summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/nios2/bits
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/nios2/bits')
-rw-r--r--libc/sysdeps/linux/nios2/bits/fcntl.h6
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_stat.h50
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_types.h6
-rw-r--r--libc/sysdeps/linux/nios2/bits/setjmp.h30
-rw-r--r--libc/sysdeps/linux/nios2/bits/stat.h167
-rw-r--r--libc/sysdeps/linux/nios2/bits/syscalls.h173
6 files changed, 95 insertions, 337 deletions
diff --git a/libc/sysdeps/linux/nios2/bits/fcntl.h b/libc/sysdeps/linux/nios2/bits/fcntl.h
index d8386d65c..4fe1ee396 100644
--- a/libc/sysdeps/linux/nios2/bits/fcntl.h
+++ b/libc/sysdeps/linux/nios2/bits/fcntl.h
@@ -44,9 +44,9 @@
#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_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_DIRECT 040000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
# define O_CLOEXEC 02000000 /* set close_on_exec */
# define O_PATH 010000000 /* Resolve pathname but do not open file. */
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_stat.h b/libc/sysdeps/linux/nios2/bits/kernel_stat.h
deleted file mode 100644
index 99a6cba97..000000000
--- a/libc/sysdeps/linux/nios2/bits/kernel_stat.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#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/libc/sysdeps/linux/nios2/bits/kernel_types.h b/libc/sysdeps/linux/nios2/bits/kernel_types.h
index 004f9c746..5c122b5b1 100644
--- a/libc/sysdeps/linux/nios2/bits/kernel_types.h
+++ b/libc/sysdeps/linux/nios2/bits/kernel_types.h
@@ -10,10 +10,10 @@
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 unsigned long __kernel_nlink_t;
typedef long __kernel_off_t;
typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
+typedef int __kernel_ipc_pid_t;
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
typedef unsigned int __kernel_size_t;
@@ -22,6 +22,8 @@ typedef int __kernel_ptrdiff_t;
typedef long __kernel_time_t;
typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t;
typedef unsigned short __kernel_uid16_t;
diff --git a/libc/sysdeps/linux/nios2/bits/setjmp.h b/libc/sysdeps/linux/nios2/bits/setjmp.h
index bc6f30848..2fbb39562 100644
--- a/libc/sysdeps/linux/nios2/bits/setjmp.h
+++ b/libc/sysdeps/linux/nios2/bits/setjmp.h
@@ -1,5 +1,5 @@
-/* Define the machine-dependent type `jmp_buf'. Nios2 version.
- Copyright (C) 1992,93,95,97,2000 Free Software Foundation, Inc.
+/* Define the machine-dependent type `jmp_buf'. Nios II version.
+ Copyright (C) 1992-2016 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
@@ -13,7 +13,7 @@
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, see
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
@@ -23,27 +23,9 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-typedef struct
-{
- /* Callee-saved registers r16 through r23. */
- unsigned long __regs[8];
+/* Saves r16-r22 (callee-saved, including GOT pointer), fp (frame pointer),
+ ra (return address), and sp (stack pointer). */
- /* 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 */
-#ifdef __UCLIBC_HAS_FPU__
- unsigned long __fpregs[64];
-#endif
-} __jmp_buf[1];
+typedef int __jmp_buf[10];
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/nios2/bits/stat.h b/libc/sysdeps/linux/nios2/bits/stat.h
deleted file mode 100644
index 6e3b0198c..000000000
--- a/libc/sysdeps/linux/nios2/bits/stat.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* 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, see
- <http://www.gnu.org/licenses/>. */
-
-#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/libc/sysdeps/linux/nios2/bits/syscalls.h b/libc/sysdeps/linux/nios2/bits/syscalls.h
index 5be5d4d86..2b12343a6 100644
--- a/libc/sysdeps/linux/nios2/bits/syscalls.h
+++ b/libc/sysdeps/linux/nios2/bits/syscalls.h
@@ -4,106 +4,97 @@
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#define TRAP_ID_SYSCALL 0
+#ifdef __ASSEMBLER__
-#ifndef __ASSEMBLER__
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ movi r2, SYS_ify(syscall_name); \
+ trap;
-#include <errno.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 DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 ldw r8, 0(sp);
+#define DOARGS_6 ldw r9, 4(sp); ldw r8, 0(sp);
-#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; \
- }) \
-)
+#else
-#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"
+#include <errno.h>
-#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"
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
-#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"
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
-#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"
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
-#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"
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ unsigned int _sys_result; \
+ { \
+ LOAD_ARGS_##nr (args) \
+ LOAD_REGS_##nr \
+ register int _r2 __asm__ ("r2") = (int)(name); \
+ register int _sys_err __asm__ ("r7"); \
+ __asm__ volatile ("trap" \
+ : "+r" (_r2), "=r" (_sys_err) \
+ : ASM_ARGS_##nr \
+ : "memory"); \
+ _sys_result = _r2; \
+ err = _sys_err; \
+ } \
+ (int) _sys_result; })
-#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"
+#define LOAD_ARGS_0()
+#define LOAD_REGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ LOAD_ARGS_0 () \
+ int __arg1 = (int) (a1);
+#define LOAD_REGS_1 \
+ register int _r4 __asm__ ("r4") = __arg1; \
+ LOAD_REGS_0
+#define ASM_ARGS_1 "r" (_r4)
+#define LOAD_ARGS_2(a1, a2) \
+ LOAD_ARGS_1 (a1) \
+ int __arg2 = (int) (a2);
+#define LOAD_REGS_2 \
+ register int _r5 __asm__ ("r5") = __arg2; \
+ LOAD_REGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_r5)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ LOAD_ARGS_2 (a1, a2) \
+ int __arg3 = (int) (a3);
+#define LOAD_REGS_3 \
+ register int _r6 __asm__ ("r6") = __arg3; \
+ LOAD_REGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_r6)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ int __arg4 = (int) (a4);
+#define LOAD_REGS_4 \
+ register int _r7 __asm__ ("r7") = __arg4; \
+ LOAD_REGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_r7)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ int __arg5 = (int) (a5);
+#define LOAD_REGS_5 \
+ register int _r8 __asm__ ("r8") = __arg5; \
+ LOAD_REGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_r8)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ int __arg6 = (int) (a6);
+#define LOAD_REGS_6 \
+ register int _r9 __asm__ ("r9") = __arg6; \
+ LOAD_REGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_r9)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */