zte's code,first commit
Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/Makefile b/ap/build/uClibc/libc/sysdeps/linux/nios2/Makefile
new file mode 100644
index 0000000..633c91f
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/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.arch
+include $(top_srcdir)Makerules
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/Makefile.arch b/ap/build/uClibc/libc/sysdeps/linux/nios2/Makefile.arch
new file mode 100644
index 0000000..a0c485a
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/Makefile.arch
@@ -0,0 +1,12 @@
+# 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.
+#
+
+CSRC := brk.c syscall.c
+
+SSRC := \
+ __longjmp.S bsd-_setjmp.S bsd-setjmp.S setjmp.S \
+ vfork.S clone.S
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/__longjmp.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/__longjmp.S
new file mode 100644
index 0000000..4b6508e
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/__longjmp.S
@@ -0,0 +1,50 @@
+/*
+ * libc/sysdeps/linux/nios2/__longjmp.S
+ *
+ * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ *
+ */
+
+#include <features.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+.globl __longjmp
+.type __longjmp,@function
+.balign 4
+
+__longjmp:
+ /* return value is in r5*/
+ mov r2, r5
+
+ /* jmp_buf in r4, restore regs. */
+ ldw r16, (JB_REGS+ 0)(r4)
+ ldw r17, (JB_REGS+ 4)(r4)
+ ldw r18, (JB_REGS+ 8)(r4)
+ ldw r19, (JB_REGS+12)(r4)
+ ldw r20, (JB_REGS+16)(r4)
+ ldw r21, (JB_REGS+20)(r4)
+ ldw r22, (JB_REGS+24)(r4)
+ ldw r23, (JB_REGS+28)(r4)
+
+ ldw ra, JB_PC(r4)
+ ldw fp, JB_FP(r4)
+ ldw gp, JB_GP(r4)
+ ldw sp, JB_SP(r4)
+
+#if defined(__HAVE_FPU__)
+ RESTORE_FPU r4 JB_FPREGS
+#endif
+
+ /* return to saved RA */
+ ret
+
+.size __longjmp,.-__longjmp
+libc_hidden_def(__longjmp)
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/endian.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/endian.h
new file mode 100644
index 0000000..de60add
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/endian.h
@@ -0,0 +1,7 @@
+/* Nios II is little-endian. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/fcntl.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/fcntl.h
new file mode 100644
index 0000000..e564b42
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/fcntl.h
@@ -0,0 +1,238 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 2000, 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 _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECTORY 040000 /* Must be a directory. */
+# define O_NOFOLLOW 0100000 /* Do not follow links. */
+# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0400000
+#endif
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
+ close-on-exit set on new fd. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+/* Splice address range into a pipe. */
+extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
+ size_t __count, unsigned int __flags);
+
+/* Splice two files together. */
+extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
+ __off64_t *__offout, size_t __len,
+ unsigned int __flags);
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern ssize_t tee (int __fdin, int __fdout, size_t __len,
+ unsigned int __flags);
+
+#endif
+__END_DECLS
+
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_stat.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_stat.h
new file mode 100644
index 0000000..99a6cba
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_stat.h
@@ -0,0 +1,50 @@
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
+
+/* This file provides whatever this particular arch's kernel thinks
+ * struct kernel_stat should look like... It turns out each arch has a
+ * different opinion on the subject... */
+
+struct kernel_stat {
+ unsigned short st_dev;
+ unsigned short __pad1;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned short __pad2;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+struct kernel_stat64 {
+ unsigned short st_dev;
+ unsigned char __pad0[10];
+#define _HAVE_STAT64___ST_INO
+ unsigned long __st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned long st_uid;
+ unsigned long st_gid;
+ unsigned short st_rdev;
+ unsigned char __pad3[10];
+ long long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long long st_ino;
+};
+
+#endif /* _BITS_STAT_STRUCT_H */
+
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_types.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_types.h
new file mode 100644
index 0000000..3c030e7
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/kernel_types.h
@@ -0,0 +1,46 @@
+/* Note that we use the exact same include guard #define names
+ * as asm/posix_types.h. This will avoid gratuitous conflicts
+ * with the posix_types.h kernel header, and will ensure that
+ * our private content, and not the kernel header, will win.
+ * -Erik
+ */
+#ifndef _ASM_NIOS2_POSIX_TYPES_H
+#define _ASM_NIOS2_POSIX_TYPES_H
+
+typedef unsigned long __kernel_dev_t;
+typedef unsigned long __kernel_ino_t;
+typedef unsigned short __kernel_mode_t;
+typedef unsigned short __kernel_nlink_t;
+typedef long __kernel_off_t;
+typedef int __kernel_pid_t;
+typedef unsigned short __kernel_ipc_pid_t;
+typedef unsigned short __kernel_uid_t;
+typedef unsigned short __kernel_gid_t;
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef unsigned int __kernel_uid32_t;
+typedef unsigned int __kernel_gid32_t;
+typedef unsigned short __kernel_old_uid_t;
+typedef unsigned short __kernel_old_gid_t;
+typedef unsigned short __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+typedef long long __kernel_loff_t;
+
+typedef struct {
+#ifdef __USE_ALL
+ int val[2];
+#else
+ int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#endif /* _ASM_NIOS2_POSIX_TYPES_H */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/mathdef.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/mathdef.h
new file mode 100644
index 0000000..e013e74
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/mathdef.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 1999, 2000, 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. */
+
+#if !defined _MATH_H && !defined _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
+# define _MATH_H_MATHDEF 1
+
+/* GCC does not promote `float' values to `double'. */
+typedef float float_t; /* `float' expressions are evaluated as
+ `float'. */
+typedef double double_t; /* `double' expressions are evaluated as
+ `double'. */
+
+/* The values returned by `ilogb' for 0 and NaN respectively. */
+# define FP_ILOGB0 (-2147483647)
+# define FP_ILOGBNAN (2147483647)
+
+#endif /* ISO C99 */
+
+#ifndef __NO_LONG_DOUBLE_MATH
+/* Signal that we do not really have a `long double'. This disables the
+ declaration of all the `long double' function variants. */
+/* XXX The FPA does support this but the patterns in GCC are currently
+ turned off. */
+# define __NO_LONG_DOUBLE_MATH 1
+#endif
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/setjmp.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/setjmp.h
new file mode 100644
index 0000000..fcff031
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/setjmp.h
@@ -0,0 +1,72 @@
+/* Define the machine-dependent type `jmp_buf'. Nios2 version.
+ Copyright (C) 1992,93,95,97,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 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 _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+typedef struct
+{
+ /* Callee-saved registers r16 through r23. */
+ unsigned long __regs[8];
+
+ /* Program counter. */
+ unsigned long __pc;
+
+ /* Stack pointer. */
+ unsigned long __sp;
+
+ /* The frame pointer. */
+ unsigned long __fp;
+
+ /* The global pointer. */
+ unsigned long __gp;
+
+ /* floating point regs, if any */
+#if defined __HAVE_FPU__
+ unsigned long __fpregs[64];
+#endif
+} __jmp_buf[1];
+
+#endif
+
+#define JB_REGS 0
+#define JB_PC 32
+#define JB_SP 36
+#define JB_FP 40
+#define JB_GP 44
+#define JB_FPREGS 48
+
+#if defined __HAVE_FPU__
+# define JB_SIZE 304
+#else
+# define JB_SIZE 48
+#endif
+
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void*)(jmpbuf)->__sp)
+
+#endif /* bits/setjmp.h */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h
new file mode 100644
index 0000000..d6383b9
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, 1998.
+
+ 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. */
+
+#define SIGCONTEXT struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS
+#define GET_PC(ctx) ((void *) (ctx)->regs.ea)
+#define GET_FRAME(ctx) ((void *) (ctx)->regs.sp)
+#define GET_STACK(ctx) ((void *) (ctx)->regs.fp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stackinfo.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stackinfo.h
new file mode 100644
index 0000000..e7fbf56
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 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. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On nios II the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stat.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stat.h
new file mode 100644
index 0000000..d380eee
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/stat.h
@@ -0,0 +1,168 @@
+/* Copyright (C) 1992,95,96,97,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. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_KERNEL 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+
+struct stat
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino; /* File serial number. */
+#else
+ __ino_t __st_ino; /* 32bit file serial number. */
+#endif
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+#ifndef __USE_FILE_OFFSET64
+ __off_t st_size; /* Size of file, in bytes. */
+#else
+ __off64_t st_size; /* Size of file, in bytes. */
+#endif
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+#else
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
+#ifndef __USE_FILE_OFFSET64
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+#else
+ __ino64_t st_ino; /* File serial number. */
+#endif
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned int __pad1;
+
+ __ino_t __st_ino; /* 32bit file serial number. */
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned int __pad2;
+ __off64_t st_size; /* Size of file, in bytes. */
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+#else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
+ __ino64_t st_ino; /* File serial number. */
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* POSIX.1b objects. Note that these macros always evaluate to zero. But
+ they do it by enforcing the correct use of the macros. */
+#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/syscalls.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/syscalls.h
new file mode 100644
index 0000000..3214e3c
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/syscalls.h
@@ -0,0 +1,108 @@
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+#ifndef __ASSEMBLER__
+
+#include <errno.h>
+#include <asm/traps.h>
+
+#define __syscall_return(type, res) \
+ do { \
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, ))) { \
+ __set_errno(INTERNAL_SYSCALL_ERRNO(res, )); \
+ res = (unsigned long) -1; \
+ } \
+ return (type) (res); \
+ } while (0)
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ long __res; \
+ __asm__ __volatile__ ( \
+ "movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
+ "movi r3, %1\n\t" /* __NR_##name */ \
+ ASM_ARGS_##nr \
+ "trap\n\t" \
+ "mov %0, r2\n\t" /* syscall return */ \
+ : "=r" (__res) /* %0 */ \
+ : "i" (name) /* %1 */ \
+ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
+ MAP_ARGS_##nr (args) /* %3-%8 */ \
+ : "r2" \
+ , "r3" \
+ CLOB_ARGS_##nr /* Clobbered */ \
+ ); \
+ __res; \
+ }) \
+)
+
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned long)(val) >= (unsigned long)(-125))
+
+#define ASM_ARGS_0
+#define MAP_ARGS_0()
+#define CLOB_ARGS_0
+
+#define ASM_ARGS_1 \
+ "mov r4, %3\n\t"
+#define MAP_ARGS_1(a) \
+ , "r" ((long) a)
+#define CLOB_ARGS_1 \
+ , "r4"
+
+#define ASM_ARGS_2 \
+ ASM_ARGS_1 \
+ "mov r5, %4\n\t"
+#define MAP_ARGS_2(a, b) \
+ MAP_ARGS_1(a) \
+ , "r" ((long) b)
+#define CLOB_ARGS_2 \
+ CLOB_ARGS_1 \
+ , "r5"
+
+#define ASM_ARGS_3 \
+ ASM_ARGS_2 \
+ "mov r6, %5\n\t"
+#define MAP_ARGS_3(a, b, c) \
+ MAP_ARGS_2(a, b) \
+ , "r" ((long) c)
+#define CLOB_ARGS_3 \
+ CLOB_ARGS_2 \
+ , "r6"
+
+#define ASM_ARGS_4 \
+ ASM_ARGS_3 \
+ "mov r7, %6\n\t"
+#define MAP_ARGS_4(a, b, c, d) \
+ MAP_ARGS_3(a, b, c) \
+ , "r" ((long) d)
+#define CLOB_ARGS_4 \
+ CLOB_ARGS_3 \
+ , "r7"
+
+#define ASM_ARGS_5 \
+ ASM_ARGS_4 \
+ "mov r8, %7\n\t"
+#define MAP_ARGS_5(a, b, c, d, e) \
+ MAP_ARGS_4(a, b, c, d) \
+ , "r" ((long) e)
+#define CLOB_ARGS_5 \
+ CLOB_ARGS_4 \
+ , "r8"
+
+#define ASM_ARGS_6 \
+ ASM_ARGS_5 \
+ "mov r9, %8\n\t"
+#define MAP_ARGS_6(a, b, c, d, e, f) \
+ MAP_ARGS_5(a, b, c, d, e) \
+ , "r" ((long) f)
+#define CLOB_ARGS_6 \
+ CLOB_ARGS_5 \
+ , "r9"
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
new file mode 100644
index 0000000..2a9422e
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
@@ -0,0 +1,48 @@
+/*
+ * Track misc arch-specific features that aren't config options
+ */
+
+#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
+#define _BITS_UCLIBC_ARCH_FEATURES_H
+
+/* instruction used when calling abort() to kill yourself */
+/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
+#undef __UCLIBC_ABORT_INSTRUCTION__
+
+/* can your target use syscall6() for mmap ? */
+#undef __UCLIBC_MMAP_HAS_6_ARGS__
+
+/* does your target use syscall4() for truncate64 ? (32bit arches only) */
+#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+
+/* does your target have a broken create_module() ? */
+#undef __UCLIBC_BROKEN_CREATE_MODULE__
+
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
+
+/* does your target have an asm .set ? */
+#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+
+/* define if target doesn't like .global */
+#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+
+/* define if target supports .weak */
+#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
+
+/* define if target supports .weakext */
+#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
+
+/* needed probably only for ppc64 */
+#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
+
+/* define if target supports CFI pseudo ops */
+#undef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
+
+/* define if target supports IEEE signed zero floats */
+#define __UCLIBC_HAVE_SIGNED_ZERO__
+
+/* only weird assemblers generally need this */
+#undef __UCLIBC_ASM_LINE_SEP__
+
+#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_page.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_page.h
new file mode 100644
index 0000000..311dd40
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/uClibc_page.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004 Erik Andersen
+ *
+ * This 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.
+ */
+
+/* Supply an architecture specific value for PAGE_SIZE and friends. */
+
+#ifndef _UCLIBC_PAGE_H
+#define _UCLIBC_PAGE_H
+
+/* PAGE_SHIFT determines the page size -- in this case 4096 */
+#define PAGE_SHIFT (12)
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#endif /* _UCLIBC_PAGE_H */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/wordsize.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/wordsize.h
new file mode 100644
index 0000000..ba643b6
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bits/wordsize.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 1999 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. */
+
+#define __WORDSIZE 32
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/brk.c b/ap/build/uClibc/libc/sysdeps/linux/nios2/brk.c
new file mode 100644
index 0000000..24bd719
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/brk.c
@@ -0,0 +1,45 @@
+/* brk system call for Linux/Nios2.
+ Copyright (C) 1995, 1996, 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 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 <unistd.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+/* This must be initialized data because commons can't have aliases. */
+void *__curbrk attribute_hidden = 0;
+
+int brk (void *addr)
+{
+ void *newbrk;
+ register int r2 __asm__("r2") = TRAP_ID_SYSCALL;
+ register int r3 __asm__("r3") = __NR_brk;
+ register void *r4 __asm__("r4") = addr;
+
+ __asm__ __volatile__ ("trap\n\t" : "=r"(newbrk) : "0"(r2), "r"(r3), "r"(r4));
+
+ __curbrk = newbrk;
+
+ if (newbrk < addr) {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+libc_hidden_def(brk)
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-_setjmp.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-_setjmp.S
new file mode 100644
index 0000000..ed4061c
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-_setjmp.S
@@ -0,0 +1,45 @@
+/*
+ * libc/sysdeps/linux/nios2/bsd-_setjmp.S
+ *
+ * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ *
+ */
+
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+ .globl _setjmp
+ .type _setjmp,@function
+ .balign 4
+
+_setjmp:
+ stw r16, (JB_REGS+ 0)(r4)
+ stw r17, (JB_REGS+ 4)(r4)
+ stw r18, (JB_REGS+ 8)(r4)
+ stw r19, (JB_REGS+12)(r4)
+ stw r20, (JB_REGS+16)(r4)
+ stw r21, (JB_REGS+20)(r4)
+ stw r22, (JB_REGS+24)(r4)
+ stw r23, (JB_REGS+28)(r4)
+
+ stw ra, JB_PC(r4)
+ stw sp, JB_SP(r4)
+ stw fp, JB_FP(r4)
+ stw gp, JB_GP(r4)
+
+#if defined(__HAVE_FPU__)
+ SAVE_FPU r4 JB_FPREGS
+#endif
+ stw r0, JB_SIZE(r4) /* signal mask is not saved */
+ mov r2, zero
+ ret
+
+
+
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-setjmp.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-setjmp.S
new file mode 100644
index 0000000..ac99bfe
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/bsd-setjmp.S
@@ -0,0 +1,52 @@
+/*
+ * libc/sysdeps/linux/nios2/bsd-setjmp.S
+ *
+ * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ *
+ */
+
+
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+ .globl setjmp
+ .type setjmp,@function
+ .balign 4
+
+setjmp:
+ stw r16, (JB_REGS+ 0)(r4)
+ stw r17, (JB_REGS+ 4)(r4)
+ stw r18, (JB_REGS+ 8)(r4)
+ stw r19, (JB_REGS+12)(r4)
+ stw r20, (JB_REGS+16)(r4)
+ stw r21, (JB_REGS+20)(r4)
+ stw r22, (JB_REGS+24)(r4)
+ stw r23, (JB_REGS+28)(r4)
+
+ stw ra, JB_PC(r4)
+ stw sp, JB_SP(r4)
+ stw fp, JB_FP(r4)
+ stw gp, JB_GP(r4)
+
+#if defined(__HAVE_FPU__)
+ SAVE_FPU r4 JB_FPREGS
+#endif
+
+ movui r5, 1
+#ifdef __PIC__
+ /* just pray 16 bit offset is enough */
+ br __sigjmp_save
+#else
+ movhi r8, %hi(__sigjmp_save)
+ ori r8, r8, %lo(__sigjmp_save)
+ jmp r8
+#endif
+
+
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.S
new file mode 100644
index 0000000..4afcb7d
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.S
@@ -0,0 +1,70 @@
+/*
+ * libc/sysdeps/linux/nios2/clone.S -- `clone' syscall for linux/nios2
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#define _ERRNO_H
+#include <bits/errno.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_clone
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+.text
+.global clone
+.type clone,%function
+.align 4
+clone:
+ addi sp,sp,-8
+ mov r8,r4
+ stw ra,4(sp)
+ stw r16,0(sp)
+
+ mov r4,r6
+ movi r2,-EINVAL
+
+ /* sanity check */
+ beq r8,zero,CLONE_ERROR_LABEL
+ beq r5,zero,CLONE_ERROR_LABEL
+
+ /* system call */
+ movi r2,TRAP_ID_SYSCALL
+ movi r3,__NR_clone
+ trap
+
+ /* child call the function */
+ mov r4,r7
+ bne r2,zero,CLONE_ERROR_LABEL
+ callr r8
+
+ /* exit if it returns */
+ mov r4,r2
+ movi r3,__NR_exit
+ trap
+
+CLONE_ERROR_LABEL:
+ movi r3,-4096
+ sub r16,zero,r2
+ bgeu r3,r2,CLONE_OK
+
+ /* store errno */
+ call __errno_location
+ stw r16,0(r2)
+ movi r2,-1
+
+CLONE_OK:
+ ldw ra,4(sp)
+ ldw r16,0(sp)
+ addi sp,sp,8
+ ret
+
+.size clone,.-clone
+
+#endif
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.c b/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.c
new file mode 100644
index 0000000..eec9f42
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/clone.c
@@ -0,0 +1,50 @@
+/*
+ * libc/sysdeps/linux/nios2/clone.c -- `clone' syscall for linux/nios2
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ *
+ * Copyright (C) 2004,05 Microtronix Datacom Ltd
+ * Copyright (C) 2002,03 NEC Electronics Corporation
+ * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ * Nios2 port by Wentao Xu
+ */
+
+#include <errno.h>
+#include <sched.h>
+#include <sys/syscall.h>
+
+int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
+{
+ register unsigned long rval __asm__ ("r2") = -EINVAL;
+
+ if (fn && child_stack) {
+ register unsigned long syscall __asm__ ("r3");
+ register unsigned long arg0 __asm__ ("r4");
+ register unsigned long arg1 __asm__ ("r5");
+
+ /* Clone this thread. */
+ rval = TRAP_ID_SYSCALL;
+ syscall = __NR_clone;
+ arg0 = flags;
+ arg1 = (unsigned long)child_stack;
+ __asm__ __volatile__ ("trap "
+ : "=r" (rval), "=r" (syscall)
+ : "0" (rval),"1" (syscall), "r" (arg0), "r" (arg1)
+ );
+
+ if (rval == 0) {
+ /* In child thread, call fn and exit. */
+ arg0 = (*fn) (arg);
+ syscall = __NR_exit;
+ __asm__ __volatile__ ("trap "
+ : "=r" (rval), "=r" (syscall)
+ : "1" (syscall), "r" (arg0));
+ }
+ }
+
+ __syscall_return (int, rval);
+}
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/crt1.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/crt1.S
new file mode 100644
index 0000000..0ba8d59
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/crt1.S
@@ -0,0 +1,73 @@
+/*
+ * libc/sysdeps/linux/nios2/crt0.S -- entry point for linux/nios2
+ *
+ * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ * Updated by Thomas Chou <thomas@wytron.com.tw> for crt1.S
+ *
+ */
+
+#include <features.h>
+#include <asm/unistd.h>
+
+ .global _start
+ .type _start,@function
+ .type _init,%function
+ .type _fini,%function
+#ifndef __UCLIBC_CTOR_DTOR__
+ .weak _init
+ .weak _fini
+#endif
+ .type main,@function
+ .type __uClibc_main,@function
+ .type __h_errno_location, @function
+ .type _stdio_init, @function
+ .type _stdio_term, @function
+ .text
+ .balign 4
+_start:
+ nop
+ br 0f
+0:
+ /* load gp */
+ movhi gp, %hiadj(_gp)
+ addi gp, gp, %lo(_gp)
+
+ /* load main, argc, argv from stack */
+ movhi r4, %hi(main)
+ ori r4, r4, %lo(main) /* main */
+ ldw r5, 0(sp) /* argc */
+ ldw r6, 4(sp) /* argv */
+
+ /* load the 4th arg */
+ movhi r7, %hi(_init)
+ ori r7, r7, %lo(_init)
+
+ /* Allocate space on the stack for 6-7th arg, reuse 5th space */
+ addi sp,sp,-8
+ /* push 5-7th args on stack */
+ movhi r8, %hi(_fini)
+ ori r8, r8, %lo(_fini)
+ stw r8, 0(sp)
+
+ stw r2, 4(sp) /* rtld_fini */
+ stw sp, 8(sp) /* stack_end */
+
+ /* call uClibc_main, shouldn't return */
+#ifdef __PIC__
+ /* just pray 16 bit offset is enough */
+ br __uClibc_main
+#else
+ call __uClibc_main
+#endif
+
+ /* crash in the event of return */
+__exit:
+ movui r2, TRAP_ID_SYSCALL
+ movui r3, __NR_exit
+ trap
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/crti.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/crti.S
new file mode 100644
index 0000000..26c55c9
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/crti.S
@@ -0,0 +1,22 @@
+
+ .section .init
+ .balign 4
+ .global _init
+ .type _init, @function
+_init:
+ addi sp, sp, -8
+ stw ra, 0(sp)
+ stw fp, 4(sp)
+
+ .balign 4
+
+
+ .section .fini
+ .balign 4
+ .global _fini
+ .type _fini, @function
+_fini:
+ addi sp, sp, -8
+ stw ra, 0(sp)
+ stw fp, 4(sp)
+ .balign 4
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/crtn.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/crtn.S
new file mode 100644
index 0000000..de00fd1
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/crtn.S
@@ -0,0 +1,14 @@
+
+ .section .init
+
+ ldw ra, 0(sp)
+ ldw fp, 4(sp)
+ addi sp, sp, 8
+ ret
+
+ .section .fini
+
+ ldw ra, 0(sp)
+ ldw fp, 4(sp)
+ addi sp, sp, 8
+ ret
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/fpu_control.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/fpu_control.h
new file mode 100644
index 0000000..9c31745
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/fpu_control.h
@@ -0,0 +1,99 @@
+/* FPU control word bits. Nios2 version.
+ Copyright (C) 1996, 1997, 1998, 1999, 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 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 _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* MIPS FPU floating point control register bits.
+ *
+ * 31-25 -> floating point conditions code bits 7-1. These bits are only
+ * available in MIPS IV.
+ * 24 -> flush denormalized results to zero instead of
+ * causing unimplemented operation exception. This bit is only
+ * available for MIPS III and newer.
+ * 23 -> Condition bit
+ * 22-18 -> reserved (read as 0, write with 0)
+ * 17 -> cause bit for unimplemented operation
+ * 16 -> cause bit for invalid exception
+ * 15 -> cause bit for division by zero exception
+ * 14 -> cause bit for overflow exception
+ * 13 -> cause bit for underflow exception
+ * 12 -> cause bit for inexact exception
+ * 11 -> enable exception for invalid exception
+ * 10 -> enable exception for division by zero exception
+ * 9 -> enable exception for overflow exception
+ * 8 -> enable exception for underflow exception
+ * 7 -> enable exception for inexact exception
+ * 6 -> flag invalid exception
+ * 5 -> flag division by zero exception
+ * 4 -> flag overflow exception
+ * 3 -> flag underflow exception
+ * 2 -> flag inexact exception
+ * 1-0 -> rounding control
+ *
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (up) toward plus infinity (RP)
+ * 11 - rounding (down)toward minus infinity (RM)
+ */
+
+#include <features.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_V 0x0800 /* Invalid operation */
+#define _FPU_MASK_Z 0x0400 /* Division by zero */
+#define _FPU_MASK_O 0x0200 /* Overflow */
+#define _FPU_MASK_U 0x0100 /* Underflow */
+#define _FPU_MASK_I 0x0080 /* Inexact operation */
+
+/* flush denormalized numbers to zero */
+#define _FPU_FLUSH_TZ 0x1000000
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
+#define _FPU_RC_ZERO 0x1
+#define _FPU_RC_UP 0x2
+#define _FPU_RC_DOWN 0x3
+
+#define _FPU_RESERVED 0xfe3c0000 /* Reserved bits in cw */
+
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+ and no interrupts for exceptions, rounding to nearest. */
+
+#define _FPU_DEFAULT 0x00000000
+
+/* IEEE: same as above, but exceptions */
+#define _FPU_IEEE 0x00000F80
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
+
+/* Macros for accessing the hardware control word. */
+#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
+#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
+
+#if 0
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+#endif
+
+#endif /* fpu_control.h */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/setjmp.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/setjmp.S
new file mode 100644
index 0000000..8acd220
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/setjmp.S
@@ -0,0 +1,51 @@
+/*
+ * libc/sysdeps/linux/nios2/setjmp.S
+ *
+ * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ *
+ */
+
+#include <features.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+.globl __sigsetjmp
+.type __sigsetjmp,@function
+.balign 4
+
+__sigsetjmp:
+ stw r16, (JB_REGS+ 0)(r4)
+ stw r17, (JB_REGS+ 4)(r4)
+ stw r18, (JB_REGS+ 8)(r4)
+ stw r19, (JB_REGS+12)(r4)
+ stw r20, (JB_REGS+16)(r4)
+ stw r21, (JB_REGS+20)(r4)
+ stw r22, (JB_REGS+24)(r4)
+ stw r23, (JB_REGS+28)(r4)
+
+ stw ra, JB_PC(r4)
+ stw sp, JB_SP(r4)
+ stw fp, JB_FP(r4)
+ stw gp, JB_GP(r4)
+
+#if defined(__HAVE_FPU__)
+ SAVE_FPU r4 JB_FPREGS
+#endif
+
+#ifdef __PIC__
+ /* just pray 16 bit offset is enough */
+ br __sigjmp_save
+#else
+ movhi r8, %hi(__sigjmp_save)
+ ori r8, r8, %lo(__sigjmp_save)
+ jmp r8
+#endif
+
+.size __sigsetjmp,.-__sigsetjmp
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/procfs.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/procfs.h
new file mode 100644
index 0000000..8cbaa41
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/procfs.h
@@ -0,0 +1,123 @@
+/* Copyright (C) 1996, 1997, 1999, 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 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 _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somehow modelled after the file of the same name on SysVr4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. */
+
+#include <features.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <sys/user.h>
+#include <bits/wordsize.h>
+
+__BEGIN_DECLS
+
+#define ELF_NGREG 38
+
+typedef struct
+ {
+ union
+ {
+ unsigned long pr_regs[32];
+ double pr_dregs[16];
+ } pr_fr;
+ unsigned long __unused;
+ unsigned long pr_fsr;
+ unsigned char pr_qcnt;
+ unsigned char pr_q_entrysize;
+ unsigned char pr_en;
+ unsigned int pr_q[64];
+ } elf_fpregset_t;
+
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ gdb doesn't really use excluded. Fields present but not used are
+ marked with "XXX". */
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/ucontext.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/ucontext.h
new file mode 100644
index 0000000..1805b4e
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/ucontext.h
@@ -0,0 +1,104 @@
+/* Copyright (C) 1998, 1999 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 _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+/*
+ * Location of the users' stored registers relative to R0.
+ * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
+ */
+#define REG_PSR (0)
+#define REG_PC (1)
+#define REG_SPARE (2)
+#define REG_WVALID (3)
+#define REG_G1 (4)
+#define REG_G2 (5)
+#define REG_G3 (6)
+#define REG_G4 (7)
+#define REG_G5 (8)
+#define REG_G6 (9)
+#define REG_G7 (10)
+#define REG_O0 (11)
+#define REG_O1 (12)
+#define REG_O2 (13)
+#define REG_O3 (14)
+#define REG_O4 (15)
+#define REG_O5 (16)
+#define REG_O6 (17)
+#define REG_O7 (18)
+#define REG_GLOBALS (19)
+
+/*
+ * A gregset_t is defined as an array type for compatibility with the reference
+ * source. This is important due to differences in the way the C language
+ * treats arrays and structures as parameters.
+ *
+ * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
+ * but that the ABI defines it absolutely to be 21 (resp. 19).
+ */
+
+#define NGREG 20
+typedef int greg_t;
+
+typedef greg_t gregset_t[NGREG];
+
+/*
+ * The following structures define how a register window can appear on the
+ * stack. This structure is available (when required) through the `gwins'
+ * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the
+ * maximum number of outstanding register windows defined in the NIOS
+ * architecture (*not* implementation).
+ */
+#define NIOS_MAXREGWINDOW 31 /* max windows in NIOS arch. */
+struct rwindow
+ {
+ greg_t rw_local[8]; /* locals */
+ greg_t rw_in[8]; /* ins */
+ };
+
+#define rw_fp rw_in[6] /* frame pointer */
+#define rw_rtn rw_in[7] /* return address */
+
+typedef struct gwindows
+ {
+ int wbcnt;
+ int *spbuf[NIOS_MAXREGWINDOW];
+ struct rwindow wbuf[NIOS_MAXREGWINDOW];
+ } gwindows_t;
+
+typedef struct
+ {
+ gregset_t gregs; /* general register set */
+ gwindows_t *gwins; /* POSSIBLE pointer to register windows */
+ } mcontext_t;
+
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/user.h b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/user.h
new file mode 100644
index 0000000..b34e93e
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/sys/user.h
@@ -0,0 +1,93 @@
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+/*
+ This file was taken from the nios2 port of the Linux Kernel.
+
+ Copyright (c) 2008 Atle Nissestad <atle@nissestad.no>
+ Copyright (c) 2010 Tobias Klauser <tklauser@distanz.ch>
+
+ This file is licensed under the terms of the GNU General Public License,
+ Version 2.
+ */
+
+#include <bits/uClibc_page.h>
+
+/* Core file format: The core file is written in such a way that gdb
+ can understand it and provide useful information to the user (under
+ linux we use the 'trad-core' bfd). There are quite a number of
+ obstacles to being able to view the contents of the floating point
+ registers, and until these are solved you will not be able to view the
+ contents of them. Actually, you can read in the core file and look at
+ the contents of the user struct to find out what the floating point
+ registers contain.
+ The actual file contents are as follows:
+ UPAGE: 1 page consisting of a user struct that tells gdb what is present
+ in the file. Directly after this is a copy of the task_struct, which
+ is currently not used by gdb, but it may come in useful at some point.
+ All of the registers are stored as part of the upage. The upage should
+ always be only one page.
+ DATA: The data area is stored. We use current->end_text to
+ current->brk to pick up all of the user variables, plus any memory
+ that may have been malloced. No attempt is made to determine if a page
+ is demand-zero or if a page is totally unused, we just cover the entire
+ range. All of the addresses are rounded in such a way that an integral
+ number of pages is written.
+ STACK: We need the stack information in order to get a meaningful
+ backtrace. We need to write the data from (esp) to
+ current->start_stack, so we round each of these off in order to be able
+ to write an integer number of pages.
+ The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+struct user_nios2fp_struct {
+};
+
+/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
+ is still the layout used by user (the new pt_regs doesn't have
+ all registers). */
+struct user_regs_struct {
+ long r1,r2,r3,r4,r5,r6,r7,r8;
+ long r9,r10,r11,r12,r13,r14,r15;
+ long r16,r17,r18,r19,r20,r21,r22,r23;
+ long gp;
+ long sp;
+ long ra;
+ long fp;
+ long orig_r2;
+ long estatus;
+ long status_extension;
+ long ea;
+};
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+struct user {
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+
+/* The rest of this junk is to help gdb figure out what goes where */
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ esp register. */
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ unsigned long u_ar0; /* Used by gdb to help find the values for */
+ /* the registers. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/syscall.c b/ap/build/uClibc/libc/sysdeps/linux/nios2/syscall.c
new file mode 100644
index 0000000..c3eb002
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/syscall.c
@@ -0,0 +1,47 @@
+/*
+ * libc/sysdeps/linux/nios2/syscall.c -- generic syscall function for linux/nios2
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd.
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+
+long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
+{
+ register long _r2 __asm__("r2")=(long)TRAP_ID_SYSCALL;
+ register long _r3 __asm__("r3")=(long)sysnum;
+
+ register long _r4 __asm__("r4")=(long)(a);
+ register long _r5 __asm__("r5")=(long)(b);
+ register long _r6 __asm__("r6")=(long)(c);
+ register long _r7 __asm__("r7")=(long)(d);
+ register long _r8 __asm__("r8")=(long)(e);
+ register long _r9 __asm__("r9")=(long)(f);
+ __asm__ __volatile__(
+ "trap "
+ : "=r"(_r2), "=r"(_r3)
+ : "0"(_r2), "1"(_r3),
+ "r"(_r4), "r"(_r5), "r"(_r6), "r"(_r7), "r"(_r8), "r"(_r9)
+ : "memory");
+
+ __syscall_return (long, _r2);
+}
+
diff --git a/ap/build/uClibc/libc/sysdeps/linux/nios2/vfork.S b/ap/build/uClibc/libc/sysdeps/linux/nios2/vfork.S
new file mode 100644
index 0000000..5d275ff
--- /dev/null
+++ b/ap/build/uClibc/libc/sysdeps/linux/nios2/vfork.S
@@ -0,0 +1,56 @@
+/*
+ * libc/sysdeps/linux/nios2/vfork.S -- `vfork' syscall for linux/nios2
+ *
+ * Copyright (C) 2004 Microtronix Datacom Ltd
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Wentao Xu <wentao@microtronix.com>
+ */
+
+#include <features.h>
+
+#define _ERRNO_H
+#include <bits/errno.h>
+#include <asm/unistd.h>
+
+#ifndef __NR_vfork
+#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
+#endif
+
+.text
+.global __vfork
+.hidden __vfork
+.type __vfork,%function
+.align 4
+__vfork:
+ movui r2, TRAP_ID_SYSCALL
+ movui r3, __NR_vfork
+ trap
+ movi r8, -4096
+ bltu r8, r2, fix_errno
+ ret
+fix_errno:
+ sub r8, r0, r2
+
+ addi sp, sp, -8
+ stw ra, 4(sp)
+ stw r8, 0(sp)
+#ifndef __PIC__
+ call __errno_location
+#else
+
+#endif
+ ldw ra, 4(sp)
+ ldw r8, 0(sp)
+ stw r8, 0(r2)
+
+ addi r2, r0, -1
+ addi sp, sp, 8
+ ret
+
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)