summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-10-08 18:15:50 +0000
committerEric Andersen <andersen@codepoet.org>2003-10-08 18:15:50 +0000
commitc7757f181f0bd52206059f2685a5197113aca76f (patch)
treedcf97b5cda180791099fb63e028eccddf1f6c31b
parent9456866061819ea226ebe2b39ef20622fd36c2f1 (diff)
Patch from George Thanos adding support for the "e1" architecture.
-rw-r--r--extra/Configs/Config.e149
-rw-r--r--extra/Configs/Config.e1.default64
-rw-r--r--libc/sysdeps/linux/e1/Makefile66
-rw-r--r--libc/sysdeps/linux/e1/bits/endian.h7
-rw-r--r--libc/sysdeps/linux/e1/bits/fcntl.h180
-rw-r--r--libc/sysdeps/linux/e1/bits/fenv.h88
-rw-r--r--libc/sysdeps/linux/e1/bits/fenvinline.h298
-rw-r--r--libc/sysdeps/linux/e1/bits/kernel_stat.h57
-rw-r--r--libc/sysdeps/linux/e1/bits/kernel_types.h45
-rw-r--r--libc/sysdeps/linux/e1/bits/mman.h75
-rw-r--r--libc/sysdeps/linux/e1/bits/proto.h5
-rw-r--r--libc/sysdeps/linux/e1/bits/setjmp.h18
-rw-r--r--libc/sysdeps/linux/e1/bits/syscalls.h22
-rw-r--r--libc/sysdeps/linux/e1/bits/unistd.h464
-rw-r--r--libc/sysdeps/linux/e1/bits/wordsize.h22
-rw-r--r--libc/sysdeps/linux/e1/crt0.S8
-rw-r--r--libc/sysdeps/linux/e1/crt1.c48
-rw-r--r--libc/sysdeps/linux/e1/longjmp.c72
-rw-r--r--libc/sysdeps/linux/e1/setjmp.c54
-rw-r--r--libc/sysdeps/linux/e1/sys/procfs.h31
-rw-r--r--libc/sysdeps/linux/e1/sys/reg.h25
-rw-r--r--libc/sysdeps/linux/e1/sys/ucontext.h109
-rw-r--r--libc/sysdeps/linux/e1/syscalls.c11
-rw-r--r--libc/sysdeps/linux/e1/vfork.c7
24 files changed, 1825 insertions, 0 deletions
diff --git a/extra/Configs/Config.e1 b/extra/Configs/Config.e1
new file mode 100644
index 000000000..ddb0b50b7
--- /dev/null
+++ b/extra/Configs/Config.e1
@@ -0,0 +1,49 @@
+
+
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+mainmenu "uClibc C Library Configuration"
+
+menu "Target Architecture Features and Options"
+
+config ARCH_E1
+ bool
+ default y
+
+config HAVE_ELF
+ bool
+ default n
+
+config ARCH_CFLAGS
+ string
+ default "-I$(KERNEL_SOURCE)/include -mgnu-param"
+
+# --bitwise-or
+
+config ARCH_LDFLAGS
+ string
+
+config LIBGCC_CFLAGS
+ string
+
+config HAVE_ELF
+ bool
+ default n
+
+config ARCH_HAS_NO_MMU
+ bool
+ default y
+
+config ARCH_HAS_C_SYMBOL_PREFIX
+ bool
+ default y
+
+source "extra/Configs/Config.in.arch"
+
+endmenu
+
+source "extra/Configs/Config.in"
+
+
diff --git a/extra/Configs/Config.e1.default b/extra/Configs/Config.e1.default
new file mode 100644
index 000000000..44621262e
--- /dev/null
+++ b/extra/Configs/Config.e1.default
@@ -0,0 +1,64 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Target Architecture Features and Options
+#
+# HAVE_ELF is not set
+ARCH_CFLAGS="-I$(KERNEL_SOURCE)/include -mgnu-param"
+ARCH_HAS_NO_MMU=y
+ARCH_HAS_C_SYMBOL_PREFIX=y
+UCLIBC_HAS_FLOATS=y
+# HAS_FPU is not set
+UCLIBC_HAS_SOFT_FLOAT=y
+# DO_C99_MATH is not set
+WARNINGS="-Wall"
+KERNEL_SOURCE="/usr/src/linux"
+UCLIBC_UCLINUX_BROKEN_MUNMAP=y
+EXCLUDE_BRK=y
+C_SYMBOL_PREFIX="_"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+# DOPIC is not set
+# UCLIBC_CTOR_DTOR is not set
+# UCLIBC_PROFILING is not set
+# UCLIBC_HAS_THREADS is not set
+# UCLIBC_HAS_LFS is not set
+MALLOC=y
+# MALLOC_930716 is not set
+UCLIBC_DYNAMIC_ATEXIT=y
+HAS_SHADOW=y
+UCLIBC_HAS_REGEX=y
+UNIX98PTY_ONLY=y
+# ASSUME_DEVPTS is not set
+
+#
+# Networking Support
+#
+# UCLIBC_HAS_IPV6 is not set
+# UCLIBC_HAS_RPC is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_WCHAR=y
+# UCLIBC_HAS_LOCALE is not set
+# USE_OLD_VFPRINTF is not set
+
+#
+# Library Installation Options
+#
+DEVEL_PREFIX="/usr/$(TARGET_ARCH)-linux-uclibc"
+SYSTEM_DEVEL_PREFIX="$(DEVEL_PREFIX)"
+DEVEL_TOOL_PREFIX="$(DEVEL_PREFIX)/usr"
+
+#
+# uClibc hacking options
+#
+DODEBUG=y
+# DOASSERTS is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
diff --git a/libc/sysdeps/linux/e1/Makefile b/libc/sysdeps/linux/e1/Makefile
new file mode 100644
index 000000000..45ee29989
--- /dev/null
+++ b/libc/sysdeps/linux/e1/Makefile
@@ -0,0 +1,66 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
+#
+# 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
+
+TOPDIR=../../../../
+include $(TOPDIR)Rules.mak
+ASFLAGS=$(CFLAGS)
+
+# If you're looking for vfork(), it is defined in include/unistd.h
+
+
+CRT0=crt0.S
+CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
+
+SSRC=
+SOBJS=$(patsubst %.S,%.o, $(SSRC))
+
+CSRC=crt1.c syscalls.c longjmp.c setjmp.c vfork.c
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+
+OBJS=$(SOBJS) $(MOBJ) $(COBJS) $(CRT0_OBJ)
+
+all: $(OBJS) $(LIBC)
+
+$(LIBC): ar-target
+
+ar-target: $(OBJS) $(CRT0_OBJ) # Tassos
+ $(AR) $(ARFLAGS) $(LIBC) $(OBJS) #Tassos
+ cp $(CRT0_OBJ) $(TOPDIR)lib/$(CRT0_OBJ) #Tassos
+
+$(CRT0_OBJ): %.o : %.S
+ $(CC) $(CFLAGS) -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(SOBJS): %.o : %.S
+ $(CC) $(CFLAGS) -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(COBJS): %.o : %.c
+ $(CC) $(CFLAGS) -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+headers:
+
+
+clean:
+ rm -f *.[oa] *~ core
+ rm -f bits/sysnum.h
+ifneq ($(strip $(HAVE_ELF)),y)
+ rm -f $(TOPDIR)/include/float.h
+endif
+
diff --git a/libc/sysdeps/linux/e1/bits/endian.h b/libc/sysdeps/linux/e1/bits/endian.h
new file mode 100644
index 000000000..6d119f75a
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/endian.h
@@ -0,0 +1,7 @@
+/* e1 is big-endian. */ /*Tassos*/
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/libc/sysdeps/linux/e1/bits/fcntl.h b/libc/sysdeps/linux/e1/bits/fcntl.h
new file mode 100644
index 000000000..4b41b4715
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/fcntl.h
@@ -0,0 +1,180 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 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 _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* 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_STREAMING 04000000/* streaming access */
+#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_XOPEN2K
+# 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. */
+#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
diff --git a/libc/sysdeps/linux/e1/bits/fenv.h b/libc/sysdeps/linux/e1/bits/fenv.h
new file mode 100644
index 000000000..dde6aceaa
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/fenv.h
@@ -0,0 +1,88 @@
+
+/* Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
+ Yannis Mitsos <yannis.mitsos@gdt.gr>
+
+ Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+
+ 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 _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+
+/* Define bits representing the exception. We use the bit positions of
+ the appropriate bits in the SR. */
+enum
+ {
+ FE_INEXACT = (1 << 8),
+#define FE_INEXACT FE_INEXACT
+ FE_UNDERFLOW = (1 << 9),
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_OVERFLOW = (1 << 10),
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_DIVBYZERO = (1 << 11),
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_INVALID = (1 << 12)
+#define FE_INVALID FE_INVALID
+ };
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* We support all of the four defined rounding modes. We use
+ the bit positions in the FPCR Mode Control Byte as the values for the
+ appropriate macros. */
+enum
+ {
+ FE_TONEAREST = 0,
+#define FE_TONEAREST FE_TONEAREST
+ FE_TOWARDZERO = 1 << 13 ,
+#define FE_TOWARDZERO FE_TOWARDZERO
+ FE_DOWNWARD = 2 << 13,
+#define FE_DOWNWARD FE_DOWNWARD
+ FE_UPWARD = 3 << 13
+#define FE_UPWARD FE_UPWARD
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+
+/* Type representing floating-point environment.*/
+typedef struct
+{
+ unsigned int round_mode;
+ unsigned int trap_enabled;
+ unsigned int accrued_except;
+ unsigned int actual_except;
+} fenv_t;
+
+#if 0
+/* If the default argument is used we use this value. */
+const fenv FE_DFL_ENV_OBJ = {0, 0x1C00, 0}
+#define FE_DFL_ENV (&FE_DFL_ENV_OBJ)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+const fenv_t FE_NOMASK_ENV_OBJ = { 0, 0x1F00, 0 };
+# define FE_NOMASK_ENV (&FE_NOMASK_ENV_OBJ)
+#endif
+
+#endif
+
+#include <bits/fenvinline.h>
diff --git a/libc/sysdeps/linux/e1/bits/fenvinline.h b/libc/sysdeps/linux/e1/bits/fenvinline.h
new file mode 100644
index 000000000..27ee172a5
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/fenvinline.h
@@ -0,0 +1,298 @@
+/*
+ Inline floating-point environment handling functions for Hyperstone e1-32X.
+ Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
+ Yannis Mitsos <yannis.mitsos@gdt.gr>
+
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+ 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 __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
+
+/**********************************************************
+ * --- A small description of the E1-16/32X FP unit. ---
+ * FP exceptions can be enabled and disabled through
+ * <feenableexcept>, <fedisableexcept>.
+ *
+ * - When an enabled exception takes place a SIGFPE signal
+ * is sent to the process by the exception handler. User
+ * can test for the exception that took place through
+ * <fetestexcept>.
+ * feraiseexcept works only for accrued exceptions.
+ *
+ * - When a disabld exception takes place it does not generate
+ * a trap. The user can check if any exception took place after
+ * an FP instruction by issuing an <fetestexcept> command.
+ * User should first clear the G2 register by issuing an
+ * <feclearexcept> function.
+ * The following program is a typical example of how the user
+ * should check for exceptions that did not generate a SIGFPE
+ * signal :
+ * {
+ * double f;
+ * int raised;
+ * feclearexcept (FE_ALL_EXCEPT);
+ * f = compute ();
+ * raised = fetestexcept (FE_OVERFLOW | FE_INVALID);
+ * if (raised & FE_OVERFLOW) { ... }
+ * if (raised & FE_INVALID) { ... }
+ * ...
+ * }
+ ***********************************************************/
+
+/* Get FPU rounding mode */
+#define fegetround() \
+({ \
+ unsigned int tmp; \
+ asm volatile("mov %0, SR" \
+ :"=l"(tmp) \
+ :/*no input*/); \
+ tmp &= (3<<13); \
+ (tmp); \
+})
+
+/* Set FPU rounding mode */
+#define fesetround(round) \
+({ \
+ unsigned int tmp = (3 << 13); \
+ while(1) { \
+ /* Clear SR.FRM field */ \
+ asm volatile("andn SR, %0" \
+ :/*no output*/ \
+ :"l"(tmp) ); \
+ tmp &= round; \
+ \
+ if(tmp) { \
+ tmp = -1; \
+ break; \
+ } \
+ \
+ asm volatile("or SR, %0" \
+ :/*no input*/ \
+ :"l"(round) ); \
+ tmp = 0; \
+ break; \
+ } \
+ (tmp); \
+})
+
+/* The following functions test for accrued exceptions.
+ * No trap is generated on an FP exception.
+ */
+static inline feclearexcept(int __excepts)
+{
+ unsigned int enabled_excepts, disabled_excepts;
+
+ /* Check that __excepts is correctly set */
+ if( __excepts & (~0x1F00) )
+ return -1;
+
+ asm volatile("mov %0, SR"
+ :"=l"(enabled_excepts)
+ :/*no input*/ );
+
+ enabled_excepts &= 0x1F00;
+ disabled_excepts = ~enabled_excepts;
+ disabled_excepts &= 0x1F00;
+
+ enabled_excepts &= __excepts;
+ disabled_excepts &= __excepts;
+
+ /* Clear accrued exceptions */
+ asm volatile("andn G2, %0\n\t"
+ "andn G2, %1\n\t"
+ :/*no output*/
+ :"l"(enabled_excepts),
+ "l"(disabled_excepts >> 8) );
+ return 0;
+}
+
+/* fetestexcepts tests both for actual and accrued
+ * excepts. You can test for an exception either after
+ * an FP instruction or within a SIGFPE handler
+ */
+inline int fetestexcept(int __excepts)
+{
+ unsigned int G2, G2en, G2dis;
+ unsigned int enabled_excepts, disabled_excepts;
+
+ /* Check that __excepts is correctly set */
+ if( __excepts & (~0x1F00) )
+ return -1;
+
+ asm volatile("mov %0, SR"
+ :"=l"(enabled_excepts)
+ :/*no input*/ );
+
+ enabled_excepts &= 0x1F00;
+ disabled_excepts = ~enabled_excepts;
+ disabled_excepts &= 0x1F00;
+
+ asm volatile("mov %0, G2"
+ :"=l"(G2)
+ :/*no input*/ );
+
+ G2en = G2 & 0x1F00;
+ G2dis = G2 & 0x1F;
+ G2en &= enabled_excepts;
+ G2dis &= (disabled_excepts >> 8);
+ return ( G2en | (G2dis << 8) );
+}
+
+static inline int feraiseexcept(int __excepts)
+{
+ asm volatile("or G2, %0"
+ :/*no output*/
+ :"l"( __excepts >> 8 ) );
+ return 0;
+}
+
+/* The following functions enable/disable individual exceptions.
+ * If enabling an exception trap is going to occur, in case of error.
+ */
+#define feenableexcept(__excepts) \
+({ \
+ int __retval, __pexcepts; \
+ int __tmpexcepts = __excepts; \
+ \
+ while(1) { \
+ asm volatile("mov %0, SR" \
+ :"=l"(__pexcepts) \
+ :/*no input*/ ); \
+ __pexcepts &= 0x1F00; \
+ \
+/* Check if __except values are valid */ \
+ if( __tmpexcepts & ~0x1F00 ) { \
+ __retval = -1; \
+ fprintf(stderr,"Non valid excepts\n");\
+ break; \
+ } \
+ \
+ asm volatile("or SR, %0" \
+ :/*no output*/ \
+ :"l"(__tmpexcepts) ); \
+ __retval = __pexcepts; \
+ break; \
+ } \
+ (__retval); \
+})
+
+
+#define fedisableexcept(__excepts) \
+({ \
+ int __retval, __pexcepts; \
+ int __tmpexcepts = __excepts; \
+ \
+ while(1) { \
+ asm volatile("mov %0, SR" \
+ :"=l"(__pexcepts) \
+ :/*no input*/ ); \
+ __pexcepts &= 0x1F00; \
+ \
+/* Check if __except values are valid */ \
+ if( __tmpexcepts & ~0x1F00 ) { \
+ __retval = -1; \
+ fprintf(stderr,"Non valid excepts\n");\
+ break; \
+ } \
+ \
+ asm volatile("andn SR, %0" \
+ :/*no output*/ \
+ :"l"(__tmpexcepts) ); \
+ __retval = __pexcepts; \
+ break; \
+ } \
+ (__retval); \
+})
+
+static inline int fegetexcept(int excepts)
+{
+ unsigned int tmp;
+ asm volatile("mov %0, SR"
+ :"=l"(tmp)
+ :/*no input*/ );
+ tmp &= 0x1F00;
+ return tmp;
+}
+
+static inline int fegetenv(fenv_t *envp)
+{
+ asm volatile("mov %0, SR\n\t
+ mov %1, SR\n\t
+ mov %2, G2\n\t
+ mov %3, G2\n\t"
+ :"=l"(envp->round_mode),
+ "=l"(envp->trap_enabled),
+ "=l"(envp->accrued_except),
+ "=l"(envp->actual_except)
+ :/*no input*/ );
+ envp->round_mode &= (3<<13);
+ envp->trap_enabled &= 0x1F00;
+ envp->accrued_except &= 0x1F;
+ envp->accrued_except <<= 8;
+ envp->actual_except &= 0x1F00;
+}
+
+#define feholdexcept(envp) \
+( \
+ fegetenv(envp); \
+ fedisableexcept(FE_ALL_EXCEPT); \
+ feclearexcept(FE_ALL_EXCEPT); \
+ (0); \
+)
+
+#define fesetenv(envp) \
+({ \
+ /* Clear FRM & FTE field of SR */ \
+ unsigned long clearSR = ( 127<<8 ); \
+ asm volatile("andn SR, %0\n\t" \
+ "or SR, %1\n\t" \
+ "or SR, %2\n\t" \
+ :/*no output*/ \
+ :"l"(clearSR), \
+ "l"(envp->round_mode), \
+ "l"(envp->trap_enabled) ); \
+ asm volatile("andn G2, 0x1F1F\n\t" \
+ "or G2, %0\n\t" \
+ "or G2, %1\n\t" \
+ :/*no output*/ \
+ :"l"( envp->accrued_except >> 8),\
+ :"l"( envp->actual_except ) ); \
+ (0); /* return 0 */ \
+})
+
+#define feupdateenv(envp) \
+({ \
+ /* Clear FRM & FTE field of SR */ \
+ asm volatile(/* We dont clear the prev SR*/ \
+ "or SR, %1\n\t" \
+ "or SR, %2\n\t" \
+ :/*no output*/ \
+ :"l"(clearSR), \
+ "l"(envp->round_mode), \
+ "l"(envp->accrued_except) ); \
+ asm volatile(/* We dont clear the prev SR*/ \
+ "or G2, %0\n\t" \
+ "or G2, %1\n\t" \
+ :/*no output*/ \
+ :"l"( envp->accrued_except >> 8),\
+ :"l"( envp->actual_except ) ); \
+ (0); /* return 0 */ \
+})
+
+
+#endif /* __GNUC__ && !_SOFT_FLOAT */
+
diff --git a/libc/sysdeps/linux/e1/bits/kernel_stat.h b/libc/sysdeps/linux/e1/bits/kernel_stat.h
new file mode 100644
index 000000000..4bcc0fe3a
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/kernel_stat.h
@@ -0,0 +1,57 @@
+#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... */
+#warning "Please verify struct kernel_stat for your architecture actually matches struct kernel_stat for x86 If it doesn't, then you will need to add a proper kernel_stat.h for your architecture..."
+
+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;
+ unsigned long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ 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 */
+ unsigned long st_atime;
+ unsigned long __pad5;
+ unsigned long st_mtime;
+ unsigned long __pad6;
+ unsigned long st_ctime;
+ unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ unsigned long long st_ino;
+};
+
+#endif /* _BITS_STAT_STRUCT_H */
+
diff --git a/libc/sysdeps/linux/e1/bits/kernel_types.h b/libc/sysdeps/linux/e1/bits/kernel_types.h
new file mode 100644
index 000000000..129455412
--- /dev/null
+++ b/libc/sysdeps/linux/e1/bits/kernel_types.h
@@ -0,0 +1,45 @@
+/* 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 __ARCH_E1_POSIX_TYPES_H
+#define __ARCH_E1_POSIX_TYPES_H
+
+typedef unsigned short __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 long long __kernel_loff_t;
+
+/*
<