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

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/build/uClibc/librt/Makefile b/ap/build/uClibc/librt/Makefile
new file mode 100644
index 0000000..c8dc9b4
--- /dev/null
+++ b/ap/build/uClibc/librt/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=../
+include $(top_builddir)Rules.mak
+all: libs
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/ap/build/uClibc/librt/Makefile.in b/ap/build/uClibc/librt/Makefile.in
new file mode 100644
index 0000000..909afd8
--- /dev/null
+++ b/ap/build/uClibc/librt/Makefile.in
@@ -0,0 +1,74 @@
+# 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 += librt
+
+CFLAGS-librt := -DNOT_IN_libc -DIS_IN_librt $(SSP_ALL_CFLAGS)
+
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-librt.so := -Wl,--dsbt-index=9
+LDFLAGS-librt.so := $(LDFLAGS)
+LIBS-librt.so := $(LIBS)
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+LIBS-librt.so += $(top_builddir)lib/libdl.so $(top_builddir)lib/libpthread.so
+endif
+
+librt_FULL_NAME := librt-$(VERSION).so
+
+librt_DIR := $(top_srcdir)librt
+librt_OUT := $(top_builddir)librt
+
+ifeq ($(UCLIBC_HAS_REALTIME),y)
+
+librt_SRC := $(notdir $(wildcard $(librt_DIR)/*.c))
+librt_filter_SRC :=
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+librt_filter_SRC += mq_notify.c timer_create.c timer_delete.c \
+	timer_getoverr.c timer_gettime.c timer_settime.c
+librt_SSRC := $(wildcard $(librt_DIR)/*.S)
+else
+librt_filter_SRC += clock_nanosleep.c clock_getcpuclockid.c clock_gettime.c
+librt_SSRC :=
+endif
+librt_SRC := $(filter-out $(librt_filter_SRC),$(librt_SRC))
+
+librt_OBJ := $(patsubst %.c,$(librt_OUT)/%.o,$(librt_SRC))
+librt_OBJ += $(patsubst $(librt_DIR)/%.S,$(librt_OUT)/%.o,$(librt_SSRC))
+
+ASFLAGS-mq_timedreceive.S = -D_LIBC_REENTRANT
+ASFLAGS-mq_timedsend.S = -D_LIBC_REENTRANT
+
+ifeq ($(DOPIC),y)
+librt-a-y += $(librt_OBJ:.o=.os)
+else
+librt-a-y += $(librt_OBJ)
+endif
+librt-so-y += $(librt_OBJ:.o=.oS)
+
+lib-a-y += $(top_builddir)lib/librt.a
+lib-so-y += $(top_builddir)lib/librt.so
+endif
+
+
+ifeq ($(DOPIC)$(UCLIBC_HAS_THREADS_NATIVE),yn)
+$(top_builddir)lib/librt.so: $(top_builddir)lib/librt.a $(libc.depend)
+else
+$(top_builddir)lib/librt.so: $(librt_OUT)/librt_so.a $(libc.depend) $(libpthread.depend) $(libdl.depend)
+endif
+	$(call link.so,$(librt_FULL_NAME),$(ABI_VERSION))
+
+$(librt_OUT)/librt_so.a: $(librt-so-y)
+	$(Q)$(RM) $@
+	$(do_ar)
+
+$(top_builddir)lib/librt.a: $(librt-a-y) | $(top_builddir)lib
+	$(Q)$(RM) $@
+	$(do_ar)
+
+objclean-y += CLEAN_librt
+
+CLEAN_librt:
+	$(do_rm) $(addprefix $(librt_OUT)/*., o os oS a)
diff --git a/ap/build/uClibc/librt/clock_getcpuclockid.c b/ap/build/uClibc/librt/clock_getcpuclockid.c
new file mode 100644
index 0000000..704c574
--- /dev/null
+++ b/ap/build/uClibc/librt/clock_getcpuclockid.c
@@ -0,0 +1,104 @@
+/* clock_getcpuclockid -- Get a clockid_t for process CPU time.  Linux version.
+   Copyright (C) 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 <errno.h>
+#include <time.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-cpu-timers.h"
+
+#ifndef HAS_CPUCLOCK
+# define HAS_CPUCLOCK 1
+#endif
+
+int
+clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
+{
+#ifdef __NR_clock_getres
+  /* The clockid_t value is a simple computation from the PID.
+     But we do a clock_getres call to validate it.  */
+
+  const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED);
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+  extern int __libc_missing_posix_cpu_timers attribute_hidden;
+#  if !(__ASSUME_POSIX_TIMERS > 0)
+  extern int __libc_missing_posix_timers attribute_hidden;
+  if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers)
+    __libc_missing_posix_cpu_timers = 1;
+#  endif
+  if (!__libc_missing_posix_cpu_timers)
+# endif
+    {
+      INTERNAL_SYSCALL_DECL (err);
+      int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL);
+      if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+	{
+	  *clock_id = pidclock;
+	  return 0;
+	}
+
+# if !(__ASSUME_POSIX_TIMERS > 0)
+      if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
+	{
+	  /* The kernel doesn't support these calls at all.  */
+	  __libc_missing_posix_timers = 1;
+	  __libc_missing_posix_cpu_timers = 1;
+	}
+      else
+# endif
+	if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
+	  {
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+	    if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
+		|| INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL
+					     (clock_getres, err, 2,
+					      MAKE_PROCESS_CPUCLOCK
+					      (0, CPUCLOCK_SCHED), NULL),
+					     err))
+	      /* The kernel doesn't support these clocks at all.  */
+	      __libc_missing_posix_cpu_timers = 1;
+	    else
+# endif
+	      /* The clock_getres system call checked the PID for us.  */
+	      return ESRCH;
+	  }
+	else
+	  return INTERNAL_SYSCALL_ERRNO (r, err);
+    }
+#endif
+
+  /* We don't allow any process ID but our own.  */
+  if (pid != 0 && pid != getpid ())
+    return EPERM;
+
+#ifdef CLOCK_PROCESS_CPUTIME_ID
+  if (HAS_CPUCLOCK)
+    {
+      /* Store the number.  */
+      *clock_id = CLOCK_PROCESS_CPUTIME_ID;
+
+      return 0;
+    }
+#endif
+
+  /* We don't have a timer for that.  */
+  return ENOENT;
+}
diff --git a/ap/build/uClibc/librt/clock_gettime.c b/ap/build/uClibc/librt/clock_gettime.c
new file mode 100644
index 0000000..8308329
--- /dev/null
+++ b/ap/build/uClibc/librt/clock_gettime.c
@@ -0,0 +1,301 @@
+/* clock_gettime -- Get current time from a POSIX clockid_t.  Linux version.
+   Copyright (C) 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 <sysdep.h>
+#include <errno.h>
+#include <time.h>
+#include "kernel-posix-cpu-timers.h"
+#include <bits/kernel-features.h>
+
+
+#define SYSCALL_GETTIME \
+  retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \
+  break
+
+#ifdef __ASSUME_POSIX_TIMERS
+
+/* This means the REALTIME and MONOTONIC clock are definitely
+   supported in the kernel.  */
+# define SYSDEP_GETTIME							      \
+  SYSDEP_GETTIME_CPUTIME						      \
+  case CLOCK_REALTIME:							      \
+  case CLOCK_MONOTONIC:							      \
+    SYSCALL_GETTIME
+
+# define __libc_missing_posix_timers 0
+#elif defined __NR_clock_gettime
+/* Is the syscall known to exist?  */
+int __libc_missing_posix_timers attribute_hidden;
+
+static inline int
+maybe_syscall_gettime (clockid_t clock_id, struct timespec *tp)
+{
+  int e = EINVAL;
+
+  if (!__libc_missing_posix_timers)
+    {
+      INTERNAL_SYSCALL_DECL (err);
+      int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp);
+      if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+	return 0;
+
+      e = INTERNAL_SYSCALL_ERRNO (r, err);
+      if (e == ENOSYS)
+	{
+	  __libc_missing_posix_timers = 1;
+	  e = EINVAL;
+	}
+    }
+
+  return e;
+}
+
+/* The REALTIME and MONOTONIC clock might be available.  Try the
+   syscall first.  */
+# define SYSDEP_GETTIME							      \
+  SYSDEP_GETTIME_CPUTIME						      \
+  case CLOCK_REALTIME:							      \
+  case CLOCK_MONOTONIC:							      \
+    retval = maybe_syscall_gettime (clock_id, tp);			      \
+    if (retval == 0)							      \
+      break;								      \
+    /* Fallback code.  */						      \
+    if (retval == EINVAL && clock_id == CLOCK_REALTIME)			      \
+      retval = realtime_gettime (tp);					      \
+    else 								      \
+      {									      \
+	__set_errno (retval);						      \
+	retval = -1;							      \
+      }									      \
+    break;
+#endif
+
+#ifdef __NR_clock_gettime
+/* We handled the REALTIME clock here.  */
+# define HANDLED_REALTIME	1
+# define HANDLED_CPUTIME	1
+
+# if __ASSUME_POSIX_CPU_TIMERS > 0
+
+#  define SYSDEP_GETTIME_CPU SYSCALL_GETTIME
+#  define SYSDEP_GETTIME_CPUTIME	/* Default catches them too.  */
+
+# else
+
+int __libc_missing_posix_cpu_timers attribute_hidden;
+
+static int
+maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp)
+{
+  int e = EINVAL;
+
+  if (!__libc_missing_posix_cpu_timers)
+    {
+      INTERNAL_SYSCALL_DECL (err);
+      int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp);
+      if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+	return 0;
+
+      e = INTERNAL_SYSCALL_ERRNO (r, err);
+# ifndef __ASSUME_POSIX_TIMERS
+      if (e == ENOSYS)
+	{
+	  __libc_missing_posix_timers = 1;
+	  __libc_missing_posix_cpu_timers = 1;
+	  e = EINVAL;
+	}
+      else
+# endif
+	{
+	  if (e == EINVAL)
+	    {
+	      /* Check whether the kernel supports CPU clocks at all.
+		 If not, record it for the future.  */
+	      r = INTERNAL_SYSCALL (clock_getres, err, 2,
+				    MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
+				    NULL);
+	      if (INTERNAL_SYSCALL_ERROR_P (r, err))
+		__libc_missing_posix_cpu_timers = 1;
+	    }
+	}
+    }
+
+  return e;
+}
+
+#  define SYSDEP_GETTIME_CPU						      \
+  retval = maybe_syscall_gettime_cpu (clock_id, tp);			      \
+  if (retval == 0)							      \
+    break;								      \
+  if (retval != EINVAL || !__libc_missing_posix_cpu_timers)		      \
+    {									      \
+      __set_errno (retval);						      \
+      retval = -1;							      \
+      break;								      \
+    }									      \
+  retval = -1 /* Otherwise continue on to the HP_TIMING version.  */;
+
+static inline int
+maybe_syscall_gettime_cputime (clockid_t clock_id, struct timespec *tp)
+{
+  return maybe_syscall_gettime_cpu
+    (clock_id == CLOCK_THREAD_CPUTIME_ID
+     ? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
+     : MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
+     tp);
+}
+
+#  define SYSDEP_GETTIME_CPUTIME					      \
+    case CLOCK_PROCESS_CPUTIME_ID:					      \
+    case CLOCK_THREAD_CPUTIME_ID:					      \
+      retval = maybe_syscall_gettime_cputime (clock_id, tp);		      \
+      if (retval == 0)							      \
+	break;								      \
+      if (retval != EINVAL || !__libc_missing_posix_cpu_timers)		      \
+	{								      \
+	  __set_errno (retval);						      \
+	  retval = -1;							      \
+	  break;							      \
+	}								      \
+      retval = hp_timing_gettime (clock_id, tp);			      \
+      break;
+#  if !HP_TIMING_AVAIL
+#   define hp_timing_gettime(clock_id, tp) (__set_errno (EINVAL), -1)
+#  endif
+
+# endif
+#endif
+
+#include <errno.h>
+#include <stdint.h>
+#include <time.h>
+#include <sys/time.h>
+#include <libc-internal.h>
+#include <ldsodefs.h>
+
+
+#if HP_TIMING_AVAIL
+/* Clock frequency of the processor.  We make it a 64-bit variable
+   because some jokers are already playing with processors with more
+   than 4GHz.  */
+static hp_timing_t freq;
+
+
+/* This function is defined in the thread library.  */
+extern int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
+				    struct timespec *tp)
+     __attribute__ ((__weak__));
+
+static int
+hp_timing_gettime (clockid_t clock_id, struct timespec *tp)
+{
+  hp_timing_t tsc;
+
+  if (__builtin_expect (freq == 0, 0))
+    {
+      /* This can only happen if we haven't initialized the `freq'
+	 variable yet.  Do this now. We don't have to protect this
+	 code against multiple execution since all of them should
+	 lead to the same result.  */
+      freq = __get_clockfreq ();
+      if (__builtin_expect (freq == 0, 0))
+	/* Something went wrong.  */
+	return -1;
+    }
+
+  if (clock_id != CLOCK_PROCESS_CPUTIME_ID
+      && __pthread_clock_gettime != NULL)
+    return __pthread_clock_gettime (clock_id, freq, tp);
+
+  /* Get the current counter.  */
+  HP_TIMING_NOW (tsc);
+
+  /* Compute the offset since the start time of the process.  */
+  tsc -= GL(dl_cpuclock_offset);
+
+  /* Compute the seconds.  */
+  tp->tv_sec = tsc / freq;
+
+  /* And the nanoseconds.  This computation should be stable until
+     we get machines with about 16GHz frequency.  */
+  tp->tv_nsec = ((tsc % freq) * UINT64_C (1000000000)) / freq;
+
+  return 0;
+}
+#endif
+
+
+static inline int
+realtime_gettime (struct timespec *tp)
+{
+  struct timeval tv;
+  int retval = gettimeofday (&tv, NULL);
+  if (retval == 0)
+    /* Convert into `timespec'.  */
+    TIMEVAL_TO_TIMESPEC (&tv, tp);
+  return retval;
+}
+
+librt_hidden_proto (clock_gettime)
+/* Get current value of CLOCK and store it in TP.  */
+int
+clock_gettime (clockid_t clock_id, struct timespec *tp)
+{
+  int retval = -1;
+#ifndef HANDLED_REALTIME
+  struct timeval tv;
+#endif
+
+  switch (clock_id)
+    {
+#ifdef SYSDEP_GETTIME
+      SYSDEP_GETTIME;
+#endif
+
+#ifndef HANDLED_REALTIME
+    case CLOCK_REALTIME:
+      retval = gettimeofday (&tv, NULL);
+      if (retval == 0)
+	TIMEVAL_TO_TIMESPEC (&tv, tp);
+      break;
+#endif
+
+    default:
+#ifdef SYSDEP_GETTIME_CPU
+      SYSDEP_GETTIME_CPU;
+#endif
+#if HP_TIMING_AVAIL
+      if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
+	  == CLOCK_THREAD_CPUTIME_ID)
+	retval = hp_timing_gettime (clock_id, tp);
+      else
+#endif
+	__set_errno (EINVAL);
+      break;
+
+#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
+    case CLOCK_PROCESS_CPUTIME_ID:
+      retval = hp_timing_gettime (clock_id, tp);
+      break;
+#endif
+    }
+
+  return retval;
+}
+librt_hidden_def (clock_gettime)
diff --git a/ap/build/uClibc/librt/clock_nanosleep.c b/ap/build/uClibc/librt/clock_nanosleep.c
new file mode 100644
index 0000000..69e6008
--- /dev/null
+++ b/ap/build/uClibc/librt/clock_nanosleep.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 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 <time.h>
+#include <errno.h>
+
+#include <sysdep-cancel.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-cpu-timers.h"
+
+
+#ifdef __ASSUME_POSIX_TIMERS
+/* We can simply use the syscall.  The CPU clocks are not supported
+   with this function.  */
+int
+clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+		 struct timespec *rem)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  int r;
+
+  if (clock_id == CLOCK_THREAD_CPUTIME_ID)
+    return EINVAL;
+  if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
+    clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);
+
+  if (SINGLE_THREAD_P)
+    r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem);
+  else
+    {
+      int oldstate = LIBC_CANCEL_ASYNC ();
+
+      r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req,
+			    rem);
+
+      LIBC_CANCEL_RESET (oldstate);
+    }
+
+  return (INTERNAL_SYSCALL_ERROR_P (r, err)
+	  ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
+}
+
+#else
+# ifdef __NR_clock_nanosleep
+/* Is the syscall known to exist?  */
+extern int __libc_missing_posix_timers attribute_hidden;
+
+/* The REALTIME and MONOTONIC clock might be available.  Try the
+   syscall first.  */
+#  define SYSDEP_NANOSLEEP \
+  if (!__libc_missing_posix_timers)					      \
+    {									      \
+      clockid_t syscall_clockid;					      \
+      INTERNAL_SYSCALL_DECL (err);					      \
+									      \
+      if (clock_id == CLOCK_THREAD_CPUTIME_ID)				      \
+	return EINVAL;							      \
+      if (clock_id == CLOCK_PROCESS_CPUTIME_ID)				      \
+	syscall_clockid = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);	      \
+      else								      \
+	syscall_clockid = clock_id;					      \
+									      \
+      int oldstate = LIBC_CANCEL_ASYNC ();				      \
+									      \
+      int r = INTERNAL_SYSCALL (clock_nanosleep, err, 4,		      \
+				syscall_clockid, flags, req, rem);	      \
+									      \
+      LIBC_CANCEL_RESET (oldstate);					      \
+									      \
+      if (!INTERNAL_SYSCALL_ERROR_P (r, err))				      \
+	return 0;							      \
+									      \
+      if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS)			      \
+	return INTERNAL_SYSCALL_ERRNO (r, err);				      \
+									      \
+      __libc_missing_posix_timers = 1;					      \
+    }
+# endif
+
+# include <sysdeps/unix/clock_nanosleep.c>
+#endif
diff --git a/ap/build/uClibc/librt/kernel-posix-cpu-timers.h b/ap/build/uClibc/librt/kernel-posix-cpu-timers.h
new file mode 100644
index 0000000..164a90d
--- /dev/null
+++ b/ap/build/uClibc/librt/kernel-posix-cpu-timers.h
@@ -0,0 +1,18 @@
+/* Parameters for the Linux kernel ABI for CPU clocks.  */
+
+#define CPUCLOCK_PID(clock)		((pid_t) ~((clock) >> 3))
+#define CPUCLOCK_PERTHREAD(clock) \
+	(((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
+#define CPUCLOCK_PID_MASK	7
+#define CPUCLOCK_PERTHREAD_MASK	4
+#define CPUCLOCK_WHICH(clock)	((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
+#define CPUCLOCK_CLOCK_MASK	3
+#define CPUCLOCK_PROF		0
+#define CPUCLOCK_VIRT		1
+#define CPUCLOCK_SCHED		2
+#define CPUCLOCK_MAX		3
+
+#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
+	((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
+#define MAKE_THREAD_CPUCLOCK(tid, clock) \
+	MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
diff --git a/ap/build/uClibc/librt/kernel-posix-timers.h b/ap/build/uClibc/librt/kernel-posix-timers.h
new file mode 100644
index 0000000..f8bfdc2
--- /dev/null
+++ b/ap/build/uClibc/librt/kernel-posix-timers.h
@@ -0,0 +1,58 @@
+/*
+ * kernel-posix-timers.h - kernel-dependent definitions for POSIX timers.
+ */
+
+#include <features.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <sys/types.h>
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+#endif
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+/* Nonzero if the system calls are not available.  */
+extern int __no_posix_timers attribute_hidden;
+
+/* Callback to start helper thread.  */
+extern void __start_helper_thread (void) attribute_hidden;
+
+/* Control variable for helper thread creation.  */
+extern pthread_once_t __helper_once attribute_hidden;
+
+/* TID of the helper thread.  */
+extern pid_t __helper_tid attribute_hidden;
+
+/* List of active SIGEV_THREAD timers.  */
+extern struct timer *__active_timer_sigev_thread attribute_hidden;
+/* Lock for the __active_timer_sigev_thread.  */
+extern pthread_mutex_t __active_timer_sigev_thread_lock attribute_hidden;
+#endif
+
+/* Type of timers in the kernel */
+typedef int kernel_timer_t;
+
+/* Internal representation of timer */
+struct timer {
+    /* Notification mechanism */
+    int sigev_notify;
+
+    /* Timer ID returned by the kernel */
+    kernel_timer_t ktimerid;
+
+    /*
+     * All new elements must be added after ktimerid. And if the thrfunc
+     * element is not the third element anymore the memory allocation in
+     * timer_create needs to be changed.
+     */
+
+    /* Parameters for the thread to be started for SIGEV_THREAD */
+    void (*thrfunc) (sigval_t);
+    sigval_t sival;
+#ifdef __UCLIBC_HAS_THREADS__
+    pthread_attr_t attr;
+#endif
+
+    /* Next element in list of active SIGEV_THREAD timers. */
+    struct timer *next;
+};
diff --git a/ap/build/uClibc/librt/mq_close.c b/ap/build/uClibc/librt/mq_close.c
new file mode 100644
index 0000000..cf04044
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_close.c
@@ -0,0 +1,22 @@
+/*
+ * mq_close.c - close a message queue.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include <mqueue.h>
+
+#ifdef __NR_mq_open
+
+/*
+ * Remove the association between message queue descriptor and its
+ * message queue.
+ */
+int mq_close(mqd_t mqdes)
+{
+	return close(mqdes);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_getsetattr.c b/ap/build/uClibc/librt/mq_getsetattr.c
new file mode 100644
index 0000000..b50d9a9
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_getsetattr.c
@@ -0,0 +1,36 @@
+/*
+ * mq_getattr.c - get message queue attributes.
+ */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/syscall.h>
+
+#include <mqueue.h>
+
+#ifdef __NR_mq_getsetattr
+
+librt_hidden_proto(mq_setattr)
+#define __NR___syscall_mq_getsetattr __NR_mq_getsetattr
+static __inline__ _syscall3(int, __syscall_mq_getsetattr, int, mqdes,
+			const void *, mqstat, void *, omqstat);
+
+/*
+ * Set attributes associated with message queue (and possibly also get
+ * its old attributes)
+ */
+int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat,
+               struct mq_attr *omqstat)
+{
+	return __syscall_mq_getsetattr(mqdes, mqstat, omqstat);
+}
+
+librt_hidden_def(mq_setattr)
+
+/* Query status and attributes of message queue */
+int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)
+{
+	return mq_setattr(mqdes, NULL, mqstat);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_notify.c b/ap/build/uClibc/librt/mq_notify.c
new file mode 100644
index 0000000..2556669
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_notify.c
@@ -0,0 +1,28 @@
+/*
+ * mq_notify.c - notify process that a message is available.
+ */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/syscall.h>
+
+#include <mqueue.h>
+
+#ifdef __NR_mq_notify
+
+#define __NR___syscall_mq_notify __NR_mq_notify
+static __inline__ _syscall2(int, __syscall_mq_notify, int, mqdes,
+			const void *, notification);
+
+/* Register notification upon message arrival to an empty message queue */
+int mq_notify(mqd_t mqdes, const struct sigevent *notification)
+{
+	/* We don't support SIGEV_THREAD notification yet */
+	if (notification != NULL && notification->sigev_notify == SIGEV_THREAD) {
+		__set_errno(ENOSYS);
+		return -1;
+	}
+	return __syscall_mq_notify(mqdes, notification);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_open.c b/ap/build/uClibc/librt/mq_open.c
new file mode 100644
index 0000000..62c8310
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_open.c
@@ -0,0 +1,52 @@
+/*
+ * mq_open.c - open a message queue.
+ */
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <sys/syscall.h>
+
+#include <mqueue.h>
+
+#ifdef __NR_mq_open
+
+#define __NR___syscall_mq_open __NR_mq_open
+static __inline__ _syscall4(int, __syscall_mq_open, const char *, name,
+			int, oflag, __kernel_mode_t, mode, void *, attr);
+/*
+ * Establish connection between a process and a message queue and
+ * return message queue descriptor or (mqd_t) -1 on error.
+ * oflag determines the type of access used. If O_CREAT is on oflag, the
+ * third argument is taken as a `mode_t', the mode of the created
+ * message queue, and the fourth argument is taken as `struct mq_attr *',
+ * pointer to message queue attributes.
+ * If the fourth argument is NULL, default attributes are used.
+ */
+mqd_t mq_open(const char *name, int oflag, ...)
+{
+	mode_t mode;
+	struct mq_attr *attr;
+
+	if (name[0] != '/') {
+		__set_errno(EINVAL);
+		return -1;
+	}
+
+	mode = 0;
+	attr = NULL;
+
+	if (oflag & O_CREAT) {
+		va_list ap;
+
+		va_start(ap, oflag);
+		mode = va_arg(ap, mode_t);
+		attr = va_arg(ap, struct mq_attr *);
+
+		va_end(ap);
+	}
+
+	return __syscall_mq_open(name + 1, oflag, mode, attr);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_receive.c b/ap/build/uClibc/librt/mq_receive.c
new file mode 100644
index 0000000..26fc451
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_receive.c
@@ -0,0 +1,48 @@
+/*
+ * mq_receive.c - functions for receiving from message queue.
+ */
+
+#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedreceive
+
+#include <stddef.h>
+#include <mqueue.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+librt_hidden_proto(mq_timedreceive)
+#else
+
+# define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
+static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
+		 char *, msg_ptr, size_t, msg_len, unsigned int *,
+		 msg_prio, const void *, abs_timeout);
+
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+/*
+ * Receive the oldest from highest priority messages.
+ * Stop waiting if abs_timeout expires.
+ */
+ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
+			unsigned int *msg_prio,
+			const struct timespec *abs_timeout)
+{
+	return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
+					 abs_timeout);
+}
+# endif
+
+#endif
+
+/* Receive the oldest from highest priority messages */
+ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
+		   unsigned int *msg_prio)
+{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+	return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_send.c b/ap/build/uClibc/librt/mq_send.c
new file mode 100644
index 0000000..78308d8
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_send.c
@@ -0,0 +1,46 @@
+/*
+ * mq_send.c - functions for sending to message queue.
+ */
+
+#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedsend
+
+#include <stddef.h>
+#include <mqueue.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+librt_hidden_proto(mq_timedsend)
+#else
+
+# define __NR___syscall_mq_timedsend __NR_mq_timedsend
+static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
+		 const char *, msg_ptr, size_t, msg_len, unsigned int,
+		 msg_prio, const void *, abs_timeout);
+
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+/*
+ * Add a message to queue. If O_NONBLOCK is set and queue is full, wait
+ * for sufficient room in the queue until abs_timeout expires.
+ */
+int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+		 unsigned int msg_prio, const struct timespec *abs_timeout)
+{
+	return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
+				      abs_timeout);
+}
+# endif
+#endif
+
+/* Add a message to queue */
+int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+	    unsigned int msg_prio)
+{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+	return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+	return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/mq_timedreceive.S b/ap/build/uClibc/librt/mq_timedreceive.S
new file mode 100644
index 0000000..015eb88
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_timedreceive.S
@@ -0,0 +1,10 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_mq_timedreceive
+#error Missing definition of NR_timedreceive needed for cancellation.
+#endif
+PSEUDO (__mq_timedreceive, mq_timedreceive, 5)
+ret
+PSEUDO_END(__mq_timedreceive)
+librt_hidden_def (__mq_timedreceive)
+weak_alias (__mq_timedreceive, mq_timedreceive)
+librt_hidden_weak (mq_timedreceive)
diff --git a/ap/build/uClibc/librt/mq_timedsend.S b/ap/build/uClibc/librt/mq_timedsend.S
new file mode 100644
index 0000000..67758a3
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_timedsend.S
@@ -0,0 +1,10 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_mq_timedsend
+#error Missing definition of NR_timedsend needed for cancellation.
+#endif
+PSEUDO (__mq_timedsend, mq_timedsend, 5)
+ret
+PSEUDO_END(__mq_timedsend)
+librt_hidden_def (__mq_timedsend)
+weak_alias (__mq_timedsend, mq_timedsend)
+librt_hidden_weak (mq_timedsend)
diff --git a/ap/build/uClibc/librt/mq_unlink.c b/ap/build/uClibc/librt/mq_unlink.c
new file mode 100644
index 0000000..3c490e0
--- /dev/null
+++ b/ap/build/uClibc/librt/mq_unlink.c
@@ -0,0 +1,39 @@
+/*
+ * mq_unlink.c - remove a message queue.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+#include <mqueue.h>
+
+#ifdef __NR_mq_unlink
+
+#define __NR___syscall_mq_unlink __NR_mq_unlink
+static __inline__ _syscall1(int, __syscall_mq_unlink, const char *, name);
+
+/* Remove message queue */
+int mq_unlink(const char *name)
+{
+	int ret;
+
+	if (name[0] != '/') {
+		__set_errno(EINVAL);
+		return -1;
+	}
+
+	ret = __syscall_mq_unlink(name + 1);
+
+	/* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES.  */
+	if (ret < 0) {
+		ret = errno;
+		if (ret == EPERM)
+			ret = EACCES;
+		__set_errno(ret);
+		ret = -1;
+	}
+
+	return ret;
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/rt_stubs.c b/ap/build/uClibc/librt/rt_stubs.c
new file mode 100644
index 0000000..a2b84e6
--- /dev/null
+++ b/ap/build/uClibc/librt/rt_stubs.c
@@ -0,0 +1,40 @@
+/*
+ * system call not available stub
+ * based on libc's stubs.c
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+#ifdef __UCLIBC_HAS_STUBS__
+
+static int rt_enosys_stub(void) __attribute_used__;
+static int rt_enosys_stub(void)
+{
+	__set_errno(ENOSYS);
+	return -1;
+}
+
+#define make_stub(stub) \
+	link_warning(stub, #stub ": this function is not implemented") \
+	strong_alias(rt_enosys_stub, stub)
+
+#ifndef __NR_mq_timedreceive
+make_stub(mq_receive)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedreceive)
+# endif
+#endif
+
+#ifndef __NR_mq_timedsend
+make_stub(mq_send)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedsend)
+# endif
+#endif
+
+#endif
diff --git a/ap/build/uClibc/librt/shm.c b/ap/build/uClibc/librt/shm.c
new file mode 100644
index 0000000..40e69fa
--- /dev/null
+++ b/ap/build/uClibc/librt/shm.c
@@ -0,0 +1,102 @@
+/* Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#ifndef _PATH_SHM
+#define _PATH_SHM "/dev/shm/"
+#endif
+
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
+
+/* Get name of dummy shm operation handle.
+ * Returns a malloc'ed buffer containing the OS specific path
+ * to the shm filename or NULL upon failure.
+ */
+static __attribute_noinline__ char* get_shm_name(const char *name) __nonnull((1));
+static char* get_shm_name(const char *name)
+{
+	char *path;
+	int i;
+
+	/* Skip leading slashes */
+	while (*name == '/')
+		++name;
+#ifdef __USE_GNU
+	i = asprintf(&path, _PATH_SHM "%s", name);
+	if (i < 0)
+		return NULL;
+#else
+	path = malloc(NAME_MAX);
+	if (path == NULL)
+		return NULL;
+	i = snprintf(path, NAME_MAX, _PATH_SHM "%s", name);
+	if (i < 0) {
+		free(path);
+		return NULL;
+	} else if (i >= NAME_MAX) {
+		free(path);
+		__set_errno(ENAMETOOLONG);
+		return NULL;
+	}
+#endif
+	return path;
+}
+
+int shm_open(const char *name, int oflag, mode_t mode)
+{
+	int fd;
+	char *shm_name = get_shm_name(name);
+
+	/* Stripped multiple '/' from start; may have set errno properly */
+	if (shm_name == NULL)
+		return -1;
+	/* The FD_CLOEXEC file descriptor flag associated with the new
+	 * file descriptor is set.  */
+#ifdef O_CLOEXEC
+	 /* Just open it with CLOEXEC set, for brevity */
+	fd = open(shm_name, oflag | O_CLOEXEC, mode);
+#else
+	fd = open(shm_name, oflag, mode);
+	if (fd >= 0) {
+		fcntl(fd, F_SETFD, FD_CLOEXEC);
+		/* thus far, {G,S}ETFD only has this single flag,
+		 * and setting it never fails.
+		 *int fdflags = fcntl(fd, F_GETFD);
+		 *if (fdflags >= 0)
+		 *	fdflags = fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
+		 *if (fdflags < 0) {
+		 *	close(fd);
+		 *	fd = -1;
+		 *}
+		 */
+	}
+#endif
+	free(shm_name); /* doesn't affect errno */
+	return fd;
+}
+
+int shm_unlink(const char *name)
+{
+	char *shm_name = get_shm_name(name);
+	int ret;
+
+	/* Stripped multiple '/' from start; may have set errno properly */
+	if (shm_name == NULL)
+		return -1;
+	ret = unlink(shm_name);
+	free(shm_name); /* doesn't affect errno */
+	return ret;
+}
diff --git a/ap/build/uClibc/librt/timer_create.c b/ap/build/uClibc/librt/timer_create.c
new file mode 100644
index 0000000..9298a37
--- /dev/null
+++ b/ap/build/uClibc/librt/timer_create.c
@@ -0,0 +1,71 @@
+/*
+ * timer_create.c - create a per-process timer.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_create
+
+#ifndef offsetof
+# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define __NR___syscall_timer_create __NR_timer_create
+static __inline__ _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
+			struct sigevent *, evp, kernel_timer_t *, ktimerid);
+
+/* Create a per-process timer */
+int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t * timerid)
+{
+	int retval;
+	kernel_timer_t ktimerid;
+	struct sigevent default_evp;
+	struct timer *newp;
+
+	if (evp == NULL) {
+		/*
+		 * The kernel has to pass up the timer ID which is a userlevel object.
+		 * Therefore we cannot leave it up to the kernel to determine it.
+		 */
+		default_evp.sigev_notify = SIGEV_SIGNAL;
+		default_evp.sigev_signo = SIGALRM;
+		evp = &default_evp;
+	}
+
+	/* Notification via a thread is not supported yet */
+	if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
+		return -1;
+
+	/*
+	 * We avoid allocating too much memory by basically using
+	 * struct timer as a derived class with the first two elements
+	 * being in the superclass. We only need these two elements here.
+	 */
+	newp = malloc(offsetof(struct timer, thrfunc));
+	if (newp == NULL)
+		return -1;	/* No memory */
+	default_evp.sigev_value.sival_ptr = newp;
+
+	retval = __syscall_timer_create(clock_id, evp, &ktimerid);
+	if (retval != -1) {
+		newp->sigev_notify = evp->sigev_notify;
+		newp->ktimerid = ktimerid;
+
+		*timerid = (timer_t) newp;
+	} else {
+		/* Cannot allocate the timer, fail */
+		free(newp);
+		retval = -1;
+	}
+
+	return retval;
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/timer_delete.c b/ap/build/uClibc/librt/timer_delete.c
new file mode 100644
index 0000000..af6b34f
--- /dev/null
+++ b/ap/build/uClibc/librt/timer_delete.c
@@ -0,0 +1,33 @@
+/*
+ * timer_delete.c - delete a per-process timer.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_delete
+
+#define __NR___syscall_timer_delete __NR_timer_delete
+static __inline__ _syscall1(int, __syscall_timer_delete, kernel_timer_t, ktimerid);
+
+/* Delete a per-process timer */
+int timer_delete(timer_t timerid)
+{
+	int res;
+	struct timer *kt = (struct timer *)timerid;
+
+	/* Delete the kernel timer object */
+	res = __syscall_timer_delete(kt->ktimerid);
+	if (res == 0) {
+		free(kt);	/* Free the memory */
+		return 0;
+	}
+
+	return -1;
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/timer_getoverr.c b/ap/build/uClibc/librt/timer_getoverr.c
new file mode 100644
index 0000000..0e85516
--- /dev/null
+++ b/ap/build/uClibc/librt/timer_getoverr.c
@@ -0,0 +1,26 @@
+/*
+ * timer-getoverr.c - get the timer overrun count.
+ */
+
+#include <errno.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_getoverrun
+
+#define __NR___syscall_timer_getoverrun __NR_timer_getoverrun
+static __inline__ _syscall1(int, __syscall_timer_getoverrun, kernel_timer_t,
+			ktimerid);
+
+/* Get the timer overrun count */
+int timer_getoverrun(timer_t timerid)
+{
+	struct timer *kt = (struct timer *)timerid;
+
+	/* Get the information from the kernel */
+	return __syscall_timer_getoverrun(kt->ktimerid);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/timer_gettime.c b/ap/build/uClibc/librt/timer_gettime.c
new file mode 100644
index 0000000..e13f446
--- /dev/null
+++ b/ap/build/uClibc/librt/timer_gettime.c
@@ -0,0 +1,27 @@
+/*
+ * timer_gettime.c - get the timer value.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_gettime
+
+#define __NR___syscall_timer_gettime __NR_timer_gettime
+static __inline__ _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid,
+			void *, value);
+
+/* Get the amount of time left on a timer */
+int timer_gettime(timer_t timerid, struct itimerspec *value)
+{
+	struct timer *kt = (struct timer *)timerid;
+
+	/* Get timeout from the kernel */
+	return __syscall_timer_gettime(kt->ktimerid, value);
+}
+
+#endif
diff --git a/ap/build/uClibc/librt/timer_settime.c b/ap/build/uClibc/librt/timer_settime.c
new file mode 100644
index 0000000..2703fa9
--- /dev/null
+++ b/ap/build/uClibc/librt/timer_settime.c
@@ -0,0 +1,28 @@
+/*
+ * timer_settime.c - set the timer.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/syscall.h>
+
+#include "kernel-posix-timers.h"
+
+#ifdef __NR_timer_settime
+
+#define __NR___syscall_timer_settime __NR_timer_settime
+static __inline__ _syscall4(int, __syscall_timer_settime, kernel_timer_t, ktimerid,
+			int, flags, const void *, value, void *, ovalue);
+
+/* Set the expiration time for a timer */
+int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
+		  struct itimerspec *ovalue)
+{
+	struct timer *kt = (struct timer *)timerid;
+
+	/* Set timeout */
+	return __syscall_timer_settime(kt->ktimerid, flags, value, ovalue);
+}
+
+#endif