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

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/build/uClibc/libc/misc/internals/Makefile b/ap/build/uClibc/libc/misc/internals/Makefile
new file mode 100644
index 0000000..4a8f4a0
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../
+top_builddir=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/ap/build/uClibc/libc/misc/internals/Makefile.in b/ap/build/uClibc/libc/misc/internals/Makefile.in
new file mode 100644
index 0000000..354dfc9
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/Makefile.in
@@ -0,0 +1,43 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libc/misc/internals
+
+CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c \
+	parse_config.c
+
+MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
+MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
+
+MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
+MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
+
+CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
+
+
+libc-y += $(MISC_INTERNALS_OBJ)
+ifneq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
+libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS
+else
+libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.os
+endif
+libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
+libc-static-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += \
+  $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \
+  $(MISC_INTERNALS_OUT)/shared_flat_add_library.o
+libc-static-$(UCLIBC_FORMAT_SHARED_FLAT) += \
+  $(MISC_INTERNALS_OUT)/shared_flat_initfini.o \
+  $(MISC_INTERNALS_OUT)/shared_flat_add_library.o
+libc-shared-$(UCLIBC_FORMAT_SHARED_FLAT) += \
+  $(MISC_INTERNALS_OUT)/shared_flat_initfini.os \
+  $(MISC_INTERNALS_OUT)/shared_flat_add_library.os
+libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
+
+objclean-y += CLEAN_libc/misc/internals
+
+CLEAN_libc/misc/internals:
+	$(do_rm) $(addprefix $(MISC_INTERNALS_OUT)/*., o os oS)
diff --git a/ap/build/uClibc/libc/misc/internals/__errno_location.c b/ap/build/uClibc/libc/misc/internals/__errno_location.c
new file mode 100644
index 0000000..aec7641
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/__errno_location.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "internal_errno.h"
+
+/* psm: moved to bits/errno.h: */
+int *
+#ifndef __UCLIBC_HAS_THREADS__
+weak_const_function
+#endif
+__errno_location (void)
+{
+    return &errno;
+}
+#ifdef IS_IN_libc /* not really need, only to keep in sync w/ libc_hidden_proto */
+libc_hidden_weak(__errno_location)
+#endif
diff --git a/ap/build/uClibc/libc/misc/internals/__h_errno_location.c b/ap/build/uClibc/libc/misc/internals/__h_errno_location.c
new file mode 100644
index 0000000..213d398
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/__h_errno_location.c
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "internal_errno.h"
+
+int * weak_const_function __h_errno_location (void)
+{
+    return &h_errno;
+}
+libc_hidden_weak(__h_errno_location)
diff --git a/ap/build/uClibc/libc/misc/internals/__uClibc_main.c b/ap/build/uClibc/libc/misc/internals/__uClibc_main.c
new file mode 100644
index 0000000..71fdbd8
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/__uClibc_main.c
@@ -0,0 +1,518 @@
+/*
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2001 by Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * __uClibc_main is the routine to be called by all the arch-specific
+ * versions of crt1.S in uClibc.
+ *
+ * It is meant to handle any special initialization needed by the library
+ * such as setting the global variable(s) __environ (environ) and
+ * initializing the stdio package.  Using weak symbols, the latter is
+ * avoided in the static library case.
+ */
+
+#include <features.h>
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+#define	_ERRNO_H
+#endif
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <elf.h>
+#include <link.h>
+#include <bits/uClibc_page.h>
+#include <paths.h>
+#include <unistd.h>
+#include <asm/errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <pthread-functions.h>
+#include <not-cancel.h>
+#include <atomic.h>
+#endif
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+#endif 
+
+#ifndef SHARED
+void *__libc_stack_end = NULL;
+
+# ifdef __UCLIBC_HAS_SSP__
+#  include <dl-osinfo.h>
+static uintptr_t stack_chk_guard;
+#  ifndef THREAD_SET_STACK_GUARD
+/* Only exported for architectures that don't store the stack guard canary
+ * in thread local area. */
+/* for gcc-4.1 non-TLS */
+uintptr_t __stack_chk_guard attribute_relro;
+#  endif
+/* for gcc-3.x + Etoh ssp */
+#  ifdef __UCLIBC_HAS_SSP_COMPAT__
+uintptr_t __guard attribute_relro;
+#  endif
+# endif
+
+/*
+ * Needed to initialize _dl_phdr when statically linked
+ */
+
+void internal_function _dl_aux_init (ElfW(auxv_t) *av);
+
+#ifdef __UCLIBC_HAS_THREADS__
+/*
+ * uClibc internal locking requires that we have weak aliases
+ * for dummy functions in case libpthread.a is not linked in.
+ * This needs to be in compilation unit that is pulled always
+ * in or linker will disregard these weaks.
+ */
+
+static int __pthread_return_0 (pthread_mutex_t *unused) { return 0; }
+weak_alias (__pthread_return_0, __pthread_mutex_lock)
+weak_alias (__pthread_return_0, __pthread_mutex_trylock)
+weak_alias (__pthread_return_0, __pthread_mutex_unlock)
+
+int weak_function
+__pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+{
+        return 0;
+}
+
+void weak_function
+_pthread_cleanup_push_defer(struct _pthread_cleanup_buffer *__buffer,
+                            void (*__routine) (void *), void *__arg)
+{
+        __buffer->__routine = __routine;
+        __buffer->__arg = __arg;
+}
+
+void weak_function
+_pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
+                             int __execute)
+{
+        if (__execute)
+                __buffer->__routine(__buffer->__arg);
+}
+#endif /* __UCLIBC_HAS_THREADS__ */
+
+#endif /* !SHARED */
+
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+	const void *q;
+	__asm__ (""
+		: "=r" (q) /* output */
+		: "0" (p) /* input */
+	);
+	return q != 0;
+}
+
+/*
+ * Prototypes.
+ */
+extern int *weak_const_function __errno_location(void);
+extern int *weak_const_function __h_errno_location(void);
+extern void weak_function _stdio_init(void) attribute_hidden;
+#ifdef __UCLIBC_HAS_LOCALE__
+extern void weak_function _locale_init(void) attribute_hidden;
+#endif
+#ifdef __UCLIBC_HAS_THREADS__
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
+extern void weak_function __pthread_initialize_minimal(void);
+#else
+extern void __pthread_initialize_minimal(void);
+#endif
+#endif
+
+/* If __UCLIBC_FORMAT_SHARED_FLAT__, all array initialisation and finalisation
+ * is handled by the routines passed to __uClibc_main().  */
+#if defined (__UCLIBC_CTOR_DTOR__) && !defined (__UCLIBC_FORMAT_SHARED_FLAT__)
+extern void _dl_app_init_array(void);
+extern void _dl_app_fini_array(void);
+# ifndef SHARED
+/* These magic symbols are provided by the linker.  */
+extern void (*__preinit_array_start []) (void) attribute_hidden;
+extern void (*__preinit_array_end []) (void) attribute_hidden;
+extern void (*__init_array_start []) (void) attribute_hidden;
+extern void (*__init_array_end []) (void) attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+# endif
+#endif
+
+#if defined (__LDSO_STANDALONE_SUPPORT__) && defined (SHARED) && defined __sh__
+extern unsigned long _dl_skip_args;
+#endif
+
+attribute_hidden const char *__uclibc_progname = "";
+#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+const char *program_invocation_short_name = "";
+const char *program_invocation_name = "";
+#endif
+#ifdef __UCLIBC_HAS___PROGNAME__
+weak_alias (program_invocation_short_name, __progname)
+weak_alias (program_invocation_name, __progname_full)
+#endif
+
+/*
+ * Declare the __environ global variable and create a weak alias environ.
+ * This must be initialized; we cannot have a weak alias into bss.
+ */
+char **__environ = 0;
+weak_alias(__environ, environ)
+
+/* TODO: don't export __pagesize; we cant now because libpthread uses it */
+size_t __pagesize = 0;
+
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW	0
+#endif
+
+#ifndef __ARCH_HAS_NO_LDSO__
+static void __check_one_fd(int fd, int mode)
+{
+    /* Check if the specified fd is already open */
+    if (fcntl(fd, F_GETFD) == -1)
+    {
+	/* The descriptor is probably not open, so try to use /dev/null */
+	int nullfd = open(_PATH_DEVNULL, mode);
+	/* /dev/null is major=1 minor=3.  Make absolutely certain
+	 * that is in fact the device that we have opened and not
+	 * some other wierd file... [removed in uclibc] */
+	if (nullfd!=fd)
+	{
+		abort();
+	}
+    }
+}
+
+static int __check_suid(void)
+{
+    uid_t uid, euid;
+    gid_t gid, egid;
+
+    uid  = getuid();
+    euid = geteuid();
+    if (uid != euid)
+	return 1;
+    gid  = getgid();
+    egid = getegid();
+    if (gid != egid)
+	return 1;
+    return 0; /* we are not suid */
+}
+#endif
+
+/* __uClibc_init completely initialize uClibc so it is ready to use.
+ *
+ * On ELF systems (with a dynamic loader) this function must be called
+ * from the dynamic loader (see TIS and ELF Specification), so that
+ * constructors of shared libraries (which depend on libc) can use all
+ * the libc code without restriction.  For this we link the shared
+ * version of the uClibc with -init __uClibc_init so DT_INIT for
+ * uClibc is the address of __uClibc_init
+ *
+ * In all other cases we call it from the main stub
+ * __uClibc_main.
+ */
+
+extern void __uClibc_init(void);
+libc_hidden_proto(__uClibc_init)
+void __uClibc_init(void)
+{
+    /* Don't recurse */
+    if (__pagesize)
+	return;
+
+    /* Setup an initial value.  This may not be perfect, but is
+     * better than  malloc using __pagesize=0 for atexit, ctors, etc.  */
+    __pagesize = PAGE_SIZE;
+
+#ifdef __UCLIBC_HAS_THREADS__
+    /* Before we start initializing uClibc we have to call
+     * __pthread_initialize_minimal so we can use pthread_locks
+     * whenever they are needed.
+     */
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
+    if (likely(__pthread_initialize_minimal!=NULL))
+#endif
+	__pthread_initialize_minimal();
+#endif
+
+#ifndef SHARED
+# ifdef __UCLIBC_HAS_SSP__
+    /* Set up the stack checker's canary.  */
+    stack_chk_guard = _dl_setup_stack_chk_guard();
+#  ifdef THREAD_SET_STACK_GUARD
+    THREAD_SET_STACK_GUARD (stack_chk_guard);
+#  else
+    __stack_chk_guard = stack_chk_guard;
+#  endif
+#  ifdef __UCLIBC_HAS_SSP_COMPAT__
+    __guard = stack_chk_guard;
+#  endif
+# endif
+#endif
+
+#ifdef __UCLIBC_HAS_LOCALE__
+    /* Initialize the global locale structure. */
+    if (likely(not_null_ptr(_locale_init)))
+	_locale_init();
+#endif
+
+    /*
+     * Initialize stdio here.  In the static library case, this will
+     * be bypassed if not needed because of the weak alias above.
+     * Thus we get a nice size savings because the stdio functions
+     * won't be pulled into the final static binary unless used.
+     */
+    if (likely(not_null_ptr(_stdio_init)))
+	_stdio_init();
+
+}
+libc_hidden_def(__uClibc_init)
+
+#ifdef __UCLIBC_CTOR_DTOR__
+void attribute_hidden (*__app_fini)(void) = NULL;
+#endif
+
+void attribute_hidden (*__rtld_fini)(void) = NULL;
+
+extern void __uClibc_fini(void);
+libc_hidden_proto(__uClibc_fini)
+void __uClibc_fini(void)
+{
+#ifdef __UCLIBC_CTOR_DTOR__
+    /* If __UCLIBC_FORMAT_SHARED_FLAT__, all array finalisation is handled
+     * by __app_fini.  */
+# ifdef SHARED
+    _dl_app_fini_array();
+# elif !defined (__UCLIBC_FORMAT_SHARED_FLAT__)
+    size_t i = __fini_array_end - __fini_array_start;
+    while (i-- > 0)
+	(*__fini_array_start [i]) ();
+# endif
+    if (__app_fini != NULL)
+	(__app_fini)();
+#endif
+    if (__rtld_fini != NULL)
+	(__rtld_fini)();
+}
+libc_hidden_def(__uClibc_fini)
+
+#ifndef SHARED
+extern void __nptl_deallocate_tsd (void) __attribute ((weak));
+extern unsigned int __nptl_nthreads __attribute ((weak));
+#endif
+
+/* __uClibc_main is the new main stub for uClibc. This function is
+ * called from crt1 (version 0.9.28 or newer), after ALL shared libraries
+ * are initialized, just before we call the application's main function.
+ */
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+		    char **argv, void (*app_init)(void), void (*app_fini)(void),
+		    void (*rtld_fini)(void),
+		    void *stack_end attribute_unused) attribute_noreturn;
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+		    char **argv, void (*app_init)(void), void (*app_fini)(void),
+		    void (*rtld_fini)(void), void *stack_end attribute_unused)
+{
+#ifndef __ARCH_HAS_NO_LDSO__
+    unsigned long *aux_dat;
+    ElfW(auxv_t) auxvt[AT_EGID + 1];
+#endif
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	/* Result of the 'main' function.  */
+	int result;
+#endif
+
+#ifndef SHARED
+    __libc_stack_end = stack_end;
+#endif
+
+    __rtld_fini = rtld_fini;
+
+#if defined __LDSO_STANDALONE_SUPPORT__ && defined SHARED && defined __sh__
+	/*
+	 * Skip ld.so and its arguments
+	 * Other archs except for SH do this in _dl_start before passing
+	 * control to the application.
+	 * FIXME: align SH _dl_start to other archs and remove this from here,
+	 *        so that we can keep the visibility hidden.
+	 */
+	argc -= _dl_skip_args;
+	argv += _dl_skip_args;
+#endif
+
+    /* The environment begins right after argv.  */
+    __environ = &argv[argc + 1];
+
+    /* If the first thing after argv is the arguments
+     * then the environment is empty. */
+    if ((char *) __environ == *argv) {
+	/* Make __environ point to the NULL at argv[argc] */
+	__environ = &argv[argc];
+    }
+
+#ifndef __ARCH_HAS_NO_LDSO__
+    /* Pull stuff from the ELF header when possible */
+    memset(auxvt, 0x00, sizeof(auxvt));
+    aux_dat = (unsigned long*)__environ;
+    while (*aux_dat) {
+	aux_dat++;
+    }
+    aux_dat++;
+    while (*aux_dat) {
+	ElfW(auxv_t) *auxv_entry = (ElfW(auxv_t) *) aux_dat;
+	if (auxv_entry->a_type <= AT_EGID) {
+	    memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
+	}
+	aux_dat += 2;
+    }
+#ifndef SHARED
+    /* Get the program headers (_dl_phdr) from the aux vector
+       It will be used into __libc_setup_tls. */
+
+    _dl_aux_init (auxvt);
+#endif
+#endif
+
+    /* We need to initialize uClibc.  If we are dynamically linked this
+     * may have already been completed by the shared lib loader.  We call
+     * __uClibc_init() regardless, to be sure the right thing happens. */
+    __uClibc_init();
+
+#ifndef __ARCH_HAS_NO_LDSO__
+    /* Make certain getpagesize() gives the correct answer */
+    __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
+
+    /* Prevent starting SUID binaries where the stdin. stdout, and
+     * stderr file descriptors are not already opened. */
+    if ((auxvt[AT_UID].a_un.a_val == (size_t)-1 && __check_suid()) ||
+	    (auxvt[AT_UID].a_un.a_val != (size_t)-1 &&
+	    (auxvt[AT_UID].a_un.a_val != auxvt[AT_EUID].a_un.a_val ||
+	     auxvt[AT_GID].a_un.a_val != auxvt[AT_EGID].a_un.a_val)))
+    {
+	__check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW);
+	__check_one_fd (STDOUT_FILENO, O_RDWR | O_NOFOLLOW);
+	__check_one_fd (STDERR_FILENO, O_RDWR | O_NOFOLLOW);
+    }
+#endif
+
+    __uclibc_progname = *argv;
+#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+    if (*argv != NULL) {
+	program_invocation_name = *argv;
+	program_invocation_short_name = strrchr(*argv, '/');
+	if (program_invocation_short_name != NULL)
+	    ++program_invocation_short_name;
+	else
+	    program_invocation_short_name = program_invocation_name;
+    }
+#endif
+
+#ifdef __UCLIBC_CTOR_DTOR__
+    /* Arrange for the application's dtors to run before we exit.  */
+    __app_fini = app_fini;
+
+    /* If __UCLIBC_FORMAT_SHARED_FLAT__, all array initialisation is handled
+     * by __app_init.  */
+# if !defined (SHARED) && !defined (__UCLIBC_FORMAT_SHARED_FLAT__)
+    /* For dynamically linked executables the preinit array is executed by
+       the dynamic linker (before initializing any shared object).
+       For static executables, preinit happens rights before init.  */
+    {
+	const size_t size = __preinit_array_end - __preinit_array_start;
+	size_t i;
+	for (i = 0; i < size; i++)
+	    (*__preinit_array_start [i]) ();
+    }
+# endif
+    /* Run all the application's ctors now.  */
+    if (app_init!=NULL) {
+	app_init();
+    }
+    /* If __UCLIBC_FORMAT_SHARED_FLAT__, all array initialisation is handled
+     * by __app_init.  */
+# ifdef SHARED
+    _dl_app_init_array();
+# elif !defined (__UCLIBC_FORMAT_SHARED_FLAT__)
+    {
+	const size_t size = __init_array_end - __init_array_start;
+	size_t i;
+	for (i = 0; i < size; i++)
+	    (*__init_array_start [i]) ();
+    }
+# endif
+#endif
+
+    /* Note: It is possible that any initialization done above could
+     * have resulted in errno being set nonzero, so set it to 0 before
+     * we call main.
+     */
+    if (likely(not_null_ptr(__errno_location)))
+	*(__errno_location()) = 0;
+
+    /* Set h_errno to 0 as well */
+    if (likely(not_null_ptr(__h_errno_location)))
+	*(__h_errno_location()) = 0;
+
+#if defined HAVE_CLEANUP_JMP_BUF && defined __UCLIBC_HAS_THREADS_NATIVE__
+	/* Memory for the cancellation buffer.  */
+	struct pthread_unwind_buf unwind_buf;
+
+	int not_first_call;
+	not_first_call =
+		setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+	if (__builtin_expect (! not_first_call, 1))
+	{
+		struct pthread *self = THREAD_SELF;
+
+		/* Store old info.  */
+		unwind_buf.priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
+		unwind_buf.priv.data.cleanup = THREAD_GETMEM (self, cleanup);
+
+		/* Store the new cleanup handler info.  */
+		THREAD_SETMEM (self, cleanup_jmp_buf, &unwind_buf);
+
+		/* Run the program.  */
+		result = main (argc, argv, __environ);
+	}
+	else
+	{
+		/* Remove the thread-local data.  */
+# ifdef SHARED
+		__libc_pthread_functions.ptr__nptl_deallocate_tsd ();
+# else
+		__nptl_deallocate_tsd ();
+# endif
+
+		/* One less thread.  Decrement the counter.  If it is zero we
+		   terminate the entire process.  */
+		result = 0;
+# ifdef SHARED
+		unsigned int *const ptr = __libc_pthread_functions.ptr_nthreads;
+# else
+		unsigned int *const ptr = &__nptl_nthreads;
+# endif
+
+		if (! atomic_decrement_and_test (ptr))
+			/* Not much left to do but to exit the thread, not the process.  */
+			__exit_thread_inline (0);
+	}
+
+	exit (result);
+#else
+	/*
+	 * Finally, invoke application's main and then exit.
+	 */
+	exit (main (argc, argv, __environ));
+#endif
+}
diff --git a/ap/build/uClibc/libc/misc/internals/errno.c b/ap/build/uClibc/libc/misc/internals/errno.c
new file mode 100644
index 0000000..11d19ee
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/errno.c
@@ -0,0 +1,21 @@
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_TLS__
+__thread int errno;
+__thread int h_errno;
+
+extern __thread int __libc_errno __attribute__ ((alias ("errno"))) attribute_hidden;
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno"))) attribute_hidden;
+#define h_errno __libc_h_errno
+
+#else
+#include "internal_errno.h"
+int errno = 0;
+int h_errno = 0;
+#ifdef __UCLIBC_HAS_THREADS__
+libc_hidden_def(errno)
+weak_alias(errno, _errno)
+libc_hidden_def(h_errno)
+weak_alias(h_errno, _h_errno)
+#endif
+#endif
diff --git a/ap/build/uClibc/libc/misc/internals/internal_errno.h b/ap/build/uClibc/libc/misc/internals/internal_errno.h
new file mode 100644
index 0000000..b491985
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/internal_errno.h
@@ -0,0 +1,21 @@
+/*
+ *
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <netdb.h>
+
+#ifndef __UCLIBC_HAS_TLS__
+
+#undef errno
+#undef h_errno
+
+extern int h_errno;
+extern int errno;
+
+#ifdef __UCLIBC_HAS_THREADS__
+libc_hidden_proto(h_errno)
+libc_hidden_proto(errno)
+#endif
+#endif
diff --git a/ap/build/uClibc/libc/misc/internals/parse_config.c b/ap/build/uClibc/libc/misc/internals/parse_config.c
new file mode 100644
index 0000000..4d21b5e
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/parse_config.c
@@ -0,0 +1,278 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * config file parser helper
+ *
+ * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Also for use in uClibc (http://uclibc.org/) licensed under LGPLv2.1 or later.
+ */
+
+#if !defined _LIBC
+#include "libbb.h"
+
+#if defined ENABLE_PARSE && ENABLE_PARSE
+int parse_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int parse_main(int argc UNUSED_PARAM, char **argv)
+{
+	const char *delims = "# \t";
+	unsigned flags = PARSE_NORMAL;
+	int mintokens = 0, ntokens = 128;
+
+	opt_complementary = "-1:n+:m+:f+";
+	getopt32(argv, "n:m:d:f:", &ntokens, &mintokens, &delims, &flags);
+	//argc -= optind;
+	argv += optind;
+	while (*argv) {
+		parser_t *p = config_open(*argv);
+		if (p) {
+			int n;
+			char **t = xmalloc(sizeof(char *) * ntokens);
+			while ((n = config_read(p, t, ntokens, mintokens, delims, flags)) != 0) {
+				for (int i = 0; i < n; ++i)
+					printf("[%s]", t[i]);
+				puts("");
+			}
+			config_close(p);
+		}
+		argv++;
+	}
+	return EXIT_SUCCESS;
+}
+#endif
+#else
+# include <unistd.h>
+# include <string.h>
+# include <malloc.h>
+# include <bits/uClibc_page.h>
+# include "internal/parse_config.h"
+# ifndef FAST_FUNC
+#  define FAST_FUNC
+# endif
+# define fopen_or_warn_stdin fopen
+# define bb_error_msg(...)
+# define xstrdup strdup
+# define xfunc_die() return 0
+/* Read up to EOF or EOL, treat line-continuations as extending the line.
+   Return number of bytes read into .line, -1 otherwise  */
+static off_t bb_get_chunk_with_continuation(parser_t* parsr)
+{
+	off_t pos = 0;
+	char *chp;
+
+	while (1) {
+		if (fgets(parsr->line + pos, parsr->line_len - pos, parsr->fp) == NULL) {
+			memset(parsr->line, 0, parsr->line_len);
+			pos = -1;
+			break;
+		}
+		pos += strlen(parsr->line + pos);
+		chp = strchr(parsr->line, '\n');
+		if (chp) {
+			--pos;
+			if (--*chp == '\\')
+				--pos;
+			else
+				break;
+		} else if (parsr->allocated) {
+			parsr->line_len += PAGE_SIZE;
+			parsr->data = realloc(parsr->data,
+								   parsr->data_len + parsr->line_len);
+			parsr->line = parsr->data + parsr->data_len;
+		} else {
+			/* discard rest of line if not enough space in buffer */
+			int c;
+			do {
+				c = fgetc(parsr->fp);
+			} while (c != EOF && c != '\n');
+			break;
+		}
+	}
+	return pos;
+}
+#endif
+
+/*
+
+Typical usage:
+
+----- CUT -----
+	char *t[3];	// tokens placeholder
+	parser_t *p = config_open(filename);
+	if (p) {
+		// parse line-by-line
+		while (config_read(p, t, 3, 0, delimiters, flags)) { // 1..3 tokens
+			// use tokens
+			bb_error_msg("TOKENS: [%s][%s][%s]", t[0], t[1], t[2]);
+		}
+		...
+		// free parser
+		config_close(p);
+	}
+----- CUT -----
+
+*/
+
+static __always_inline parser_t * FAST_FUNC config_open2(const char *filename,
+	FILE* FAST_FUNC (*fopen_func)(const char *path, const char *mode))
+{
+	parser_t *parser;
+	FILE* fp;
+
+	fp = fopen_func(filename, "r");
+	if (!fp)
+		return NULL;
+	parser = calloc(1, sizeof(*parser));
+	if (parser) {
+		parser->fp = fp;
+	}
+	return parser;
+}
+
+parser_t attribute_hidden * FAST_FUNC config_open(const char *filename)
+{
+	return config_open2(filename, fopen_or_warn_stdin);
+}
+
+#ifdef UNUSED
+static void config_free_data(parser_t *parser)
+{
+	free(parser->data);
+	parser->data = parser->line = NULL;
+}
+#endif
+
+void attribute_hidden FAST_FUNC config_close(parser_t *parser)
+{
+	if (parser) {
+		fclose(parser->fp);
+		if (parser->allocated)
+			free(parser->data);
+		free(parser);
+	}
+}
+
+/*
+0. If parser is NULL return 0.
+1. Read a line from config file. If nothing to read then return 0.
+   Handle continuation character. Advance lineno for each physical line.
+   Discard everything past comment character.
+2. if PARSE_TRIM is set (default), remove leading and trailing delimiters.
+3. If resulting line is empty goto 1.
+4. Look for first delimiter. If !PARSE_COLLAPSE or !PARSE_TRIM is set then
+   remember the token as empty.
+5. Else (default) if number of seen tokens is equal to max number of tokens
+   (token is the last one) and PARSE_GREEDY is set then the remainder
+   of the line is the last token.
+   Else (token is not last or PARSE_GREEDY is not set) just replace
+   first delimiter with '\0' thus delimiting the token.
+6. Advance line pointer past the end of token. If number of seen tokens
+   is less than required number of tokens then goto 4.
+7. Check the number of seen tokens is not less the min number of tokens.
+   Complain or die otherwise depending on PARSE_MIN_DIE.
+8. Return the number of seen tokens.
+
+mintokens > 0 make config_read() print error message if less than mintokens
+(but more than 0) are found. Empty lines are always skipped (not warned about).
+*/
+#undef config_read
+int attribute_hidden FAST_FUNC config_read(parser_t *parser, char ***tokens,
+											unsigned flags, const char *delims)
+{
+	char *line;
+	int ntokens, mintokens;
+	off_t len;
+	int t;
+
+	if (parser == NULL)
+		return 0;
+	ntokens = flags & 0xFF;
+	mintokens = (flags & 0xFF00) >> 8;
+again:
+	if (parser->data == NULL) {
+		if (parser->line_len == 0)
+			parser->line_len = 81;
+		if (parser->data_len == 0)
+			parser->data_len += 1 + ntokens * sizeof(char *);
+		parser->data = malloc(parser->data_len + parser->line_len);
+		if (parser->data == NULL)
+			return 0;
+		parser->allocated |= 1;
+	} /* else { assert(parser->data_len > 0); } */
+	parser->line = parser->data + parser->data_len;
+	/*config_free_data(parser);*/
+
+	/* Read one line (handling continuations with backslash) */
+	len = bb_get_chunk_with_continuation(parser);
+	if (len == -1)
+		return 0;
+	line = parser->line;
+
+	/* Skip multiple token-delimiters in the start of line? */
+	if (flags & PARSE_TRIM)
+		line += strspn(line, delims + 1);
+
+	if (line[0] == '\0' || line[0] == delims[0])
+		goto again;
+
+	*tokens = (char **) parser->data;
+	memset(*tokens, 0, sizeof(*tokens[0]) * ntokens);
+
+	/* Tokenize the line */
+	for (t = 0; *line && *line != delims[0] && t < ntokens; t++) {
+		/* Pin token */
+		*(*tokens + t) = line;
+
+		/* Combine remaining arguments? */
+		if ((t != ntokens-1) || !(flags & PARSE_GREEDY)) {
+			/* Vanilla token, find next delimiter */
+			line += strcspn(line, delims[0] ? delims : delims + 1);
+		} else {
+			/* Combining, find comment char if any */
+			line = strchrnul(line, delims[0]);
+
+			/* Trim any extra delimiters from the end */
+			if (flags & PARSE_TRIM) {
+				while (strchr(delims + 1, line[-1]) != NULL)
+					line--;
+			}
+		}
+
+		/* Token not terminated? */
+		if (line[0] == delims[0])
+			*line = '\0';
+		else if (line[0] != '\0')
+			*(line++) = '\0';
+
+#if 0 /* unused so far */
+		if (flags & PARSE_ESCAPE) {
+			const char *from;
+			char *to;
+
+			from = to = tokens[t];
+			while (*from) {
+				if (*from == '\\') {
+					from++;
+					*to++ = bb_process_escape_sequence(&from);
+				} else {
+					*to++ = *from++;
+				}
+			}
+			*to = '\0';
+		}
+#endif
+
+		/* Skip possible delimiters */
+		if (flags & PARSE_COLLAPSE)
+			line += strspn(line, delims + 1);
+	}
+
+	if (t < mintokens) {
+		bb_error_msg(/*"bad line %u: "*/"%d tokens found, %d needed",
+				/*parser->lineno, */t, mintokens);
+		if (flags & PARSE_MIN_DIE)
+			xfunc_die();
+		goto again;
+	}
+	return t;
+}
diff --git a/ap/build/uClibc/libc/misc/internals/shared_flat_add_library.c b/ap/build/uClibc/libc/misc/internals/shared_flat_add_library.c
new file mode 100644
index 0000000..f03480f
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/shared_flat_add_library.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 CodeSourcery Inc
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * This file defines __shared_flat_add_library.  If a library has
+ * initialistion and finalisation code, it should use this routine
+ * to register itself.
+ */
+#include "shared_flat_lib.h"
+
+/* The initialisation and finalisation symbols for this library.  */
+extern void _init(void) attribute_hidden weak_function;
+extern void _fini(void) attribute_hidden weak_function;
+extern void (*__preinit_array_start[])(void) attribute_hidden;
+extern void (*__preinit_array_end[])(void) attribute_hidden;
+extern void (*__init_array_start[])(void) attribute_hidden;
+extern void (*__init_array_end[])(void) attribute_hidden;
+extern void (*__fini_array_start[])(void) attribute_hidden;
+extern void (*__fini_array_end[])(void) attribute_hidden;
+
+/* The shared_flat_lib structure that describes this library.  */
+static struct shared_flat_lib this_lib = {
+	0,
+	0,
+	__preinit_array_start,
+	__preinit_array_end,
+	__init_array_start,
+	__init_array_end,
+	__fini_array_start,
+	__fini_array_end,
+	_init,
+	_fini
+};
+
+/* Add this_lib to the end of the global list. */
+void __shared_flat_add_library(void) attribute_hidden;
+void __shared_flat_add_library(void)
+{
+	this_lib.prev = __last_shared_lib;
+	if (this_lib.prev)
+		this_lib.prev->next = &this_lib;
+	else
+		__first_shared_lib = &this_lib;
+	__last_shared_lib = &this_lib;
+}
diff --git a/ap/build/uClibc/libc/misc/internals/shared_flat_initfini.c b/ap/build/uClibc/libc/misc/internals/shared_flat_initfini.c
new file mode 100644
index 0000000..81e5383
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/shared_flat_initfini.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2006 CodeSourcery Inc
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * This file defines the main initialisation and finalisation code for
+ * shared flat libraries.  It in turn calls the initialisation and
+ * finalisation code for each registered library.
+ */
+#include "shared_flat_lib.h"
+
+/* A doubly-linked list of shared libraries.  Those nearer the head
+ * of the list should be initialised first and finalised last.  */
+struct shared_flat_lib *__first_shared_lib;
+struct shared_flat_lib *__last_shared_lib;
+
+void __shared_flat_init(void)
+{
+	struct shared_flat_lib *lib;
+	void (**start)(void);
+	void (**end)(void);
+
+	for (lib = __first_shared_lib; lib; lib = lib->next) {
+		end = lib->preinit_array_end;
+		for (start = lib->preinit_array_start; start < end; start++)
+			(*start)();
+	}
+
+	for (lib = __first_shared_lib; lib; lib = lib->next) {
+		if (lib->init)
+			lib->init();
+
+		end = lib->init_array_end;
+		for (start = lib->init_array_start; start < end; start++)
+			(*start)();
+	}
+}
+
+void __shared_flat_fini(void)
+{
+	struct shared_flat_lib *lib;
+	void (**start)(void);
+	void (**end)(void);
+
+	for (lib = __last_shared_lib; lib; lib = lib->prev) {
+		start = lib->fini_array_start;
+		for (end = lib->fini_array_end; end > start;)
+			(*--end)();
+
+		if (lib->fini)
+			lib->fini();
+	}
+}
diff --git a/ap/build/uClibc/libc/misc/internals/shared_flat_lib.h b/ap/build/uClibc/libc/misc/internals/shared_flat_lib.h
new file mode 100644
index 0000000..e012135
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/shared_flat_lib.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 CodeSourcery Inc
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * This file defines the shared_flat_lib structure and the global library
+ * list.   The structure is used to provide something close to ELF-like
+ * initialisation and finalisation when using shared flat libraries.
+ */
+#ifndef __SHARED_FLAT_LIB__
+#define __SHARED_FLAT_LIB__
+
+struct shared_flat_lib {
+	struct shared_flat_lib *prev;
+	struct shared_flat_lib *next;
+	/* .preinit_array is usually only supported for executables.
+	 * However, the distinction between the executable and its
+	 * shared libraries isn't as pronounced for flat files; a shared
+	 * library is really just a part of an executable that can be
+	 * shared with other executables.  We therefore allow
+	 * .preinit_array to be used in libraries too.  */
+	void (**preinit_array_start)(void);
+	void (**preinit_array_end)(void);
+	void (**init_array_start)(void);
+	void (**init_array_end)(void);
+	void (**fini_array_start)(void);
+	void (**fini_array_end)(void);
+	void (*init)(void);
+	void (*fini)(void);
+};
+
+extern struct shared_flat_lib *__first_shared_lib;
+extern struct shared_flat_lib *__last_shared_lib;
+
+#endif
diff --git a/ap/build/uClibc/libc/misc/internals/tempname.c b/ap/build/uClibc/libc/misc/internals/tempname.c
new file mode 100644
index 0000000..28c0098
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/tempname.c
@@ -0,0 +1,252 @@
+/* Copyright (C) 1991,92,93,94,95,96,97,98,99 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* March 11, 2002       Manuel Novoa III
+ *
+ * Modify code to remove dependency on libgcc long long arith support funcs.
+ */
+
+/* June 6, 2004       Erik Andersen
+ *
+ * Don't use brain damaged getpid() based randomness.
+ */
+
+/* April 15, 2005     Mike Frysinger
+ *
+ * Use brain damaged getpid() if real random fails.
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include "tempname.h"
+
+/* Return nonzero if DIR is an existent directory.  */
+static int direxists (const char *dir)
+{
+    struct stat buf;
+    return stat(dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+}
+
+/* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
+   non-null and exists, uses it; otherwise uses the first of $TMPDIR,
+   P_tmpdir, /tmp that exists.  Copies into TMPL a template suitable
+   for use with mk[s]temp.  Will fail (-1) if DIR is non-null and
+   doesn't exist, none of the searched dirs exists, or there's not
+   enough space in TMPL. */
+int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *dir,
+	const char *pfx /*, int try_tmpdir*/)
+{
+    /*const char *d; */
+    /* dir and pfx lengths should always fit into an int,
+       so don't bother using size_t here.  Especially since
+       the printf func requires an int for precision (%*s).  */
+    int dlen, plen;
+
+    if (!pfx || !pfx[0])
+    {
+	pfx = "file";
+	plen = 4;
+    }
+    else
+    {
+	plen = strlen (pfx);
+	if (plen > 5)
+	    plen = 5;
+    }
+
+    /* Disable support for $TMPDIR */
+#if 0
+    if (try_tmpdir)
+    {
+	d = __secure_getenv ("TMPDIR");
+	if (d != NULL && direxists (d))
+	    dir = d;
+	else if (dir != NULL && direxists (dir))
+	    /* nothing */ ;
+	else
+	    dir = NULL;
+    }
+#endif
+    if (dir == NULL)
+    {
+	if (direxists (P_tmpdir))
+	    dir = P_tmpdir;
+	else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
+	    dir = "/tmp";
+	else
+	{
+	    __set_errno (ENOENT);
+	    return -1;
+	}
+    }
+
+    dlen = strlen (dir);
+    while (dlen > 1 && dir[dlen - 1] == '/')
+	dlen--;			/* remove trailing slashes */
+
+    /* check we have room for "${dir}/${pfx}XXXXXX\0" */
+    if (tmpl_len < (size_t)dlen + 1 + plen + 6 + 1)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    sprintf (tmpl, "%.*s/%.*sXXXXXX", dlen, dir, plen, pfx);
+    return 0;
+}
+
+/* These are the characters used in temporary filenames.  */
+static const char letters[] =
+"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+#define NUM_LETTERS (62)
+
+static unsigned int fillrand(unsigned char *buf, unsigned int len)
+{
+    int fd;
+    unsigned int result = -1;
+    fd = open("/dev/urandom", O_RDONLY);
+    if (fd < 0) {
+	fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
+    }
+    if (fd >= 0) {
+	result = read(fd, buf, len);
+	close(fd);
+    }
+    return result;
+}
+
+static void brain_damaged_fillrand(unsigned char *buf, unsigned int len)
+{
+	unsigned int i, k;
+	struct timeval tv;
+	uint32_t high, low, rh;
+	static uint64_t value;
+	gettimeofday(&tv, NULL);
+	value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid();
+	low = value & UINT32_MAX;
+	high = value >> 32;
+	for (i = 0; i < len; ++i) {
+		rh = high % NUM_LETTERS;
+		high /= NUM_LETTERS;
+#define L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS)
+		k = (low % NUM_LETTERS) + (L * rh);
+#undef L
+#define H ((UINT32_MAX / NUM_LETTERS) + ((UINT32_MAX % NUM_LETTERS + 1) / NUM_LETTERS))
+		low = (low / NUM_LETTERS) + (H * rh) + (k / NUM_LETTERS);
+#undef H
+		k %= NUM_LETTERS;
+		buf[i] = letters[k];
+	}
+}
+
+/* Generate a temporary file name based on TMPL.  TMPL must match the
+   rules for mk[s]temp (i.e. end in "XXXXXX").  The name constructed
+   does not exist at the time of the call to __gen_tempname.  TMPL is
+   overwritten with the result.
+
+   KIND may be one of:
+   __GT_NOCREATE:       simply verify that the name does not exist
+                        at the time of the call. mode argument is ignored.
+   __GT_FILE:           create the file using open(O_CREAT|O_EXCL)
+                        and return a read-write fd with given mode.
+   __GT_BIGFILE:        same as __GT_FILE but use open64().
+   __GT_DIR:            create a directory with given mode.
+
+*/
+int attribute_hidden __gen_tempname (char *tmpl, int kind, mode_t mode)
+{
+    char *XXXXXX;
+    unsigned int i;
+    int fd, save_errno = errno;
+    unsigned char randomness[6];
+    size_t len;
+
+    len = strlen (tmpl);
+    /* This is where the Xs start.  */
+    XXXXXX = tmpl + len - 6;
+    if (len < 6 || strcmp (XXXXXX, "XXXXXX"))
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    for (i = 0; i < TMP_MAX; ++i) {
+	unsigned char j;
+	/* Get some random data.  */
+	if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) {
+	    /* if random device nodes failed us, lets use the braindamaged ver */
+	    brain_damaged_fillrand(randomness, sizeof(randomness));
+	}
+	for (j = 0; j < sizeof(randomness); ++j)
+	    XXXXXX[j] = letters[randomness[j] % NUM_LETTERS];
+
+	switch (kind) {
+	    case __GT_NOCREATE:
+		{
+		    struct stat st;
+		    if (stat (tmpl, &st) < 0) {
+			if (errno == ENOENT) {
+			    fd = 0;
+			    goto restore_and_ret;
+			} else
+			    /* Give up now. */
+			    return -1;
+		    } else
+			fd = 0;
+		}
+	    case __GT_FILE:
+		fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, mode);
+		break;
+#if defined __UCLIBC_HAS_LFS__
+	    case __GT_BIGFILE:
+		fd = open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, mode);
+		break;
+#endif
+	    case __GT_DIR:
+		fd = mkdir (tmpl, mode);
+		break;
+	    default:
+		fd = -1;
+		assert (! "invalid KIND in __gen_tempname");
+	}
+
+	if (fd >= 0) {
+restore_and_ret:
+	    __set_errno (save_errno);
+	    return fd;
+	}
+	else if (errno != EEXIST)
+	    /* Any other error will apply also to other names we might
+	       try, and there are 2^32 or so of them, so give up now. */
+	    return -1;
+    }
+
+    /* We got out of the loop because we ran out of combinations to try.  */
+    __set_errno (EEXIST);
+    return -1;
+}
diff --git a/ap/build/uClibc/libc/misc/internals/tempname.h b/ap/build/uClibc/libc/misc/internals/tempname.h
new file mode 100644
index 0000000..e75b632
--- /dev/null
+++ b/ap/build/uClibc/libc/misc/internals/tempname.h
@@ -0,0 +1,21 @@
+#ifndef __TEMPNAME_H__
+#define __TEMPNAME_H__
+
+#define	__need_size_t
+#include <stddef.h>
+#include <sys/types.h>
+
+/* Disable support for $TMPDIR */
+extern int ___path_search (char *tmpl, size_t tmpl_len, const char *dir,
+	        const char *pfx /*, int try_tmpdir */) attribute_hidden;
+#define __path_search(tmpl, tmpl_len, dir, pfx, try_tmpdir) ___path_search(tmpl, tmpl_len, dir, pfx)
+
+extern int __gen_tempname (char *__tmpl, int __kind, mode_t mode) attribute_hidden;
+
+/* The __kind argument to __gen_tempname may be one of: */
+#define __GT_FILE     0       /* create a file */
+#define __GT_BIGFILE  1       /* create a file, using open64 */
+#define __GT_DIR      2       /* create a directory */
+#define __GT_NOCREATE 3       /* just find a name not currently in use */
+
+#endif