[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/unistd/.indent.pro b/ap/build/uClibc/libc/unistd/.indent.pro
new file mode 100644
index 0000000..492ecf1
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/.indent.pro
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
diff --git a/ap/build/uClibc/libc/unistd/Makefile b/ap/build/uClibc/libc/unistd/Makefile
new file mode 100644
index 0000000..11f362a
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/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/unistd/Makefile.in b/ap/build/uClibc/libc/unistd/Makefile.in
new file mode 100644
index 0000000..2704177
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/Makefile.in
@@ -0,0 +1,52 @@
+# 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/unistd
+
+UNISTD_DIR := $(top_srcdir)libc/unistd
+UNISTD_OUT := $(top_builddir)libc/unistd
+
+CSRC := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
+# multi source
+CSRC := $(filter-out exec.c,$(CSRC))
+
+ifeq ($(ARCH_USE_MMU),y)
+CSRC := $(filter-out __exec_alloc.c,$(CSRC))
+endif
+
+ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
+CSRC := $(filter-out getopt-susv3.c getopt_long-simple.c,$(CSRC))
+else
+CSRC := $(filter-out getopt.c,$(CSRC))
+ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
+CSRC := $(filter-out getopt_long-simple.c,$(CSRC))
+endif
+endif
+
+ifeq ($(UCLIBC_HAS_GNU_GETSUBOPT),y)
+CSRC := $(filter-out getsubopt-susv3.c,$(CSRC))
+else
+CSRC := $(filter-out getsubopt.c,$(CSRC))
+endif
+
+ifneq ($(UCLIBC_SUSV3_LEGACY),y)
+CSRC := $(filter-out ualarm.c usleep.c,$(CSRC))
+endif
+
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+CSRC := $(filter-out sleep.c,$(CSRC))
+endif
+
+UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC))
+UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC))
+
+libc-y += $(UNISTD_OBJ)
+
+objclean-y += CLEAN_libc/unistd
+
+CLEAN_libc/unistd:
+	$(do_rm) $(addprefix $(UNISTD_OUT)/*., o os)
diff --git a/ap/build/uClibc/libc/unistd/__exec_alloc.c b/ap/build/uClibc/libc/unistd/__exec_alloc.c
new file mode 100644
index 0000000..837ffb4
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/__exec_alloc.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___exec_alloc
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/confstr.c b/ap/build/uClibc/libc/unistd/confstr.c
new file mode 100644
index 0000000..fc0bd59
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/confstr.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 1991, 1996, 1997, 2000-2002, 2003, 2004
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+
+
+#define CS_PATH "/bin:/usr/bin"
+
+/* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
+   of BUF with the value corresponding to NAME and zero-terminate BUF.
+   Return the number of bytes required to hold NAME's entire value.  */
+size_t confstr (int name, char *buf, size_t len)
+{
+  const char *string;
+  size_t string_len;
+
+  switch (name)
+    {
+    case _CS_PATH:
+      {
+	static const char cs_path[] = CS_PATH;
+	string = cs_path;
+	string_len = sizeof (cs_path);
+      }
+      break;
+#ifdef __UCLIBC_HAS_THREADS__
+    case _CS_GNU_LIBPTHREAD_VERSION:
+# if defined __LINUXTHREADS_OLD__
+      string = "linuxthreads-0.01";
+      string_len = sizeof("linuxthreads-x.xx");
+# elif defined __LINUXTHREADS_NEW__
+      string = "linuxthreads-0.10";
+      string_len = sizeof("linuxthreads-x.xx");
+# elif defined __UCLIBC_HAS_THREADS_NATIVE__
+#  define __NPTL_VERSION ("NPTL " \
+		__stringify(__UCLIBC_MAJOR__) "." \
+		__stringify(__UCLIBC_MINOR__) "." \
+		__stringify(__UCLIBC_SUBLEVEL__))
+      string = __NPTL_VERSION;
+      string_len = sizeof(__NPTL_VERSION);
+# else
+#  error unable to determine thread impl
+# endif
+      break;
+#endif
+    default:
+      __set_errno (EINVAL);
+      return 0;
+    }
+
+  if (len > 0 && buf != NULL)
+    {
+      if (string_len <= len)
+	memcpy (buf, string, string_len);
+      else
+	{
+	  memcpy (buf, string, len - 1);
+	  buf[len - 1] = '\0';
+	}
+    }
+  return string_len;
+}
diff --git a/ap/build/uClibc/libc/unistd/daemon.c b/ap/build/uClibc/libc/unistd/daemon.c
new file mode 100644
index 0000000..628df51
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/daemon.c
@@ -0,0 +1,144 @@
+/* vi: set sw=4 ts=4: */
+/* daemon implementation for uClibc
+ *
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
+ *		ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
+ *
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ * Modified for uClibc by Erik Andersen <andersen@uclibc.org>
+ */
+
+#include <stdio.h>
+#include <features.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <signal.h>
+#include <unistd.h>
+#include <not-cancel.h>
+#include <errno.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sys/stat.h>
+#endif
+
+#ifdef __UCLIBC_HAS_LFS__
+#define STAT stat64
+#define FSTAT fstat64
+#else
+#define STAT stat
+#define FSTAT fstat
+#endif
+
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
+
+#ifndef __ARCH_USE_MMU__
+#include <sys/syscall.h>
+#include <sched.h>
+/* use clone() to get fork() like behavior here -- we just want to disassociate
+ * from the controlling terminal
+ */
+static inline attribute_optimize("O3")
+pid_t _fork_parent(void)
+{
+	INTERNAL_SYSCALL_DECL(err);
+	register long ret = INTERNAL_SYSCALL(clone, err, 2, CLONE_VM, 0);
+	if (ret > 0)
+		/* parent needs to die now w/out touching stack */
+		INTERNAL_SYSCALL(exit, err, 1, 0);
+	return ret;
+}
+static inline pid_t fork_parent(void)
+{
+	/* Block all signals to keep the parent from using the stack */
+	pid_t ret;
+	sigset_t new_set, old_set;
+	sigfillset(&new_set);
+	sigprocmask(SIG_BLOCK, &new_set, &old_set);
+	ret = _fork_parent();
+	sigprocmask(SIG_SETMASK, &old_set, NULL);
+	return ret;
+}
+#else
+static inline pid_t fork_parent(void)
+{
+	switch (fork()) {
+		case -1: return -1;
+		case 0:  return 0;
+		default: _exit(0);
+	}
+}
+#endif
+
+int daemon(int nochdir, int noclose)
+{
+	int fd;
+
+	if (fork_parent() == -1)
+		return -1;
+
+	if (setsid() == -1)
+		return -1;
+
+	if (!nochdir)
+		chdir("/");
+
+	if (!noclose)
+	{
+		struct STAT st;
+
+		if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+			&& (__builtin_expect (FSTAT (fd, &st), 0) == 0))
+		{
+			if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0) {
+				dup2(fd, STDIN_FILENO);
+				dup2(fd, STDOUT_FILENO);
+				dup2(fd, STDERR_FILENO);
+				if (fd > 2)
+					close(fd);
+			} else {
+				/* We must set an errno value since no
+				   function call actually failed.  */
+				close_not_cancel_no_status (fd);
+				__set_errno (ENODEV);
+				return -1;
+			}
+		} else {
+			close_not_cancel_no_status (fd);
+			return -1;
+		}
+	}
+	return 0;
+}
+#endif
diff --git a/ap/build/uClibc/libc/unistd/exec.c b/ap/build/uClibc/libc/unistd/exec.c
new file mode 100644
index 0000000..7d24072
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/exec.c
@@ -0,0 +1,331 @@
+/*  Copyright (C) 2004     Manuel Novoa III
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Jan 1, 2004
+ *   Initial version of a SUSv3 compliant exec*() functions.
+ * Feb 17, 2004
+ *   Sigh... Fall back to alloca() if munmap() is broken on uClinux.
+ */
+
+/* NOTE: Strictly speaking, there could be problems from accessing
+ * __environ in multithreaded programs.  The only way around this
+ * that I see is to essentially lock __environ access (modifying
+ * the setenv code), make a copy of the environment table (just the
+ * pointers since the strings themselves are never freed), and then
+ * unlock prior to the execve call.  If that fails, then we'd need
+ * to free the storage allocated for the copy.  Better ideas anyone?
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+
+
+/**********************************************************************/
+#define EXEC_FUNC_COMMON 0
+#define EXEC_FUNC_EXECVP 1
+#if defined(__ARCH_USE_MMU__)
+
+/* We have an MMU, so use alloca() to grab space for buffers and arg lists. */
+
+# define EXEC_ALLOC_SIZE(VAR)      /* nothing to do */
+# define EXEC_ALLOC(SIZE,VAR,FUNC) alloca((SIZE))
+# define EXEC_FREE(PTR,VAR)        ((void)0)
+
+#else
+
+/* We do not have an MMU, so using alloca() is not an option (as this will
+ * easily overflow the stack in most setups).  Less obviously, using malloc()
+ * is not an option either since malloc()ed memory can leak in from a vfork()ed
+ * child into the parent as no one is around after the child calls exec*() to
+ * free() the memory.  Therefore, we must use mmap() and unmap() directly,
+ * caching the result as we go.  This way we minimize the leak by reusing the
+ * memory with every call to an exec*().
+ *
+ * To prevent recursive use of the same cached memory, we have to give execvp()
+ * its own cache.  Here are the nested exec calls (a/-: alloc/no-alloc):
+ *  execve(-) -> calls straight to kernel
+ *  execl(a)  -> execve(-)
+ *  execlp(a) -> execvp(a)	!! recursive usage !!
+ *  execle(a) -> execve(-)
+ *  execv(-)  -> execve(-)
+ *  execvp(a) -> execve(-)
+ */
+
+# define EXEC_ALLOC_SIZE(VAR)      /* nothing to do */
+# define EXEC_ALLOC(SIZE,VAR,FUNC) __exec_alloc((SIZE), FUNC)
+# define EXEC_FREE(PTR,VAR)        ((void)0)
+
+extern void *__exec_alloc(size_t size, int func) attribute_hidden;
+
+# ifdef L___exec_alloc
+
+void attribute_hidden *__exec_alloc(size_t size, int func)
+{
+	static void *common_cache, *execvp_cache;
+	static size_t common_size, execvp_size;
+
+	void **cache = (func ? &execvp_cache : &common_cache);
+	size_t *cache_size = (func ? &execvp_size : &common_size);
+
+	if (*cache_size >= size)
+		return *cache;
+	else if (*cache)
+		munmap(*cache, *cache_size);
+
+	*cache_size = size;
+	return *cache = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
+
+	/* We don't actually handle OOM in the exec funcs ...
+	if (*cache != MAP_FAILED)
+		return *cache;
+	else
+		return (*cache = NULL);
+	*/
+}
+
+# endif
+
+#endif
+/**********************************************************************/
+#ifdef L_execl
+
+int execl(const char *path, const char *arg, ...)
+{
+	EXEC_ALLOC_SIZE(size)		/* Do NOT add a semicolon! */
+	int n;
+	char **argv;
+	char **p;
+	va_list args;
+
+	n = 0;
+	va_start(args, arg);
+	do {
+		++n;
+	} while (va_arg(args, char *));
+	va_end(args);
+
+	p = argv = (char **) EXEC_ALLOC((n+1) * sizeof(char *), size, EXEC_FUNC_COMMON);
+
+	p[0] = (char *)arg;
+
+	va_start(args, arg);
+	do {
+		*++p = va_arg(args, char *);
+	} while (--n);
+	va_end(args);
+
+	n = execve(path, (char *const *) argv, __environ);
+
+	EXEC_FREE(argv, size);
+
+	return n;
+}
+libc_hidden_def(execl)
+
+#endif
+/**********************************************************************/
+#ifdef L_execv
+
+int execv(__const char *path, char *__const argv[])
+{
+	return execve(path, argv, __environ);
+}
+libc_hidden_def(execv)
+
+#endif
+/**********************************************************************/
+#ifdef L_execle
+
+int execle(const char *path, const char *arg, ...)
+{
+	EXEC_ALLOC_SIZE(size)		/* Do NOT add a semicolon! */
+	int n;
+	char **argv;
+	char **p;
+	char *const *envp;
+	va_list args;
+
+	n = 0;
+	va_start(args, arg);
+	do {
+		++n;
+	} while (va_arg(args, char *));
+	envp = va_arg(args, char *const *);	/* Varies from execl and execlp. */
+	va_end(args);
+
+	p = argv = (char **) EXEC_ALLOC((n+1) * sizeof(char *), size, EXEC_FUNC_COMMON);
+
+	p[0] = (char *)arg;
+
+	va_start(args, arg);
+	do {
+		*++p = va_arg(args, char *);
+	} while (--n);
+	va_end(args);
+
+	n = execve(path, (char *const *) argv, envp);
+
+	EXEC_FREE(argv, size);
+
+	return n;
+}
+libc_hidden_def(execle)
+
+#endif
+/**********************************************************************/
+#ifdef L_execlp
+
+int execlp(const char *file, const char *arg, ...)
+{
+	EXEC_ALLOC_SIZE(size)		/* Do NOT add a semicolon! */
+	int n;
+	char **argv;
+	char **p;
+	va_list args;
+
+	n = 0;
+	va_start(args, arg);
+	do {
+		++n;
+	} while (va_arg(args, char *));
+	va_end(args);
+
+	p = argv = (char **) EXEC_ALLOC((n+1) * sizeof(char *), size, EXEC_FUNC_COMMON);
+
+	p[0] = (char *)arg;
+
+	va_start(args, arg);
+	do {
+		*++p = va_arg(args, char *);
+	} while (--n);
+	va_end(args);
+
+	n = execvp(file, (char *const *) argv);
+
+	EXEC_FREE(argv, size);
+
+	return n;
+}
+libc_hidden_def(execlp)
+
+#endif
+/**********************************************************************/
+#ifdef L_execvp
+
+
+/* Use a default path that matches glibc behavior, since SUSv3 says
+ * this is implementation-defined.  The default is current working dir,
+ * /bin, and then /usr/bin. */
+static const char default_path[] = ":/bin:/usr/bin";
+
+int execvp(const char *path, char *const argv[])
+{
+	char *buf = NULL;
+	char *p;
+	char *e;
+	char *s0;
+	char *s;
+	EXEC_ALLOC_SIZE(size = 0)	/* Do NOT add a semicolon! */
+	size_t len;
+	size_t plen;
+
+	if (!path || !*path) {		/* Comply with SUSv3. */
+	BAD:
+		__set_errno(ENOENT);
+		return -1;
+	}
+
+	if (strchr(path, '/')) {
+		execve(path, argv, __environ);
+		if (errno == ENOEXEC) {
+			char **nargv;
+			EXEC_ALLOC_SIZE(size2) /* Do NOT add a semicolon! */
+			size_t n;
+	RUN_BIN_SH:
+			/* Need the dimension - 1.  We omit counting the trailing
+			 * NULL but we actually omit the first entry. */
+			for (n=0 ; argv[n] ; n++) {}
+			nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVP);
+			nargv[0] = argv[0];
+			nargv[1] = (char *)path;
+			memcpy(nargv+2, argv+1, n*sizeof(char *));
+			execve("/bin/sh", nargv, __environ);
+			EXEC_FREE(nargv, size2);
+		}
+	} else {
+		if ((p = getenv("PATH")) != NULL) {
+			if (!*p) {
+				goto BAD;
+			}
+		} else {
+			p = (char *) default_path;
+		}
+
+		plen = strlen(path);
+		if (plen > (FILENAME_MAX - 1)) {
+		ALL_TOO_LONG:
+			__set_errno(ENAMETOOLONG);
+			return -1;
+		}
+		len = (FILENAME_MAX - 1) - plen;
+
+		buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVP);
+		{
+			int seen_small = 0;
+			s0 = buf + len;
+			memcpy(s0, path, plen+1);
+
+			do {
+				s = s0;
+				e = strchrnul(p, ':');
+				if (e > p) {
+					plen = e - p;
+					if (e[-1] != '/') {
+						++plen;
+					}
+					if (plen > len) {
+						goto NEXT;
+					}
+					s -= plen;
+					memcpy(s, p, plen);
+					s[plen-1] = '/';
+				}
+
+				execve(s, argv, __environ);
+
+				seen_small = 1;
+
+				if (errno == ENOEXEC) {
+					path = s;
+					goto RUN_BIN_SH;
+				}
+
+			NEXT:
+				if (!*e) {
+					if (!seen_small) {
+						goto ALL_TOO_LONG;
+					}
+					break;
+				}
+				p = e + 1;
+			} while (1);
+		}
+	}
+
+	EXEC_FREE(buf, size);
+
+	return -1;
+}
+libc_hidden_def(execvp)
+
+#endif
+/**********************************************************************/
diff --git a/ap/build/uClibc/libc/unistd/execl.c b/ap/build/uClibc/libc/unistd/execl.c
new file mode 100644
index 0000000..176b18b
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/execl.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execl
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/execle.c b/ap/build/uClibc/libc/unistd/execle.c
new file mode 100644
index 0000000..05dd3a0
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/execle.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execle
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/execlp.c b/ap/build/uClibc/libc/unistd/execlp.c
new file mode 100644
index 0000000..b7e615d
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/execlp.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execlp
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/execv.c b/ap/build/uClibc/libc/unistd/execv.c
new file mode 100644
index 0000000..2503042
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/execv.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execv
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/execvp.c b/ap/build/uClibc/libc/unistd/execvp.c
new file mode 100644
index 0000000..9fc025f
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/execvp.c
@@ -0,0 +1,8 @@
+/* Copyright (C) 2004      Manuel Novoa III <mjn3@uclibc.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execvp
+#include "exec.c"
diff --git a/ap/build/uClibc/libc/unistd/fpathconf.c b/ap/build/uClibc/libc/unistd/fpathconf.c
new file mode 100644
index 0000000..02b4445
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/fpathconf.c
@@ -0,0 +1,253 @@
+/* fpathconf -- adjusted for busybox
+   Copyright (C) 1991,95,96,98,99,2000,2001 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <unistd.h>
+#include <limits.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+
+
+#ifndef __USE_FILE_OFFSET64
+extern int fstatfs (int __fildes, struct statfs *__buf)
+     __THROW __nonnull ((2));
+#else
+# ifdef __REDIRECT_NTH
+	 extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
+	                            fstatfs64) __nonnull ((2));
+# else
+#  define fstatfs fstatfs64
+# endif
+#endif
+
+extern __typeof(fstatfs) __libc_fstatfs;
+
+/* The Linux kernel headers mention this as a kind of generic value.  */
+#define LINUX_LINK_MAX	127
+
+
+/* Get file-specific information about descriptor FD.  */
+long int fpathconf(int fd, int name)
+{
+    if (fd < 0)
+    {
+	__set_errno (EBADF);
+	return -1;
+    }
+
+    if (name == _PC_LINK_MAX)
+    {
+	/* Cut some corners */
+#if 0
+	struct statfs fsbuf;
+
+	/* Determine the filesystem type.  */
+	if (__libc_fstatfs (fd, &fsbuf) < 0)
+	{
+	    if (errno == ENOSYS)
+		/* not possible, return the default value.  */
+		return LINUX_LINK_MAX;
+
+	    /* Some error occured.  */
+	    return -1;
+	}
+
+	switch (fsbuf.f_type)
+	{
+	    case EXT2_SUPER_MAGIC:
+		return EXT2_LINK_MAX;
+
+	    case MINIX_SUPER_MAGIC:
+	    case MINIX_SUPER_MAGIC2:
+		return MINIX_LINK_MAX;
+
+	    case MINIX2_SUPER_MAGIC:
+	    case MINIX2_SUPER_MAGIC2:
+		return MINIX2_LINK_MAX;
+
+	    case XENIX_SUPER_MAGIC:
+		return XENIX_LINK_MAX;
+
+	    case SYSV4_SUPER_MAGIC:
+	    case SYSV2_SUPER_MAGIC:
+		return SYSV_LINK_MAX;
+
+	    case COH_SUPER_MAGIC:
+		return COH_LINK_MAX;
+
+	    case UFS_MAGIC:
+	    case UFS_CIGAM:
+		return UFS_LINK_MAX;
+
+	    case REISERFS_SUPER_MAGIC:
+		return REISERFS_LINK_MAX;
+
+	    default:
+		return LINUX_LINK_MAX;
+	}
+#else
+	return LINUX_LINK_MAX;
+#endif
+    }
+
+    switch (name)
+    {
+	default:
+	    __set_errno (EINVAL);
+	    return -1;
+
+	case _PC_MAX_CANON:
+#ifdef	MAX_CANON
+	    return MAX_CANON;
+#else
+	    return -1;
+#endif
+
+	case _PC_MAX_INPUT:
+#ifdef	MAX_INPUT
+	    return MAX_INPUT;
+#else
+	    return -1;
+#endif
+
+	case _PC_NAME_MAX:
+#ifdef	NAME_MAX
+	    {
+		struct statfs buf;
+		int save_errno = errno;
+
+		if (__libc_fstatfs (fd, &buf) < 0)
+		{
+		    if (errno == ENOSYS)
+		    {
+			errno = save_errno;
+			return NAME_MAX;
+		    }
+		    return -1;
+		}
+		else
+		{
+#ifdef _STATFS_F_NAMELEN
+		    return buf.f_namelen;
+#else
+# ifdef _STATFS_F_NAME_MAX
+		    return buf.f_name_max;
+# else
+		    return NAME_MAX;
+# endif
+#endif
+		}
+	    }
+#else
+	    return -1;
+#endif
+
+	case _PC_PATH_MAX:
+#ifdef	PATH_MAX
+	    return PATH_MAX;
+#else
+	    return -1;
+#endif
+
+	case _PC_PIPE_BUF:
+#ifdef	PIPE_BUF
+	    return PIPE_BUF;
+#else
+	    return -1;
+#endif
+
+	case _PC_CHOWN_RESTRICTED:
+#ifdef	_POSIX_CHOWN_RESTRICTED
+	    return _POSIX_CHOWN_RESTRICTED;
+#else
+	    return -1;
+#endif
+
+	case _PC_NO_TRUNC:
+#ifdef	_POSIX_NO_TRUNC
+	    return _POSIX_NO_TRUNC;
+#else
+	    return -1;
+#endif
+
+	case _PC_VDISABLE:
+#ifdef	_POSIX_VDISABLE
+	    return _POSIX_VDISABLE;
+#else
+	    return -1;
+#endif
+
+	case _PC_SYNC_IO:
+#ifdef	_POSIX_SYNC_IO
+	    return _POSIX_SYNC_IO;
+#else
+	    return -1;
+#endif
+
+	case _PC_ASYNC_IO:
+#if defined _POSIX_ASYNC_IO && defined __UCLIBC_HAS_LFS__
+	    {
+		/* AIO is only allowed on regular files and block devices.  */
+		struct stat st;
+
+		if (fstat (fd, &st) < 0 || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
+		    return -1;
+		else
+		    return 1;
+	    }
+#else
+	    return -1;
+#endif
+
+	case _PC_PRIO_IO:
+#ifdef	_POSIX_PRIO_IO
+	    return _POSIX_PRIO_IO;
+#else
+	    return -1;
+#endif
+
+	case _PC_SOCK_MAXBUF:
+#ifdef	SOCK_MAXBUF
+	    return SOCK_MAXBUF;
+#else
+	    return -1;
+#endif
+
+	case _PC_FILESIZEBITS:
+#ifdef FILESIZEBITS
+	    return FILESIZEBITS;
+#else
+	    /* We let platforms with larger file sizes overwrite this value.  */
+	    return 32;
+#endif
+
+	    /* Be lazy -- skip these */
+	case _PC_REC_INCR_XFER_SIZE:
+	case _PC_REC_MAX_XFER_SIZE:
+	case _PC_REC_MIN_XFER_SIZE:
+	case _PC_REC_XFER_ALIGN:
+	case _PC_ALLOC_SIZE_MIN:
+	case _PC_SYMLINK_MAX:
+	    return -1;
+    }
+
+}
+
diff --git a/ap/build/uClibc/libc/unistd/getlogin.c b/ap/build/uClibc/libc/unistd/getlogin.c
new file mode 100644
index 0000000..b855e50
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getlogin.c
@@ -0,0 +1,45 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * getlogin for uClibc
+ * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+
+/* uClibc makes it policy to not mess with the utmp file whenever
+ * possible, since I consider utmp a complete waste of time.  Since
+ * getlogin() should never be used for security purposes, we kindly let
+ * the user specify whatever they want via the LOGNAME environment
+ * variable, or we return NULL if getenv() fails to find anything */
+
+char * getlogin(void)
+{
+	return (getenv("LOGNAME"));
+}
+libc_hidden_def(getlogin)
+
+int getlogin_r(char *name, size_t len)
+{
+	char * foo = getenv("LOGNAME");
+
+	if (! foo)
+		return -1;
+
+	strncpy(name, foo, len);
+	name[len-1] = '\0';
+	return 0;
+}
+
+char *cuserid(char *s)
+{
+	char *name = getlogin();
+	if (s) {
+		return(strcpy(s, name ? name : ""));
+	}
+	return name;
+}
diff --git a/ap/build/uClibc/libc/unistd/getopt-susv3.c b/ap/build/uClibc/libc/unistd/getopt-susv3.c
new file mode 100644
index 0000000..d7b8d0d
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getopt-susv3.c
@@ -0,0 +1,123 @@
+/*  Copyright (C) 2003     Manuel Novoa III
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/*  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!
+ *
+ *  Besides uClibc, I'm using this code in my libc for elks, which is
+ *  a 16-bit environment with a fairly limited compiler.  It would make
+ *  things much easier for me if this file isn't modified unnecessarily.
+ *  In particular, please put any new or replacement functions somewhere
+ *  else, and modify the makefile to use your version instead.
+ *  Thanks.  Manuel
+ *
+ *  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION! */
+
+/* Sep 7, 2003
+ *   Initial version of a SUSv3 compliant getopt().
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <getopt.h>
+
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO: Enable gettext awareness.
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+#undef _
+#define _(X)   X
+
+#ifdef __BCC__
+static const char missing[] = "option requires an argument";
+static const char illegal[] = "illegal option";
+#else
+static const char missing[] = "%s: option requires an argument -- %c\n";
+static const char illegal[] = "%s: illegal option -- %c\n";
+#endif
+
+int opterr = 1;
+int optind = 1;
+int optopt = 0;
+char *optarg = NULL;
+
+int getopt(int argc, char * const argv[], const char *optstring)
+{
+	static const char *o;		/* multi opt position */
+	register const char *p;
+	register const char *s;
+	int retval = -1;
+
+	optopt = 0;
+	optarg = NULL;
+
+	if (!o) {				/* Not in a multi-option arg. */
+		if ((optind >= argc)	/* No more args? */
+			|| ((p = argv[optind]) == NULL) /* Missing? */
+			|| (*p != '-')		/* Not an option? */
+			|| (!*++p)			/* "-" case? */
+			) {
+			goto DONE;
+		}
+		if ((*p == '-') && (p[1] == 0)) { /* "--" case. */
+/* 			++optind; */
+/* 			goto DONE; */
+			goto NEXTOPT;		/* Less code generated... */
+		}
+		o = p;
+	}
+
+#ifdef __BCC__
+	p = o;						/* Sigh... Help out bcc. */
+#define o p
+#endif
+	retval = (unsigned char) *o; /* Avoid problems for char val of -1. */
+
+	if ((*o == ':') || !(s = strchr(optstring, *o))) { /* Illegal option? */
+		s = illegal;
+		retval = '?';
+		goto BAD;
+	}
+
+	if (s[1] == ':') {			/* Option takes an arg? */
+		if (o[1]) {					/* No space between option and arg? */
+			optarg = (char *)(o + 1);
+			goto NEXTOPT;
+		}
+
+		if (optind + 1 < argc) {	/* Space between option and arg? */
+			optarg = argv[++optind];
+		} else {				/* Out of args! */
+			s = missing;
+			retval = ':';
+		BAD:
+			optopt = *o;
+			if (*optstring != ':') {
+				retval = '?';
+				if (opterr) {
+#ifdef __BCC__
+					fprintf(stderr, "%s: %s -- %c\n", argv[0], s, *o);
+#else
+					fprintf(stderr, _(s), argv[0], *o);
+#endif
+				}
+			}
+		}
+	}
+
+#ifdef __BCC__
+#undef o
+#endif
+
+	if (!*++o) {
+	NEXTOPT:
+		o = NULL;
+		++optind;
+	}
+ DONE:
+	return retval;
+}
+libc_hidden_def(getopt)
diff --git a/ap/build/uClibc/libc/unistd/getopt.c b/ap/build/uClibc/libc/unistd/getopt.c
new file mode 100644
index 0000000..f4c1130
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getopt.c
@@ -0,0 +1,1198 @@
+/* Getopt for GNU.
+   NOTE: getopt is now part of the C library, so if you don't know what
+   "Keep this file name-space clean" means, talk to drepper@gnu.org
+   before changing it!
+   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004
+   	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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/*
+ * Modified for uClibc by Manuel Novoa III on 1/5/01.
+ * Modified once again for uClibc by Erik Andersen 8/7/02
+ */
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
+   Ditto for AIX 3.2 and <stdlib.h>.  */
+#ifndef _NO_PROTO
+# define _NO_PROTO
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define __FORCE_GLIBC
+#include <features.h>
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+   actually compiling the library itself.  This code is part of the GNU C
+   Library, but also included in many other GNU distributions.  Compiling
+   and linking in this code is a waste when using the GNU C library
+   (especially if it is a shared library).  Rather than having every GNU
+   program understand `configure --with-gnu-libc' and omit the object files,
+   it is simpler to just do this in the source for each such file.  */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+#  define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+   to get __GNU_LIBRARY__ defined.  */
+#ifdef	__GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+   contain conflicting prototypes for getopt.  */
+# include <stdlib.h>
+# include <unistd.h>
+#endif	/* GNU C library.  */
+
+#include <string.h>
+
+#ifdef VMS
+# include <unixlib.h>
+#endif
+
+#if !defined __UCLIBC__ && !defined __UCLIBC_HAS_GETTEXT_AWARENESS__
+#ifdef _LIBC
+# include <libintl.h>
+#else
+# include "gettext.h"
+# define _(msgid) gettext (msgid)
+#endif
+#else
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO: Enable gettext awareness.
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+#undef _
+#define _(X)	X
+
+#endif
+
+/* Treat '-W foo' the same as the long option '--foo',
+ * disabled for the moment since it costs about 2k... */
+#undef SPECIAL_TREATMENT_FOR_W
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+#endif
+
+#ifndef attribute_hidden
+# define attribute_hidden
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+   but it behaves differently for the user, since it allows the user
+   to intersperse the options with the other arguments.
+
+   As `getopt' works, it permutes the elements of ARGV so that,
+   when it is done, all the options precede everything else.  Thus
+   all application programs are extended to handle flexible argument order.
+
+   Setting the environment variable POSIXLY_CORRECT disables permutation.
+   Then the behavior is completely standard.
+
+   GNU application programs can use a third alternative mode in which
+   they can distinguish the relative order of options and other arguments.  */
+
+#include <getopt.h>
+#include "getopt_int.h"
+
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns -1, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+/* 1003.2 says this must be 1 before any call.  */
+int optind = 1;
+
+/* Callers store zero here to inhibit the error message
+   for unrecognized options.  */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+   This must be initialized on some systems to avoid linking in the
+   system's own getopt implementation.  */
+
+int optopt = '?';
+
+/* Keep a global copy of all internal members of getopt_data.  */
+
+static struct _getopt_data getopt_data;
+
+
+#ifndef __GNU_LIBRARY__
+
+/* Avoid depending on library functions or files
+   whose names are inconsistent.  */
+
+#ifndef getenv
+extern char *getenv ();
+#endif
+
+#endif /* not __GNU_LIBRARY__ */
+
+#ifdef _LIBC
+/* Stored original parameters.
+   XXX This is no good solution.  We should rather copy the args so
+   that we can compare them later.  But we must not use malloc(3).  */
+# ifdef USE_NONOPTION_FLAGS
+extern int __libc_argc;
+extern char **__libc_argv;
+
+/* Bash 2.0 gives us an environment variable containing flags
+   indicating ARGV elements that should not be considered arguments.  */
+
+/* Defined in getopt_init.c  */
+extern char *__getopt_nonoption_flags;
+
+#  define SWAP_FLAGS(ch1, ch2) \
+  if (d->__nonoption_flags_len > 0)					      \
+    {									      \
+      char __tmp = __getopt_nonoption_flags[ch1];			      \
+      __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];	      \
+      __getopt_nonoption_flags[ch2] = __tmp;				      \
+    }
+# else
+#  define SWAP_FLAGS(ch1, ch2)
+# endif
+#else	/* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif	/* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+   One subsequence is elements [first_nonopt,last_nonopt)
+   which contains all the non-options that have been skipped so far.
+   The other is elements [last_nonopt,optind), which contains all
+   the options processed since those non-options were skipped.
+
+   `first_nonopt' and `last_nonopt' are relocated so that they describe
+   the new indices of the non-options in ARGV after they are moved.  */
+
+static void
+exchange (char **argv, struct _getopt_data *d)
+{
+  int bottom = d->__first_nonopt;
+  int middle = d->__last_nonopt;
+  int top = d->optind;
+  char *tem;
+
+  /* Exchange the shorter segment with the far end of the longer segment.
+     That puts the shorter segment into the right place.
+     It leaves the longer segment in the right place overall,
+     but it consists of two parts that need to be swapped next.  */
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  /* First make sure the handling of the `__getopt_nonoption_flags'
+     string can work normally.  Our top argument must be in the range
+     of the string.  */
+  if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
+    {
+      /* We must extend the array.  The user plays games with us and
+	 presents new arguments.  */
+      char *new_str = malloc (top + 1);
+      if (new_str == NULL)
+	d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
+      else
+	{
+	  memset (__mempcpy (new_str, __getopt_nonoption_flags,
+			     d->__nonoption_flags_max_len),
+		  '\0', top + 1 - d->__nonoption_flags_max_len);
+	  d->__nonoption_flags_max_len = top + 1;
+	  __getopt_nonoption_flags = new_str;
+	}
+    }
+#endif
+
+  while (top > middle && middle > bottom)
+    {
+      if (top - middle > middle - bottom)
+	{
+	  /* Bottom segment is the short one.  */
+	  int len = middle - bottom;
+	  register int i;
+
+	  /* Swap it with the top part of the top segment.  */
+	  for (i = 0; i < len; i++)
+	    {
+	      tem = argv[bottom + i];
+	      argv[bottom + i] = argv[top - (middle - bottom) + i];
+	      argv[top - (middle - bottom) + i] = tem;
+	      SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+	    }
+	  /* Exclude the moved bottom segment from further swapping.  */
+	  top -= len;
+	}
+      else
+	{
+	  /* Top segment is the short one.  */
+	  int len = top - middle;
+	  register int i;
+
+	  /* Swap it with the bottom part of the bottom segment.  */
+	  for (i = 0; i < len; i++)
+	    {
+	      tem = argv[bottom + i];
+	      argv[bottom + i] = argv[middle + i];
+	      argv[middle + i] = tem;
+	      SWAP_FLAGS (bottom + i, middle + i);
+	    }
+	  /* Exclude the moved top segment from further swapping.  */
+	  bottom += len;
+	}
+    }
+
+  /* Update records for the slots the non-options now occupy.  */
+
+  d->__first_nonopt += (d->optind - d->__last_nonopt);
+  d->__last_nonopt = d->optind;
+}
+
+/* Initialize the internal data when the first call is made.  */
+
+static const char *
+_getopt_initialize (attribute_unused int argc, attribute_unused char *const *argv, const char *optstring,
+		    struct _getopt_data *d)
+{
+  /* Start processing options with ARGV-element 1 (since ARGV-element 0
+     is the program name); the sequence of previously skipped
+     non-option ARGV-elements is empty.  */
+
+  d->__first_nonopt = d->__last_nonopt = d->optind;
+
+  d->__nextchar = NULL;
+
+  d->__posixly_correct = !!getenv ("POSIXLY_CORRECT");
+
+  /* Determine how to handle the ordering of options and nonoptions.  */
+
+  if (optstring[0] == '-')
+    {
+      d->__ordering = RETURN_IN_ORDER;
+      ++optstring;
+    }
+  else if (optstring[0] == '+')
+    {
+      d->__ordering = REQUIRE_ORDER;
+      ++optstring;
+    }
+  else if (d->__posixly_correct)
+    d->__ordering = REQUIRE_ORDER;
+  else
+    d->__ordering = PERMUTE;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  if (!d->__posixly_correct
+      && argc == __libc_argc && argv == __libc_argv)
+    {
+      if (d->__nonoption_flags_max_len == 0)
+	{
+	  if (__getopt_nonoption_flags == NULL
+	      || __getopt_nonoption_flags[0] == '\0')
+	    d->__nonoption_flags_max_len = -1;
+	  else
+	    {
+	      const char *orig_str = __getopt_nonoption_flags;
+	      int len = d->__nonoption_flags_max_len = strlen (orig_str);
+	      if (d->__nonoption_flags_max_len < argc)
+		d->__nonoption_flags_max_len = argc;
+	      __getopt_nonoption_flags =
+		(char *) malloc (d->__nonoption_flags_max_len);
+	      if (__getopt_nonoption_flags == NULL)
+		d->__nonoption_flags_max_len = -1;
+	      else
+		memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+			'\0', d->__nonoption_flags_max_len - len);
+	    }
+	}
+      d->__nonoption_flags_len = d->__nonoption_flags_max_len;
+    }
+  else
+    d->__nonoption_flags_len = 0;
+#endif
+
+  return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+   given in OPTSTRING.
+
+   If an element of ARGV starts with '-', and is not exactly "-" or "--",
+   then it is an option element.  The characters of this element
+   (aside from the initial '-') are option characters.  If `getopt'
+   is called repeatedly, it returns successively each of the option characters
+   from each of the option elements.
+
+   If `getopt' finds another option character, it returns that character,
+   updating `optind' and `nextchar' so that the next call to `getopt' can
+   resume the scan with the following option character or ARGV-element.
+
+   If there are no more option characters, `getopt' returns -1.
+   Then `optind' is the index in ARGV of the first ARGV-element
+   that is not an option.  (The ARGV-elements have been permuted
+   so that those that are not options now come last.)
+
+   OPTSTRING is a string containing the legitimate option characters.
+   If an option character is seen that is not listed in OPTSTRING,
+   return '?' after printing an error message.  If you set `opterr' to
+   zero, the error message is suppressed but we still return '?'.
+
+   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+   so the following text in the same ARGV-element, or the text of the following
+   ARGV-element, is returned in `optarg'.  Two colons mean an option that
+   wants an optional arg; if there is text in the current ARGV-element,
+   it is returned in `optarg', otherwise `optarg' is set to zero.
+
+   If OPTSTRING starts with `-' or `+', it requests different methods of
+   handling the non-option ARGV-elements.
+   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+   Long-named options begin with `--' instead of `-'.
+   Their names may be abbreviated as long as the abbreviation is unique
+   or is an exact match for some defined option.  If they have an
+   argument, it follows the option name in the same ARGV-element, separated
+   from the option name by a `=', or else the in next ARGV-element.
+   When `getopt' finds a long-named option, it returns 0 if that option's
+   `flag' field is nonzero, the value of the option's `val' field
+   if the `flag' field is zero.
+
+   The elements of ARGV aren't really const, because we permute them.
+   But we pretend they're const in the prototype to be compatible
+   with other systems.
+
+   LONGOPTS is a vector of `struct option' terminated by an
+   element containing a name which is zero.
+
+   LONGIND returns the index in LONGOPT of the long-named option found.
+   It is only valid when a long-named option has been found by the most
+   recent call.
+
+   If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+   long-named options.  */
+
+static int
+_getopt_internal_r (int argc, char *const *argv, const char *optstring,
+		    const struct option *longopts, int *longind,
+		    int long_only, struct _getopt_data *d)
+{
+  int print_errors = d->opterr;
+  if (optstring[0] == ':')
+    print_errors = 0;
+
+  if (argc < 1)
+    return -1;
+
+  d->optarg = NULL;
+
+  if (d->optind == 0 || !d->__initialized)
+    {
+      if (d->optind == 0)
+	d->optind = 1;	/* Don't scan ARGV[0], the program name.  */
+      optstring = _getopt_initialize (argc, argv, optstring, d);
+      d->__initialized = 1;
+    }
+
+  /* Test whether ARGV[optind] points to a non-option argument.
+     Either it does not have option syntax, or there is an environment flag
+     from the shell indicating it is not an option.  The later information
+     is only used when the used in the GNU libc.  */
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
+		      || (d->optind < d->__nonoption_flags_len		      \
+			  && __getopt_nonoption_flags[d->optind] == '1'))
+#else
+# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
+#endif
+
+  if (d->__nextchar == NULL || *d->__nextchar == '\0')
+    {
+      /* Advance to the next ARGV-element.  */
+
+      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+	 moved back by the user (who may also have changed the arguments).  */
+      if (d->__last_nonopt > d->optind)
+	d->__last_nonopt = d->optind;
+      if (d->__first_nonopt > d->optind)
+	d->__first_nonopt = d->optind;
+
+      if (d->__ordering == PERMUTE)
+	{
+	  /* If we have just processed some options following some non-options,
+	     exchange them so that the options come first.  */
+
+	  if (d->__first_nonopt != d->__last_nonopt
+	      && d->__last_nonopt != d->optind)
+	    exchange ((char **) argv, d);
+	  else if (d->__last_nonopt != d->optind)
+	    d->__first_nonopt = d->optind;
+
+	  /* Skip any additional non-options
+	     and extend the range of non-options previously skipped.  */
+
+	  while (d->optind < argc && NONOPTION_P)
+	    d->optind++;
+	  d->__last_nonopt = d->optind;
+	}
+
+      /* The special ARGV-element `--' means premature end of options.
+	 Skip it like a null option,
+	 then exchange with previous non-options as if it were an option,
+	 then skip everything else like a non-option.  */
+
+      if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+	{
+	  d->optind++;
+
+	  if (d->__first_nonopt != d->__last_nonopt
+	      && d->__last_nonopt != d->optind)
+	    exchange ((char **) argv, d);
+	  else if (d->__first_nonopt == d->__last_nonopt)
+	    d->__first_nonopt = d->optind;
+	  d->__last_nonopt = argc;
+
+	  d->optind = argc;
+	}
+
+      /* If we have done all the ARGV-elements, stop the scan
+	 and back over any non-options that we skipped and permuted.  */
+
+      if (d->optind == argc)
+	{
+	  /* Set the next-arg-index to point at the non-options
+	     that we previously skipped, so the caller will digest them.  */
+	  if (d->__first_nonopt != d->__last_nonopt)
+	    d->optind = d->__first_nonopt;
+	  return -1;
+	}
+
+      /* If we have come to a non-option and did not permute it,
+	 either stop the scan or describe it to the caller and pass it by.  */
+
+      if (NONOPTION_P)
+	{
+	  if (d->__ordering == REQUIRE_ORDER)
+	    return -1;
+	  d->optarg = argv[d->optind++];
+	  return 1;
+	}
+
+      /* We have found another option-ARGV-element.
+	 Skip the initial punctuation.  */
+
+      d->__nextchar = (argv[d->optind] + 1
+		  + (longopts != NULL && argv[d->optind][1] == '-'));
+    }
+
+  /* Decode the current option-ARGV-element.  */
+
+  /* Check whether the ARGV-element is a long option.
+
+     If long_only and the ARGV-element has the form "-f", where f is
+     a valid short option, don't consider it an abbreviated form of
+     a long option that starts with f.  Otherwise there would be no
+     way to give the -f short option.
+
+     On the other hand, if there's a long option "fubar" and
+     the ARGV-element is "-fu", do consider that an abbreviation of
+     the long option, just like "--fu", and not "-f" with arg "u".
+
+     This distinction seems to be the most useful approach.  */
+
+  if (longopts != NULL
+      && (argv[d->optind][1] == '-'
+	  || (long_only && (argv[d->optind][2]
+			    || !strchr (optstring, argv[d->optind][1])))))
+    {
+      char *nameend;
+      const struct option *p;
+      const struct option *pfound = NULL;
+      int exact = 0;
+      int ambig = 0;
+      int indfound = -1;
+      int option_index;
+
+      for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
+	/* Do nothing.  */ ;
+
+      /* Test all long options for either exact match
+	 or abbreviated matches.  */
+      for (p = longopts, option_index = 0; p->name; p++, option_index++)
+	if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+	  {
+	    if ((unsigned int) (nameend - d->__nextchar)
+		== (unsigned int) strlen (p->name))
+	      {
+		/* Exact match found.  */
+		pfound = p;
+		indfound = option_index;
+		exact = 1;
+		break;
+	      }
+	    else if (pfound == NULL)
+	      {
+		/* First nonexact match found.  */
+		pfound = p;
+		indfound = option_index;
+	      }
+	    else if (long_only
+		     || pfound->has_arg != p->has_arg
+		     || pfound->flag != p->flag
+		     || pfound->val != p->val)
+	      /* Second or later nonexact match found.  */
+	      ambig = 1;
+	  }
+
+      if (ambig && !exact)
+	{
+	  if (print_errors)
+	    {
+#if defined _LIBC && defined USE_IN_LIBIO
+	      char *buf;
+
+	      if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
+			      argv[0], argv[d->optind]) >= 0)
+		{
+		  _IO_flockfile (stderr);
+
+		  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+		  __fxprintf (NULL, "%s", buf);
+
+		  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		  _IO_funlockfile (stderr);
+
+		  free (buf);
+		}
+#else
+	      fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
+		       argv[0], argv[d->optind]);
+#endif
+	    }
+	  d->__nextchar += strlen (d->__nextchar);
+	  d->optind++;
+	  d->optopt = 0;
+	  return '?';
+	}
+
+      if (pfound != NULL)
+	{
+	  option_index = indfound;
+	  d->optind++;
+	  if (*nameend)
+	    {
+	      /* Don't test has_arg with >, because some C compilers don't
+		 allow it to be used on enums.  */
+	      if (pfound->has_arg)
+		d->optarg = nameend + 1;
+	      else
+		{
+		  if (print_errors)
+		    {
+#if defined _LIBC && defined USE_IN_LIBIO
+		      char *buf;
+		      int n;
+#endif
+
+		      if (argv[d->optind - 1][1] == '-')
+			{
+			  /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+			  n = __asprintf (&buf, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+					  argv[0], pfound->name);
+#else
+			  fprintf (stderr, _("\
+%s: option `--%s' doesn't allow an argument\n"),
+				   argv[0], pfound->name);
+#endif
+			}
+		      else
+			{
+			  /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+			  n = __asprintf (&buf, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+					  argv[0], argv[d->optind - 1][0],
+					  pfound->name);
+#else
+			  fprintf (stderr, _("\
+%s: option `%c%s' doesn't allow an argument\n"),
+				   argv[0], argv[d->optind - 1][0],
+				   pfound->name);
+#endif
+			}
+
+#if defined _LIBC && defined USE_IN_LIBIO
+		      if (n >= 0)
+			{
+			  _IO_flockfile (stderr);
+
+			  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			  ((_IO_FILE *) stderr)->_flags2
+			    |= _IO_FLAGS2_NOTCANCEL;
+
+			  __fxprintf (NULL, "%s", buf);
+
+			  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			  _IO_funlockfile (stderr);
+
+			  free (buf);
+			}
+#endif
+		    }
+
+		  d->__nextchar += strlen (d->__nextchar);
+
+		  d->optopt = pfound->val;
+		  return '?';
+		}
+	    }
+	  else if (pfound->has_arg == 1)
+	    {
+	      if (d->optind < argc)
+		d->optarg = argv[d->optind++];
+	      else
+		{
+		  if (print_errors)
+		    {
+#if defined _LIBC && defined USE_IN_LIBIO
+		      char *buf;
+
+		      if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+				      argv[0], argv[d->optind - 1]) >= 0)
+			{
+			  _IO_flockfile (stderr);
+
+			  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			  ((_IO_FILE *) stderr)->_flags2
+			    |= _IO_FLAGS2_NOTCANCEL;
+
+			  __fxprintf (NULL, "%s", buf);
+
+			  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			  _IO_funlockfile (stderr);
+
+			  free (buf);
+			}
+#else
+		      fprintf (stderr,
+			       _("%s: option `%s' requires an argument\n"),
+			       argv[0], argv[d->optind - 1]);
+#endif
+		    }
+		  d->__nextchar += strlen (d->__nextchar);
+		  d->optopt = pfound->val;
+		  return optstring[0] == ':' ? ':' : '?';
+		}
+	    }
+	  d->__nextchar += strlen (d->__nextchar);
+	  if (longind != NULL)
+	    *longind = option_index;
+	  if (pfound->flag)
+	    {
+	      *(pfound->flag) = pfound->val;
+	      return 0;
+	    }
+	  return pfound->val;
+	}
+
+      /* Can't find it as a long option.  If this is not getopt_long_only,
+	 or the option starts with '--' or is not a valid short
+	 option, then it's an error.
+	 Otherwise interpret it as a short option.  */
+      if (!long_only || argv[d->optind][1] == '-'
+	  || strchr (optstring, *d->__nextchar) == NULL)
+	{
+	  if (print_errors)
+	    {
+#if defined _LIBC && defined USE_IN_LIBIO
+	      char *buf;
+	      int n;
+#endif
+
+	      if (argv[d->optind][1] == '-')
+		{
+		  /* --option */
+#if defined _LIBC && defined USE_IN_LIBIO
+		  n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
+				  argv[0], d->__nextchar);
+#else
+		  fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
+			   argv[0], d->__nextchar);
+#endif
+		}
+	      else
+		{
+		  /* +option or -option */
+#if defined _LIBC && defined USE_IN_LIBIO
+		  n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
+				  argv[0], argv[d->optind][0], d->__nextchar);
+#else
+		  fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
+			   argv[0], argv[d->optind][0], d->__nextchar);
+#endif
+		}
+
+#if defined _LIBC && defined USE_IN_LIBIO
+	      if (n >= 0)
+		{
+		  _IO_flockfile (stderr);
+
+		  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+		  __fxprintf (NULL, "%s", buf);
+
+		  ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		  _IO_funlockfile (stderr);
+
+		  free (buf);
+		}
+#endif
+	    }
+	  d->__nextchar = (char *) "";
+	  d->optind++;
+	  d->optopt = 0;
+	  return '?';
+	}
+    }
+
+  /* Look at and handle the next short option-character.  */
+
+  {
+    char c = *d->__nextchar++;
+    char *temp = strchr (optstring, c);
+
+    /* Increment `optind' when we start to process its last character.  */
+    if (*d->__nextchar == '\0')
+      ++d->optind;
+
+    if (temp == NULL || c == ':')
+      {
+	if (print_errors)
+	  {
+#if defined _LIBC && defined USE_IN_LIBIO
+	      char *buf;
+	      int n;
+#endif
+
+	    if (d->__posixly_correct)
+	      {
+		/* 1003.2 specifies the format of this message.  */
+#if defined _LIBC && defined USE_IN_LIBIO
+		n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
+				argv[0], c);
+#else
+		fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
+#endif
+	      }
+	    else
+	      {
+#if defined _LIBC && defined USE_IN_LIBIO
+		n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
+				argv[0], c);
+#else
+		fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
+#endif
+	      }
+
+#if defined _LIBC && defined USE_IN_LIBIO
+	    if (n >= 0)
+	      {
+		_IO_flockfile (stderr);
+
+		int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+		__fxprintf (NULL, "%s", buf);
+
+		((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		_IO_funlockfile (stderr);
+
+		free (buf);
+	      }
+#endif
+	  }
+	d->optopt = c;
+	return '?';
+      }
+#ifdef SPECIAL_TREATMENT_FOR_W
+    /* Convenience. Treat POSIX -W foo same as long option --foo */
+    if (temp[0] == 'W' && temp[1] == ';')
+      {
+	char *nameend;
+	const struct option *p;
+	const struct option *pfound = NULL;
+	int exact = 0;
+	int ambig = 0;
+	int indfound = 0;
+	int option_index;
+
+	/* This is an option that requires an argument.  */
+	if (*d->__nextchar != '\0')
+	  {
+	    d->optarg = d->__nextchar;
+	    /* If we end this ARGV-element by taking the rest as an arg,
+	       we must advance to the next element now.  */
+	    d->optind++;
+	  }
+	else if (d->optind == argc)
+	  {
+	    if (print_errors)
+	      {
+		/* 1003.2 specifies the format of this message.  */
+#if defined _LIBC && defined USE_IN_LIBIO
+		char *buf;
+
+		if (__asprintf (&buf,
+				_("%s: option requires an argument -- %c\n"),
+				argv[0], c) >= 0)
+		  {
+		    _IO_flockfile (stderr);
+
+		    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+		    __fxprintf (NULL, "%s", buf);
+
+		    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		    _IO_funlockfile (stderr);
+
+		    free (buf);
+		  }
+#else
+		fprintf (stderr, _("%s: option requires an argument -- %c\n"),
+			 argv[0], c);
+#endif
+	      }
+	    d->optopt = c;
+	    if (optstring[0] == ':')
+	      c = ':';
+	    else
+	      c = '?';
+	    return c;
+	  }
+	else
+	  /* We already incremented `d->optind' once;
+	     increment it again when taking next ARGV-elt as argument.  */
+	  d->optarg = argv[d->optind++];
+
+	/* optarg is now the argument, see if it's in the
+	   table of longopts.  */
+
+	for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
+	     nameend++)
+	  /* Do nothing.  */ ;
+
+	/* Test all long options for either exact match
+	   or abbreviated matches.  */
+	for (p = longopts, option_index = 0; p->name; p++, option_index++)
+	  if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
+	    {
+	      if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
+		{
+		  /* Exact match found.  */
+		  pfound = p;
+		  indfound = option_index;
+		  exact = 1;
+		  break;
+		}
+	      else if (pfound == NULL)
+		{
+		  /* First nonexact match found.  */
+		  pfound = p;
+		  indfound = option_index;
+		}
+	      else
+		/* Second or later nonexact match found.  */
+		ambig = 1;
+	    }
+	if (ambig && !exact)
+	  {
+	    if (print_errors)
+	      {
+#if defined _LIBC && defined USE_IN_LIBIO
+		char *buf;
+
+		if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
+				argv[0], argv[d->optind]) >= 0)
+		  {
+		    _IO_flockfile (stderr);
+
+		    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+		    ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+		    __fxprintf (NULL, "%s", buf);
+
+		    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+		    _IO_funlockfile (stderr);
+
+		    free (buf);
+		  }
+#else
+		fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
+			 argv[0], argv[d->optind]);
+#endif
+	      }
+	    d->__nextchar += strlen (d->__nextchar);
+	    d->optind++;
+	    return '?';
+	  }
+	if (pfound != NULL)
+	  {
+	    option_index = indfound;
+	    if (*nameend)
+	      {
+		/* Don't test has_arg with >, because some C compilers don't
+		   allow it to be used on enums.  */
+		if (pfound->has_arg)
+		  d->optarg = nameend + 1;
+		else
+		  {
+		    if (print_errors)
+		      {
+#if defined _LIBC && defined USE_IN_LIBIO
+			char *buf;
+
+			if (__asprintf (&buf, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+					argv[0], pfound->name) >= 0)
+			  {
+			    _IO_flockfile (stderr);
+
+			    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			    ((_IO_FILE *) stderr)->_flags2
+			      |= _IO_FLAGS2_NOTCANCEL;
+
+			    __fxprintf (NULL, "%s", buf);
+
+			    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			    _IO_funlockfile (stderr);
+
+			    free (buf);
+			  }
+#else
+			fprintf (stderr, _("\
+%s: option `-W %s' doesn't allow an argument\n"),
+				 argv[0], pfound->name);
+#endif
+		      }
+
+		    d->__nextchar += strlen (d->__nextchar);
+		    return '?';
+		  }
+	      }
+	    else if (pfound->has_arg == 1)
+	      {
+		if (d->optind < argc)
+		  d->optarg = argv[d->optind++];
+		else
+		  {
+		    if (print_errors)
+		      {
+#if defined _LIBC && defined USE_IN_LIBIO
+			char *buf;
+
+			if (__asprintf (&buf, _("\
+%s: option `%s' requires an argument\n"),
+					argv[0], argv[d->optind - 1]) >= 0)
+			  {
+			    _IO_flockfile (stderr);
+
+			    int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			    ((_IO_FILE *) stderr)->_flags2
+			      |= _IO_FLAGS2_NOTCANCEL;
+
+			    __fxprintf (NULL, "%s", buf);
+
+			    ((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			    _IO_funlockfile (stderr);
+
+			    free (buf);
+			  }
+#else
+			fprintf (stderr,
+				 _("%s: option `%s' requires an argument\n"),
+				 argv[0], argv[d->optind - 1]);
+#endif
+		      }
+		    d->__nextchar += strlen (d->__nextchar);
+		    return optstring[0] == ':' ? ':' : '?';
+		  }
+	      }
+	    d->__nextchar += strlen (d->__nextchar);
+	    if (longind != NULL)
+	      *longind = option_index;
+	    if (pfound->flag)
+	      {
+		*(pfound->flag) = pfound->val;
+		return 0;
+	      }
+	    return pfound->val;
+	  }
+	  d->__nextchar = NULL;
+	  return 'W';	/* Let the application handle it.   */
+      }
+#endif
+    if (temp[1] == ':')
+      {
+	if (temp[2] == ':')
+	  {
+	    /* This is an option that accepts an argument optionally.  */
+	    if (*d->__nextchar != '\0')
+	      {
+		d->optarg = d->__nextchar;
+		d->optind++;
+	      }
+	    else
+	      d->optarg = NULL;
+	    d->__nextchar = NULL;
+	  }
+	else
+	  {
+	    /* This is an option that requires an argument.  */
+	    if (*d->__nextchar != '\0')
+	      {
+		d->optarg = d->__nextchar;
+		/* If we end this ARGV-element by taking the rest as an arg,
+		   we must advance to the next element now.  */
+		d->optind++;
+	      }
+	    else if (d->optind == argc)
+	      {
+		if (print_errors)
+		  {
+		    /* 1003.2 specifies the format of this message.  */
+#if defined _LIBC && defined USE_IN_LIBIO
+		    char *buf;
+
+		    if (__asprintf (&buf, _("\
+%s: option requires an argument -- %c\n"),
+				    argv[0], c) >= 0)
+		      {
+			_IO_flockfile (stderr);
+
+			int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
+			((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+
+			__fxprintf (NULL, "%s", buf);
+
+			((_IO_FILE *) stderr)->_flags2 = old_flags2;
+			_IO_funlockfile (stderr);
+
+			free (buf);
+		      }
+#else
+		    fprintf (stderr,
+			     _("%s: option requires an argument -- %c\n"),
+			     argv[0], c);
+#endif
+		  }
+		d->optopt = c;
+		if (optstring[0] == ':')
+		  c = ':';
+		else
+		  c = '?';
+	      }
+	    else
+	      /* We already incremented `optind' once;
+		 increment it again when taking next ARGV-elt as argument.  */
+	      d->optarg = argv[d->optind++];
+	    d->__nextchar = NULL;
+	  }
+      }
+    return c;
+  }
+}
+
+int
+_getopt_internal (int argc, char *const *argv, const char *optstring,
+		  const struct option *longopts, int *longind, int long_only)
+{
+  int result;
+
+  getopt_data.optind = optind;
+  getopt_data.opterr = opterr;
+
+  result = _getopt_internal_r (argc, argv, optstring, longopts,
+			       longind, long_only, &getopt_data);
+
+  optind = getopt_data.optind;
+  optarg = getopt_data.optarg;
+  optopt = getopt_data.optopt;
+
+  return result;
+}
+
+int
+getopt (int argc, char *const *argv, const char *optstring)
+{
+  return _getopt_internal (argc, argv, optstring,
+			   (const struct option *) 0,
+			   (int *) 0,
+			   0);
+}
+libc_hidden_def(getopt)
+
+int
+getopt_long (int argc, char *const *argv, const char *options,
+	     const struct option *long_options, int *opt_index)
+{
+  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+   If an option that starts with '-' (not '--') doesn't match a long option,
+   but does match a short option, it is parsed as a short option
+   instead.  */
+
+int
+getopt_long_only (int argc, char *const *argv, const char *options,
+		  const struct option *long_options, int *opt_index)
+{
+  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+}
+
+#endif	/* Not ELIDE_CODE.  */
diff --git a/ap/build/uClibc/libc/unistd/getopt_int.h b/ap/build/uClibc/libc/unistd/getopt_int.h
new file mode 100644
index 0000000..a871785
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getopt_int.h
@@ -0,0 +1,134 @@
+/* Internal declarations for getopt.
+   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _GETOPT_INT_H
+#define _GETOPT_INT_H	1
+
+extern int _getopt_internal (int ___argc, char *const *___argv,
+			     const char *__shortopts,
+		             const struct option *__longopts, int *__longind,
+			     int __long_only) attribute_hidden;
+
+
+/* Reentrant versions which can handle parsing multiple argument
+   vectors at the same time.  */
+
+/* For __ordering member */
+enum {
+	REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+};
+
+/* Data type for reentrant functions.  */
+
+struct _getopt_data
+{
+  /* These have exactly the same meaning as the corresponding global
+     variables, except that they are used for the reentrant
+     versions of getopt.  */
+  int optind;
+  int opterr;
+  char *optarg;
+  smalluint optopt; /* we store characters here, a byte is enough */
+
+  /* Internal members.  */
+
+  /* True if the internal members have been initialized.  */
+  smallint __initialized;
+
+  /* Describe how to deal with options that follow non-option ARGV-elements.
+
+     If the caller did not specify anything,
+     the default is REQUIRE_ORDER if the environment variable
+     POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+     REQUIRE_ORDER means don't recognize them as options;
+     stop option processing when the first non-option is seen.
+     This is what Unix does.
+     This mode of operation is selected by either setting the environment
+     variable POSIXLY_CORRECT, or using `+' as the first character
+     of the list of option characters.
+
+     PERMUTE is the default.  We permute the contents of ARGV as we
+     scan, so that eventually all the non-options are at the end.
+     This allows options to be given in any order, even with programs
+     that were not written to expect this.
+
+     RETURN_IN_ORDER is an option available to programs that were
+     written to expect options and other ARGV-elements in any order
+     and that care about the ordering of the two.  We describe each
+     non-option ARGV-element as if it were the argument of an option
+     with character code 1.  Using `-' as the first character of the
+     list of option characters selects this mode of operation.
+
+     The special argument `--' forces an end of option-scanning regardless
+     of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+     `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+  smallint __ordering;
+
+  /* If the POSIXLY_CORRECT environment variable is set.  */
+  smallint __posixly_correct;
+
+  /* The next char to be scanned in the option-element
+     in which the last option character we returned was found.
+     This allows us to pick up the scan where we left off.
+
+     If this is zero, or a null string, it means resume the scan
+     by advancing to the next ARGV-element.  */
+  char *__nextchar;
+
+
+  /* Handle permutation of arguments.  */
+
+  /* Describe the part of ARGV that contains non-options that have
+     been skipped.  `first_nonopt' is the index in ARGV of the first
+     of them; `last_nonopt' is the index after the last of them.  */
+
+  int __first_nonopt;
+  int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+  int __nonoption_flags_max_len;
+  int __nonoption_flags_len;
+# endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+   default values and to clear the initialization flag.  */
+#define _GETOPT_DATA_INITIALIZER	{ 1, 1 }
+
+#if 0 /* first is static on uClibc, the others not used */
+extern int _getopt_internal_r (int ___argc, char *const *___argv,
+			       const char *__shortopts,
+			       const struct option *__longopts, int *__longind,
+			       int __long_only, struct _getopt_data *__data);
+
+extern int _getopt_long_r (int ___argc, char *const *___argv,
+			   const char *__shortopts,
+			   const struct option *__longopts, int *__longind,
+			   struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char *const *___argv,
+				const char *__shortopts,
+				const struct option *__longopts,
+				int *__longind,
+				struct _getopt_data *__data);
+#endif
+
+#endif /* getopt_int.h */
diff --git a/ap/build/uClibc/libc/unistd/getopt_long-simple.c b/ap/build/uClibc/libc/unistd/getopt_long-simple.c
new file mode 100644
index 0000000..47612df
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getopt_long-simple.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stddef.h>
+#include <getopt.h>
+#include <stdio.h>
+
+
+static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
+{
+	if (optind >= argc || !argv[optind] || argv[optind][0] != '-') return -1;
+	if ((longonly && argv[optind][1]) ||
+		(argv[optind][1] == '-' && argv[optind][2]))
+	{
+		int i;
+		for (i=0; longopts[i].name; i++) {
+			const char *name = longopts[i].name;
+			char *opt = argv[optind]+2;
+			while (*name && *name++ == *opt++);
+			if (*name || (*opt && *opt != '=')) continue;
+			if (*opt == '=') {
+				if (!longopts[i].has_arg) continue;
+				optarg = opt+1;
+			} else {
+				if (longopts[i].has_arg == required_argument) {
+					if (!(optarg = argv[++optind]))
+						return ':';
+				} else optarg = NULL;
+			}
+			optind++;
+			if (idx) *idx = i;
+			if (longopts[i].flag) {
+				*longopts[i].flag = longopts[i].val;
+				return 0;
+			}
+			return longopts[i].val;
+		}
+		if (argv[optind][1] == '-') {
+			optind++;
+			return '?';
+		}
+	}
+	return getopt(argc, argv, optstring);
+}
+
+int getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx)
+{
+	return __getopt_long(argc, argv, optstring, longopts, idx, 0);
+}
+
+int getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx)
+{
+	return __getopt_long(argc, argv, optstring, longopts, idx, 1);
+}
diff --git a/ap/build/uClibc/libc/unistd/getpass.c b/ap/build/uClibc/libc/unistd/getpass.c
new file mode 100644
index 0000000..c311a15
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getpass.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 1992-1999,2001,2003,2004,2005 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
+
+
+/* It is desirable to use this bit on systems that have it.
+   The only bit of terminal state we want to twiddle is echoing, which is
+   done in software; there is no need to change the state of the terminal
+   hardware.  */
+
+#ifndef TCSASOFT
+#define TCSASOFT 0
+#endif
+#define PWD_BUFFER_SIZE 256
+
+char * getpass (const char *prompt)
+{
+  FILE *in, *out;
+  struct termios s, t;
+  int tty_changed;
+  static char buf[PWD_BUFFER_SIZE];
+  int nread;
+
+  /* Try to write to and read from the terminal if we can.
+     If we can't open the terminal, use stderr and stdin.  */
+
+  out = in = fopen ("/dev/tty", "r+");
+  if (in == NULL)
+    {
+      in = stdin;
+      out = stderr;
+    }
+  else
+    {
+      /* Disable buffering for read/write FILE to prevent problems with
+       * fseek and buffering for read/write auto-transitioning. */
+      setvbuf(in, NULL, _IONBF, 0);
+    }
+
+  /* Turn echoing off if it is on now.  */
+
+  tty_changed = 0;
+  if (tcgetattr (fileno (in), &t) == 0)
+    {
+      /* Save the old one. */
+      s = t;
+      /* Tricky, tricky. */
+      t.c_lflag &= ~(ECHO|ISIG);
+      tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0);
+    }
+
+  /* Write the prompt.  */
+  fputs(prompt, out);
+  fflush(out);
+
+  /* Read the password.  */
+  if (!fgets (buf, sizeof(buf), in))
+    buf[0] = '\0';
+  nread = strlen(buf);
+  if (nread > 0 && buf[nread - 1] == '\n')
+      /* Remove the newline.  */
+      buf[nread - 1] = '\0';
+
+  if (tty_changed)
+    {
+      /* Write the newline that was not echoed.  */
+      putc('\n', out);
+      /* Restore the original setting.  */
+      (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
+    }
+
+  if (in != stdin)
+    /* We opened the terminal; now close it.  */
+    fclose (in);
+
+  return buf;
+}
+#endif
diff --git a/ap/build/uClibc/libc/unistd/getsubopt-susv3.c b/ap/build/uClibc/libc/unistd/getsubopt-susv3.c
new file mode 100644
index 0000000..9ff33ef
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getsubopt-susv3.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+
+int getsubopt(char **opt, char *const *keys, char **val)
+{
+	char *s = *opt;
+	int i;
+
+	*val = NULL;
+	*opt = strchr(s, ',');
+	if (*opt) *(*opt)++ = 0;
+	else *opt = s + strlen(s);
+
+	for (i=0; keys[i]; i++) {
+		size_t l = strlen(keys[i]);
+		if (strncmp(keys[i], s, l)) continue;
+		if (s[l] == '=')
+			*val = s + l;
+		else if (s[l]) continue;
+		return i;
+	}
+	return -1;
+}
diff --git a/ap/build/uClibc/libc/unistd/getsubopt.c b/ap/build/uClibc/libc/unistd/getsubopt.c
new file mode 100644
index 0000000..4ff615b
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/getsubopt.c
@@ -0,0 +1,72 @@
+/* Parse comma separate list into words.
+   Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Parse comma separated suboption from *OPTIONP and match against
+   strings in TOKENS.  If found return index and set *VALUEP to
+   optional value introduced by an equal sign.  If the suboption is
+   not part of TOKENS return in *VALUEP beginning of unknown
+   suboption.  On exit *OPTIONP is set to the beginning of the next
+   token or at the terminating NUL character.  */
+int
+getsubopt (char **optionp, char *const *tokens, char **valuep)
+{
+  char *endp, *vstart;
+  int cnt;
+
+  if (**optionp == '\0')
+    return -1;
+
+  /* Find end of next token.  */
+  endp = strchrnul (*optionp, ',');
+
+  /* Find start of value.  */
+  vstart = memchr (*optionp, '=', endp - *optionp);
+  if (vstart == NULL)
+    vstart = endp;
+
+  /* Try to match the characters between *OPTIONP and VSTART against
+     one of the TOKENS.  */
+  for (cnt = 0; tokens[cnt] != NULL; ++cnt)
+    if (strncmp (*optionp, tokens[cnt], vstart - *optionp) == 0
+	&& tokens[cnt][vstart - *optionp] == '\0')
+      {
+	/* We found the current option in TOKENS.  */
+	*valuep = vstart != endp ? vstart + 1 : NULL;
+
+	if (*endp != '\0')
+	  *endp++ = '\0';
+	*optionp = endp;
+
+	return cnt;
+      }
+
+  /* The current suboption does not match any option.  */
+  *valuep = *optionp;
+
+  if (*endp != '\0')
+    *endp++ = '\0';
+  *optionp = endp;
+
+  return -1;
+}
diff --git a/ap/build/uClibc/libc/unistd/pathconf.c b/ap/build/uClibc/libc/unistd/pathconf.c
new file mode 100644
index 0000000..84f20ed
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/pathconf.c
@@ -0,0 +1,199 @@
+/* Copyright (C) 1991,1995,1996,1998,2000,2001,2003
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* pathconf -- adjusted for busybox */
+
+/* It would be great it this could be implemented using fpathconf,
+ * but that doesn't work out very well (think FIFOs and sockets) */
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+
+extern __typeof(statfs) __libc_statfs;
+
+
+/* The Linux kernel headers mention this as a kind of generic value. */
+#ifndef LINK_MAX
+# define LINK_MAX 127
+#endif
+
+/* Get file-specific information about PATH.  */
+long int
+pathconf (const char *path, int name)
+{
+  if (path[0] == '\0')
+    {
+      __set_errno (ENOENT);
+      return -1;
+    }
+
+  switch (name)
+    {
+    default:
+      __set_errno (EINVAL);
+      return -1;
+
+    case _PC_LINK_MAX:
+#ifdef	LINK_MAX
+      return LINK_MAX;
+#else
+      return -1;
+#endif
+
+    case _PC_MAX_CANON:
+#ifdef	MAX_CANON
+      return MAX_CANON;
+#else
+      return -1;
+#endif
+
+    case _PC_MAX_INPUT:
+#ifdef	MAX_INPUT
+      return MAX_INPUT;
+#else
+      return -1;
+#endif
+
+    case _PC_NAME_MAX:
+#ifdef	NAME_MAX
+      {
+	struct statfs buf;
+	int save_errno = errno;
+
+	if (__libc_statfs (path, &buf) < 0)
+	  {
+	    if (errno == ENOSYS)
+	      {
+		errno = save_errno;
+		return NAME_MAX;
+	      }
+	    return -1;
+	  }
+	else
+	  {
+#ifdef _STATFS_F_NAMELEN
+	    return buf.f_namelen;
+#else
+# ifdef _STATFS_F_NAME_MAX
+	    return buf.f_name_max;
+# else
+	    return NAME_MAX;
+# endif
+#endif
+	  }
+      }
+#else
+      return -1;
+#endif
+
+    case _PC_PATH_MAX:
+#ifdef	PATH_MAX
+      return PATH_MAX;
+#else
+      return -1;
+#endif
+
+    case _PC_PIPE_BUF:
+#ifdef	PIPE_BUF
+      return PIPE_BUF;
+#else
+      return -1;
+#endif
+
+    case _PC_CHOWN_RESTRICTED:
+#ifdef	_POSIX_CHOWN_RESTRICTED
+      return _POSIX_CHOWN_RESTRICTED;
+#else
+      return -1;
+#endif
+
+    case _PC_NO_TRUNC:
+#ifdef	_POSIX_NO_TRUNC
+      return _POSIX_NO_TRUNC;
+#else
+      return -1;
+#endif
+
+    case _PC_VDISABLE:
+#ifdef	_POSIX_VDISABLE
+      return _POSIX_VDISABLE;
+#else
+      return -1;
+#endif
+
+    case _PC_SYNC_IO:
+#ifdef	_POSIX_SYNC_IO
+      return _POSIX_SYNC_IO;
+#else
+      return -1;
+#endif
+
+    case _PC_ASYNC_IO:
+#if defined _POSIX_ASYNC_IO && defined __UCLIBC_HAS_LFS__
+      {
+	/* AIO is only allowed on regular files and block devices.  */
+	struct stat st;
+
+	if (stat (path, &st) < 0
+	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
+	  return -1;
+	else
+	  return 1;
+      }
+#else
+      return -1;
+#endif
+
+    case _PC_PRIO_IO:
+#ifdef	_POSIX_PRIO_IO
+      return _POSIX_PRIO_IO;
+#else
+      return -1;
+#endif
+
+    case _PC_SOCK_MAXBUF:
+#ifdef	SOCK_MAXBUF
+      return SOCK_MAXBUF;
+#else
+      return -1;
+#endif
+
+    case _PC_FILESIZEBITS:
+#ifdef FILESIZEBITS
+      return FILESIZEBITS;
+#else
+      /* We let platforms with larger file sizes overwrite this value.  */
+      return 32;
+#endif
+
+        /* Be lazy -- skip these */
+    case _PC_REC_INCR_XFER_SIZE:
+    case _PC_REC_MAX_XFER_SIZE:
+    case _PC_REC_MIN_XFER_SIZE:
+    case _PC_REC_XFER_ALIGN:
+    case _PC_ALLOC_SIZE_MIN:
+    case _PC_SYMLINK_MAX:
+      return -1;
+    }
+}
diff --git a/ap/build/uClibc/libc/unistd/sleep.c b/ap/build/uClibc/libc/unistd/sleep.c
new file mode 100644
index 0000000..9db115a
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/sleep.c
@@ -0,0 +1,193 @@
+/* Implementation of the POSIX sleep function using nanosleep.
+   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   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.  */
+
+#include <errno.h>
+#include <time.h>
+#include <signal.h>
+#include <unistd.h>
+
+
+/* version perusing nanosleep */
+#if defined __UCLIBC_HAS_REALTIME__
+
+/* I am unable to reproduce alleged "Linux quirk".
+ * I used the following test program:
+#include <unistd.h>
+#include <time.h>
+#include <signal.h>
+static void dummy(int sig) {}
+int main() {
+    struct timespec t = { 2, 0 };
+    if (fork() == 0) {
+	sleep(1);
+	return 0;
+    }
+    signal(SIGCHLD, SIG_DFL); //
+    signal(SIGCHLD, dummy);   // Pick one
+    signal(SIGCHLD, SIG_IGN); //
+    nanosleep(&t, &t);
+    return 0;
+}
+ * Testing on 2.4.20 and on 2.6.35-rc4:
+ * With SIG_DFL, nanosleep is not interrupted by SIGCHLD. Ok.
+ * With dummy handler, nanosleep is interrupted by SIGCHLD. Ok.
+ * With SIG_IGN, nanosleep is NOT interrupted by SIGCHLD.
+ * It looks like sleep's workaround for SIG_IGN is no longer needed?
+ * The only emails I can find are from 1998 (!):
+ * ----------
+ *  Subject: Re: sleep ignore sigchld
+ *  From: Linus Torvalds <torvalds@transmeta.com>
+ *  Date: Mon, 16 Nov 1998 11:02:15 -0800 (PST)
+ *
+ *  On Mon, 16 Nov 1998, H. J. Lu wrote:
+ *  > That is a kernel bug. SIGCHLD is a special one. Usually it cannot
+ *  > be ignored. [snip...]
+ *
+ *  No can do.
+ *
+ *  "nanosleep()" is implemented in a bad way that makes it impossible to
+ *  restart it cleanly. It was done that way because glibc wanted it that way,
+ *  not because it's a good idea. [snip...]
+ * ----------
+ * I assume that in the passed twelve+ years, nanosleep got fixed,
+ * but the hack in sleep to work around broken nanosleep was never removed.
+ */
+
+# if 0
+
+/* This is a quick and dirty, but not 100% compliant with
+ * the stupid SysV SIGCHLD vs. SIG_IGN behaviour.  It is
+ * fine unless you are messing with SIGCHLD...  */
+unsigned int sleep (unsigned int sec)
+{
+	unsigned int res;
+	struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
+	res = nanosleep(&ts, &ts);
+	if (res) res = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
+	return res;
+}
+
+# else
+
+/* We are going to use the `nanosleep' syscall of the kernel.  But the
+   kernel does not implement the sstupid SysV SIGCHLD vs. SIG_IGN
+   behaviour for this syscall.  Therefore we have to emulate it here.  */
+unsigned int sleep (unsigned int seconds)
+{
+    struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
+    sigset_t set;
+    struct sigaction oact;
+    unsigned int result;
+
+    /* This is not necessary but some buggy programs depend on this.  */
+    if (seconds == 0) {
+#  ifdef CANCELLATION_P
+	CANCELLATION_P (THREAD_SELF);
+#  endif
+	return 0;
+    }
+
+    /* Linux will wake up the system call, nanosleep, when SIGCHLD
+       arrives even if SIGCHLD is ignored.  We have to deal with it
+       in libc.  */
+
+    __sigemptyset (&set);
+    __sigaddset (&set, SIGCHLD);
+
+    /* Is SIGCHLD set to SIG_IGN? */
+    sigaction (SIGCHLD, NULL, &oact); /* never fails */
+    if (oact.sa_handler == SIG_IGN) {
+	/* Yes.  Block SIGCHLD, save old mask.  */
+	sigprocmask (SIG_BLOCK, &set, &set); /* never fails */
+    }
+
+    /* Run nanosleep, with SIGCHLD blocked if SIGCHLD is SIG_IGNed.  */
+    result = nanosleep (&ts, &ts);
+    if (result != 0) {
+	/* Got EINTR. Return remaining time.  */
+	result = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
+    }
+
+    if (!__sigismember (&set, SIGCHLD)) {
+	/* We did block SIGCHLD, and old mask had no SIGCHLD bit.
+	   IOW: we need to unblock SIGCHLD now. Do it.  */
+	/* this sigprocmask call never fails, thus never updates errno,
+	   and therefore we don't need to save/restore it.  */
+	sigprocmask (SIG_SETMASK, &set, NULL); /* never fails */
+    }
+
+    return result;
+}
+
+# endif
+
+#else /* __UCLIBC_HAS_REALTIME__ */
+
+/* no nanosleep, use signals and alarm() */
+static void sleep_alarm_handler(int attribute_unused sig)
+{
+}
+unsigned int sleep (unsigned int seconds)
+{
+    struct sigaction act, oact;
+    sigset_t set, oset;
+    unsigned int result, remaining;
+    time_t before, after;
+    int old_errno = errno;
+
+    /* This is not necessary but some buggy programs depend on this.  */
+    if (seconds == 0)
+	return 0;
+
+    /* block SIGALRM */
+    __sigemptyset (&set);
+    __sigaddset (&set, SIGALRM);
+    sigprocmask (SIG_BLOCK, &set, &oset); /* can't fail */
+
+    act.sa_handler = sleep_alarm_handler;
+    act.sa_flags = 0;
+    act.sa_mask = oset;
+    sigaction(SIGALRM, &act, &oact); /* never fails */
+
+    before = time(NULL);
+    remaining = alarm(seconds);
+    if (remaining && remaining > seconds) {
+	/* restore user's alarm */
+	sigaction(SIGALRM, &oact, NULL);
+	alarm(remaining); /* restore old alarm */
+	sigsuspend(&oset);
+	after = time(NULL);
+    } else {
+	sigsuspend (&oset);
+	after = time(NULL);
+	sigaction (SIGALRM, &oact, NULL);
+    }
+    result = after - before;
+    alarm(remaining > result ? remaining - result : 0);
+    sigprocmask (SIG_SETMASK, &oset, NULL);
+
+    __set_errno(old_errno);
+
+    return result > seconds ? 0 : seconds - result;
+}
+
+#endif /* __UCLIBC_HAS_REALTIME__ */
+
+libc_hidden_def(sleep)
diff --git a/ap/build/uClibc/libc/unistd/swab.c b/ap/build/uClibc/libc/unistd/swab.c
new file mode 100644
index 0000000..70ea464
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/swab.c
@@ -0,0 +1,23 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <byteswap.h>
+
+/* Updated implementation based on byteswap.h from Miles Bader
+ * <miles@gnu.org>.  This should be much faster on arches with machine
+ * specific, optimized definitions in include/bits/byteswap.h (i.e. on
+ * x86, use the bswap instruction on i486 and better boxes).  For
+ * platforms that lack such support, this should be no slower than it
+ * was before... */
+void swab (const void *source, void *dest, ssize_t count)
+{
+    const unsigned short *from = source, *from_end = from + (count >> 1);
+    unsigned short junk;
+    unsigned short *to = dest;
+
+    while (from < from_end) {
+	/* Don't put '*from++'into the bswap_16() macros
+	 * or mad things will happen on macro expansion */
+	junk=*from++;
+	*to++ = bswap_16 (junk);
+    }
+}
diff --git a/ap/build/uClibc/libc/unistd/sysconf.c b/ap/build/uClibc/libc/unistd/sysconf.c
new file mode 100644
index 0000000..c049dc9
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/sysconf.c
@@ -0,0 +1,1011 @@
+/* Copyright (C) 1991,1993,1995-1997,2000
+   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.  */
+
+#define _XOPEN_SOURCE  500
+#include <features.h>
+#include <errno.h>
+#include <limits.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/sysinfo.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#ifdef __UCLIBC_HAS_REGEX__
+#include <regex.h>
+#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep.h>
+#endif
+#include <sys/resource.h>
+#include <string.h>
+#include <dirent.h>
+#include "internal/parse_config.h"
+
+static int nprocessors_onln(void)
+{
+	char **l = NULL;
+	parser_t *p = config_open("/proc/stat");
+	int ret = 0;
+
+	if (p) {
+		while (config_read(p, &l, 2, 1, " ", 0))
+			if (l[0][0] == 'c'
+				&& l[0][1] == 'p'
+				&& l[0][2] == 'u'
+				&& isdigit(l[0][3]))
+				++ret;
+	} else if ((p = config_open("/proc/cpuinfo"))) {
+#if defined __sparc__
+		while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+			if (strncmp("ncpus active", l[0], 12) == 0) {
+				ret = atoi(l[1]);
+				break;
+			}
+#else
+		while (config_read(p, &l, 2, 2, "\0:\t", PARSE_NORMAL))
+			if (strcmp("processor", l[0]) == 0)
+				++ret;
+#endif
+	}
+	config_close(p);
+	return ret != 0 ? ret : 1;
+}
+
+#if defined __UCLIBC__ && !defined __UCLIBC_HAS_LFS__
+# define readdir64 readdir
+# define dirent64 dirent
+#endif
+static int nprocessors_conf(void)
+{
+	int ret = 0;
+	DIR *dir = opendir("/sys/devices/system/cpu");
+
+	if (dir) {
+		struct dirent64 *dp;
+
+		while ((dp = readdir64(dir))) {
+			if (dp->d_type == DT_DIR
+				&& dp->d_name[0] == 'c'
+				&& dp->d_name[1] == 'p'
+				&& dp->d_name[2] == 'u'
+				&& isdigit(dp->d_name[3]))
+				++ret;
+		}
+		closedir(dir);
+	} else
+	{
+#if defined __sparc__
+		char **l = NULL;
+		parser_t *p = config_open("/proc/stat");
+		while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+			if (strncmp("ncpus probed", l[0], 13) == 0) {
+				ret = atoi(l[1]);
+				break;
+			}
+		config_close(p);
+#else
+		ret = nprocessors_onln();
+#endif
+	}
+	return ret != 0 ? ret : 1;
+}
+
+
+#ifndef __UCLIBC_CLK_TCK_CONST
+#error __UCLIBC_CLK_TCK_CONST not defined!
+#endif
+
+/***********************************************************************/
+/*
+ * Manuel Novoa III        Jan 2001
+ *
+ * On i386, the switch-based implementation generates 796 bytes of code.
+ * However, many of the return values are repeats.  By collecting these
+ * repeats and moving to a table-based implementation, we generate 283
+ * bytes on i386 (-Os -fomit-frame-pointer).
+ */
+
+#ifdef _UCLIBC_GENERATE_SYSCONF_ARCH
+/*
+ * Set some errno's so the auto-gen code knows what it is dealing with.
+ *    1) ENOSYS signifies that we're returning a default value.
+ *       This is just extra info for development.
+ *    2) EISNAM signifies that the value returned varies at runtime.
+ *
+ * Option: GETPAGESIZE_IS_DYNAMIC
+ *    The current implementation of getpagesize in uClibc returns
+ *    a constant.  The pagesize on the target arch should not vary,
+ *    so it should be safe to set this as 0.
+ */
+#define RETURN_NEG_1 __set_errno(ENOSYS); return -1
+#define RETURN_FUNCTION(f) __set_errno(EISNAM); return (long int) #f
+#define GETPAGESIZE_IS_DYNAMIC 0
+#else
+#define RETURN_NEG_1 return -1
+#define RETURN_FUNCTION(f) return f;
+#endif /* _UCLIBC_GENERATE_SYSCONF_ARCH */
+
+/* Legacy value of ARG_MAX.  The macro is now not defined since the
+   actual value varies based on the stack size.  */
+#define legacy_ARG_MAX 131072
+
+/* Get the value of the system variable NAME.  */
+long int sysconf(int name)
+{
+  struct rlimit rlimit;
+
+  switch (name)
+    {
+    default:
+      __set_errno(EINVAL);
+      return -1;
+
+    case _SC_ARG_MAX:
+      /* Use getrlimit to get the stack limit.  */
+      if (getrlimit (RLIMIT_STACK, &rlimit) == 0)
+          return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4);
+#if defined ARG_MAX
+      return ARG_MAX;
+#else
+      return legacy_ARG_MAX;
+#endif
+
+    case _SC_CHILD_MAX:
+#ifdef	CHILD_MAX
+      return CHILD_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_CLK_TCK:
+      /* Can't use CLK_TCK here since that calls __sysconf(_SC_CLK_TCK) */
+      return __UCLIBC_CLK_TCK_CONST;
+
+    case _SC_NGROUPS_MAX:
+#ifdef	NGROUPS_MAX
+      return NGROUPS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_OPEN_MAX:
+      RETURN_FUNCTION(getdtablesize());
+
+    case _SC_STREAM_MAX:
+#ifdef	STREAM_MAX
+      return STREAM_MAX;
+#else
+      return FOPEN_MAX;
+#endif
+
+    case _SC_TZNAME_MAX:
+      return _POSIX_TZNAME_MAX;
+
+    case _SC_JOB_CONTROL:
+#ifdef	_POSIX_JOB_CONTROL
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SAVED_IDS:
+#ifdef	_POSIX_SAVED_IDS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_REALTIME_SIGNALS:
+#ifdef	_POSIX_REALTIME_SIGNALS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PRIORITY_SCHEDULING:
+#ifdef	_POSIX_PRIORITY_SCHEDULING
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_TIMERS:
+#ifdef	_POSIX_TIMERS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_ASYNCHRONOUS_IO:
+#ifdef	_POSIX_ASYNCHRONOUS_IO
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PRIORITIZED_IO:
+#ifdef	_POSIX_PRIORITIZED_IO
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SYNCHRONIZED_IO:
+#ifdef	_POSIX_SYNCHRONIZED_IO
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_FSYNC:
+#ifdef	_POSIX_FSYNC
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MAPPED_FILES:
+#ifdef	_POSIX_MAPPED_FILES
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MEMLOCK:
+#ifdef	_POSIX_MEMLOCK
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MEMLOCK_RANGE:
+#ifdef	_POSIX_MEMLOCK_RANGE
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MEMORY_PROTECTION:
+#ifdef	_POSIX_MEMORY_PROTECTION
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MESSAGE_PASSING:
+#ifdef	_POSIX_MESSAGE_PASSING
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SEMAPHORES:
+#ifdef	_POSIX_SEMAPHORES
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SHARED_MEMORY_OBJECTS:
+#ifdef	_POSIX_SHARED_MEMORY_OBJECTS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_VERSION:
+      return _POSIX_VERSION;
+
+    case _SC_PAGESIZE:
+#if defined(GETPAGESIZE_IS_DYNAMIC) && (GETPAGESIZE_IS_DYNAMIC == 1)
+      RETURN_FUNCTION(getpagesize());
+#else
+      return getpagesize();		/* note: currently this is not dynamic */
+#endif
+
+    case _SC_AIO_LISTIO_MAX:
+#ifdef	AIO_LISTIO_MAX
+      return AIO_LISTIO_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_AIO_MAX:
+#ifdef	AIO_MAX
+      return AIO_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_AIO_PRIO_DELTA_MAX:
+#ifdef	AIO_PRIO_DELTA_MAX
+      return AIO_PRIO_DELTA_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_DELAYTIMER_MAX:
+#ifdef	DELAYTIMER_MAX
+      return DELAYTIMER_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MQ_OPEN_MAX:
+#ifdef	MQ_OPEN_MAX
+      return MQ_OPEN_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MQ_PRIO_MAX:
+#ifdef	MQ_PRIO_MAX
+      return MQ_PRIO_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_RTSIG_MAX:
+#ifdef	RTSIG_MAX
+      return RTSIG_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SEM_NSEMS_MAX:
+#ifdef	SEM_NSEMS_MAX
+      return SEM_NSEMS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SEM_VALUE_MAX:
+#ifdef	SEM_VALUE_MAX
+      return SEM_VALUE_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SIGQUEUE_MAX:
+#ifdef	SIGQUEUE_MAX
+      return SIGQUEUE_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_TIMER_MAX:
+#ifdef	TIMER_MAX
+      return TIMER_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_BC_BASE_MAX:
+#ifdef	BC_BASE_MAX
+      return BC_BASE_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_BC_DIM_MAX:
+#ifdef	BC_DIM_MAX
+      return BC_DIM_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_BC_SCALE_MAX:
+#ifdef	BC_SCALE_MAX
+      return BC_SCALE_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_BC_STRING_MAX:
+#ifdef	BC_STRING_MAX
+      return BC_STRING_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_COLL_WEIGHTS_MAX:
+#ifdef	COLL_WEIGHTS_MAX
+      return COLL_WEIGHTS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_EQUIV_CLASS_MAX:
+#ifdef	EQUIV_CLASS_MAX
+      return EQUIV_CLASS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_EXPR_NEST_MAX:
+#ifdef	EXPR_NEST_MAX
+      return EXPR_NEST_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_LINE_MAX:
+#ifdef	LINE_MAX
+      return LINE_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_RE_DUP_MAX:
+#ifdef	RE_DUP_MAX
+      return RE_DUP_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_CHARCLASS_NAME_MAX:
+#ifdef	CHARCLASS_NAME_MAX
+      return CHARCLASS_NAME_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII:
+#ifdef	_POSIX_PII
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_XTI:
+#ifdef	_POSIX_PII_XTI
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_SOCKET:
+#ifdef	_POSIX_PII_SOCKET
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_INTERNET:
+#ifdef	_POSIX_PII_INTERNET
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_OSI:
+#ifdef	_POSIX_PII_OSI
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_POLL:
+#ifdef	_POSIX_POLL
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_SELECT:
+#ifdef	_POSIX_SELECT
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_UIO_MAXIOV:
+#ifdef	UIO_MAXIOV
+      return UIO_MAXIOV;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_INTERNET_STREAM:
+#ifdef	_POSIX_PII_INTERNET_STREAM
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_INTERNET_DGRAM:
+#ifdef	_POSIX_PII_INTERNET_DGRAM
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_OSI_COTS:
+#ifdef	_POSIX_PII_OSI_COTS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_OSI_CLTS:
+#ifdef	_POSIX_PII_OSI_CLTS
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_PII_OSI_M:
+#ifdef	_POSIX_PII_OSI_M
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_T_IOV_MAX:
+#ifdef	_T_IOV_MAX
+      return _T_IOV_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_VERSION:
+      return _POSIX2_VERSION;
+
+    case _SC_2_C_BIND:
+#ifdef	_POSIX2_C_BIND
+      return _POSIX2_C_BIND;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_C_DEV:
+#ifdef	_POSIX2_C_DEV
+      return _POSIX2_C_DEV;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_C_VERSION:
+#ifdef	_POSIX2_C_VERSION
+      return _POSIX2_C_VERSION;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_FORT_DEV:
+#ifdef	_POSIX2_FORT_DEV
+      return _POSIX2_FORT_DEV;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_FORT_RUN:
+#ifdef	_POSIX2_FORT_RUN
+      return _POSIX2_FORT_RUN;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_LOCALEDEF:
+#ifdef	_POSIX2_LOCALEDEF
+      return _POSIX2_LOCALEDEF;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_SW_DEV:
+#ifdef	_POSIX2_SW_DEV
+      return _POSIX2_SW_DEV;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_CHAR_TERM:
+#ifdef	_POSIX2_CHAR_TERM
+      return _POSIX2_CHAR_TERM;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_2_UPE:
+#ifdef	_POSIX2_UPE
+      return _POSIX2_UPE;
+#else
+      RETURN_NEG_1;
+#endif
+
+      /* POSIX 1003.1c (POSIX Threads).  */
+    case _SC_THREADS:
+#ifdef __UCLIBC_HAS_THREADS__
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_SAFE_FUNCTIONS:
+#ifdef __UCLIBC_HAS_THREADS__
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+/* If you change these, also change libc/pwd_grp/pwd_grp.c to match */
+    case _SC_GETGR_R_SIZE_MAX:
+      return __UCLIBC_GRP_BUFFER_SIZE__;
+
+    case _SC_GETPW_R_SIZE_MAX:
+      return __UCLIBC_PWD_BUFFER_SIZE__;
+
+/* getlogin() is a worthless interface.  In uClibc we let the user specify
+ * whatever they want via the LOGNAME environment variable, or we return NULL
+ * if getenv() fails to find anything.  So this is merely how large a env
+ * variable can be.  Lets use 256 */
+    case _SC_LOGIN_NAME_MAX:
+      return 256;
+
+/* If you change this, also change _SC_TTY_NAME_MAX in libc/unistd/sysconf.c */
+#define TTYNAME_BUFLEN		32
+    case _SC_TTY_NAME_MAX:
+      return TTYNAME_BUFLEN;
+
+    case _SC_THREAD_DESTRUCTOR_ITERATIONS:
+#ifdef	_POSIX_THREAD_DESTRUCTOR_ITERATIONS
+      return _POSIX_THREAD_DESTRUCTOR_ITERATIONS;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_KEYS_MAX:
+#ifdef	PTHREAD_KEYS_MAX
+      return PTHREAD_KEYS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_STACK_MIN:
+#ifdef	PTHREAD_STACK_MIN
+      return PTHREAD_STACK_MIN;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_THREADS_MAX:
+#ifdef	PTHREAD_THREADS_MAX
+      return PTHREAD_THREADS_MAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_ATTR_STACKADDR:
+#ifdef	_POSIX_THREAD_ATTR_STACKADDR
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_ATTR_STACKSIZE:
+#ifdef	_POSIX_THREAD_ATTR_STACKSIZE
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_PRIORITY_SCHEDULING:
+#ifdef	_POSIX_THREAD_PRIORITY_SCHEDULING
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_PRIO_INHERIT:
+#ifdef	_POSIX_THREAD_PRIO_INHERIT
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_PRIO_PROTECT:
+#ifdef	_POSIX_THREAD_PRIO_PROTECT
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_THREAD_PROCESS_SHARED:
+#ifdef	_POSIX_THREAD_PROCESS_SHARED
+      return 1;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NPROCESSORS_CONF:
+      RETURN_FUNCTION(nprocessors_conf());
+
+    case _SC_NPROCESSORS_ONLN:
+      RETURN_FUNCTION(nprocessors_onln());
+
+    case _SC_PHYS_PAGES:
+#if 0
+      RETURN_FUNCTION(get_phys_pages());
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_AVPHYS_PAGES:
+#if 0
+      RETURN_FUNCTION(get_avphys_pages());
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_ATEXIT_MAX:
+      return __UCLIBC_MAX_ATEXIT;
+
+    case _SC_PASS_MAX:
+      /* We have no limit but since the return value might be used to
+	 allocate a buffer we restrict the value.  */
+      return BUFSIZ;
+
+    case _SC_XOPEN_VERSION:
+      return _XOPEN_VERSION;
+
+    case _SC_XOPEN_XCU_VERSION:
+      return _XOPEN_XCU_VERSION;
+
+    case _SC_XOPEN_UNIX:
+      return _XOPEN_UNIX;
+
+    case _SC_XOPEN_CRYPT:
+#ifdef	_XOPEN_CRYPT
+      return _XOPEN_CRYPT;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_ENH_I18N:
+#ifdef	_XOPEN_ENH_I18N
+      return _XOPEN_ENH_I18N;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_SHM:
+#ifdef	_XOPEN_SHM
+      return _XOPEN_SHM;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_XPG2:
+#ifdef	_XOPEN_XPG2
+      return _XOPEN_XPG2;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_XPG3:
+#ifdef	_XOPEN_XPG3
+      return _XOPEN_XPG3;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_XPG4:
+#ifdef	_XOPEN_XPG4
+      return _XOPEN_XPG4;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_CHAR_BIT:
+      return CHAR_BIT;
+
+    case _SC_CHAR_MAX:
+      return CHAR_MAX;
+
+    case _SC_CHAR_MIN:
+      return CHAR_MIN;
+
+    case _SC_INT_MAX:
+      return INT_MAX;
+
+    case _SC_INT_MIN:
+      return INT_MIN;
+
+    case _SC_LONG_BIT:
+      return sizeof (long int) * CHAR_BIT;
+
+    case _SC_WORD_BIT:
+      return sizeof (int) * CHAR_BIT;
+
+    case _SC_MB_LEN_MAX:
+      return MB_LEN_MAX;
+
+    case _SC_NZERO:
+      return NZERO;
+
+    case _SC_SSIZE_MAX:
+      return _POSIX_SSIZE_MAX;
+
+    case _SC_SCHAR_MAX:
+      return SCHAR_MAX;
+
+    case _SC_SCHAR_MIN:
+      return SCHAR_MIN;
+
+    case _SC_SHRT_MAX:
+      return SHRT_MAX;
+
+    case _SC_SHRT_MIN:
+      return SHRT_MIN;
+
+    case _SC_UCHAR_MAX:
+      return UCHAR_MAX;
+
+    case _SC_UINT_MAX:
+      return UINT_MAX;
+
+    case _SC_ULONG_MAX:
+      return ULONG_MAX;
+
+    case _SC_USHRT_MAX:
+      return USHRT_MAX;
+
+    case _SC_NL_ARGMAX:
+#ifdef	NL_ARGMAX
+      return NL_ARGMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NL_LANGMAX:
+#ifdef	NL_LANGMAX
+      return NL_LANGMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NL_MSGMAX:
+#ifdef	NL_MSGMAX
+      return NL_MSGMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NL_NMAX:
+#ifdef	NL_NMAX
+      return NL_NMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NL_SETMAX:
+#ifdef	NL_SETMAX
+      return NL_SETMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_NL_TEXTMAX:
+#ifdef	NL_TEXTMAX
+      return NL_TEXTMAX;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XBS5_ILP32_OFF32:
+#ifdef _XBS5_ILP32_OFF32
+      return _XBS5_ILP32_OFF32;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_XBS5_ILP32_OFFBIG:
+#ifdef _XBS5_ILP32_OFFBIG
+      return _XBS5_ILP32_OFFBIG;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_XBS5_LP64_OFF64:
+#ifdef _XBS5_LP64_OFF64
+      return _XBS5_LP64_OFF64;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_XBS5_LPBIG_OFFBIG:
+#ifdef _XBS5_LPBIG_OFFBIG
+      return _XBS5_LPBIG_OFFBIG;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_V7_ILP32_OFF32:
+#ifdef _POSIX_V7_ILP32_OFF32
+      return _POSIX_V7_ILP32_OFF32;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_V7_ILP32_OFFBIG:
+#ifdef _POSIX_V7_ILP32_OFFBIG
+      return _POSIX_V7_ILP32_OFFBIG;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_V7_LP64_OFF64:
+#ifdef _POSIX_V7_LP64_OFF64
+      return _POSIX_V7_LP64_OFF64;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_V7_LPBIG_OFFBIG:
+#ifdef _POSIX_V7_LPBIG_OFFBIG
+      return _POSIX_V7_LPBIG_OFFBIG;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_XOPEN_LEGACY:
+      return _XOPEN_LEGACY;
+
+    case _SC_XOPEN_REALTIME:
+#ifdef _XOPEN_REALTIME
+      return _XOPEN_REALTIME;
+#else
+      RETURN_NEG_1;
+#endif
+    case _SC_XOPEN_REALTIME_THREADS:
+#ifdef _XOPEN_REALTIME_THREADS
+      return _XOPEN_REALTIME_THREADS;
+#else
+      RETURN_NEG_1;
+#endif
+
+    case _SC_MONOTONIC_CLOCK:
+#ifdef __NR_clock_getres
+    /* Check using the clock_getres system call.  */
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+    {
+      struct timespec ts;
+      INTERNAL_SYSCALL_DECL (err);
+      int r;
+      r = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
+      return INTERNAL_SYSCALL_ERROR_P (r, err) ? -1 : _POSIX_VERSION;
+    }
+# elif defined __UCLIBC_HAS_REALTIME__
+      if (clock_getres(CLOCK_MONOTONIC, NULL) >= 0)
+        return _POSIX_VERSION;
+# endif
+#endif
+      RETURN_NEG_1;
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+    case _SC_THREAD_CPUTIME:
+# if _POSIX_THREAD_CPUTIME > 0
+      return _POSIX_THREAD_CPUTIME;
+# else
+      RETURN_NEG_1;
+# endif
+#endif
+    }
+}
+libc_hidden_def(sysconf)
diff --git a/ap/build/uClibc/libc/unistd/ualarm.c b/ap/build/uClibc/libc/unistd/ualarm.c
new file mode 100644
index 0000000..82eb972
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/ualarm.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+useconds_t ualarm(useconds_t value, useconds_t interval)
+{
+    struct itimerval otimer;
+    const struct itimerval itimer = {
+	{ 0, interval },
+	{ 0, value}
+    };
+
+    if (setitimer(ITIMER_REAL, &itimer, &otimer) < 0) {
+	return -1;
+    }
+    return((otimer.it_value.tv_sec * 1000000) + otimer.it_value.tv_usec);
+}
diff --git a/ap/build/uClibc/libc/unistd/usershell.c b/ap/build/uClibc/libc/unistd/usershell.c
new file mode 100644
index 0000000..261c1c1
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/usershell.c
@@ -0,0 +1,78 @@
+/* setusershell(), getusershell(), endusershell() for uClibc.
+ *
+ * Copyright (C) 2010 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in
+ * this tarball.
+ */
+/* My manpage reads:
+ * The  getusershell() function returns the next line from the file
+ * /etc/shells, opening the file if necessary. The line should contain
+ * the pathname of a valid user shell.  If /etc/shells does not exist
+ * or is unreadable, getusershell() behaves as if /bin/sh and /bin/csh
+ * were listed in the file.
+ * The getusershell() function returns a NULL pointer on end-of-file.
+ */
+#include <unistd.h>
+#include <stdlib.h>
+#include <paths.h>
+#include <string.h>
+#include "internal/parse_config.h"
+
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
+
+static const char * const defaultsh[] = { _PATH_BSHELL, _PATH_CSHELL, NULL};
+static char *shellb, **shells;
+static parser_t *shellp;
+
+void endusershell(void)
+{
+	if (shellp) {
+		shells = (char**) shellb;
+		while (shells && *shells) {
+			char*xxx = *shells++;
+			free(xxx);
+		}
+		config_close(shellp);
+		shellp = NULL;
+	}
+	free(shellb);
+	shellb = NULL;
+	shells = NULL;
+}
+libc_hidden_def(endusershell)
+
+void setusershell(void)
+{
+	endusershell();
+	shellp = config_open(_PATH_SHELLS);
+	if (shellp == NULL)
+		shells = (char **)defaultsh;
+	else {
+		char **shell = NULL;
+		int pos = 0;
+
+		while (config_read(shellp, &shell, 1, 1, "# \t", PARSE_NORMAL))
+		{
+			shellb = realloc(shellb, (pos + 2) * sizeof(char*));
+			shells = (char**) shellb + pos++;
+			*shells++ = strdup(*shell);
+			*shells = NULL;
+
+		}
+		shells = (char **)shellb;
+	}
+}
+libc_hidden_def(setusershell)
+
+char *getusershell(void)
+{
+	char *sh;
+	if (shells == NULL)
+		setusershell();
+	sh = *shells;
+	if (sh)
+		shells++;
+	return sh;
+}
+#endif
diff --git a/ap/build/uClibc/libc/unistd/usleep.c b/ap/build/uClibc/libc/unistd/usleep.c
new file mode 100644
index 0000000..8d01703
--- /dev/null
+++ b/ap/build/uClibc/libc/unistd/usleep.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#if defined __USE_BSD || defined __USE_POSIX98
+#if defined __UCLIBC_HAS_REALTIME__
+
+int usleep (__useconds_t usec)
+{
+	const struct timespec ts = {
+		.tv_sec = (long int) (usec / 1000000),
+		.tv_nsec = (long int) (usec % 1000000) * 1000ul
+	};
+	return nanosleep(&ts, NULL);
+}
+#else /* __UCLIBC_HAS_REALTIME__ */
+int usleep (__useconds_t usec)
+{
+	struct timeval tv;
+
+	tv.tv_sec = (long int) (usec / 1000000);
+	tv.tv_usec = (long int) (usec % 1000000);
+	return select(0, NULL, NULL, NULL, &tv);
+}
+#endif /* __UCLIBC_HAS_REALTIME__ */
+#endif