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/>. */
+ 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."
#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 */
#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_NOFOLLOW 0400000 /* Do not follow links. */
+# 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.
# 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. */
-# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
-# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
-/* Unlike the asm/unistd.h kernel header file (which this is partly based on),
- * this file must be able to cope with PIC and non-PIC code. For some arches
- * there is no difference. For x86 (which has far too few registers) there is
- * a difference. Regardless, including asm/unistd.h is hereby officially
- * forbidden. Don't do it. It is bad for you.
- */
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /* avoid using res which is declared to be in register d0; \
- errno might expand to a function call and clobber it. */ \
- int __err = -(res); \
- errno = __err; \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
+#ifndef __ASSEMBLER__
-#define _syscall0(type, name) \
-type name(void) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %1,er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name) \
- : "cc"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#include <errno.h>
-#define _syscall1(type, name, atype, a) \
-type name(atype a) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a) \
- : "cc", "er1"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define ASMFMT_0()
+#define ASMFMT_1(arg1) \
+ , "g" ((unsigned long)arg1)
+#define ASMFMT_2(arg1, arg2) \
+ , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2)
+#define ASMFMT_3(arg1, arg2, arg3) \
+ , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2), "g" ((unsigned long)arg3)
+#define ASMFMT_4(arg1, arg2, arg3, arg4) \
+ , "g" ((unsigned long)arg1), "g" ((unsigned long)arg2), "g" ((unsigned long)arg3), "g" ((unsigned long)arg4)
+#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
+ , "g" (arg1), "g" (arg2), "g" (arg3), "g" (arg4)/*, "g" (arg5)*/
+#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ , "g" (arg1), "g" (arg2), "g" (arg3), "g" (arg4)/*, "g" (arg5), "g" (arg6)*/
-#define _syscall2(type, name, atype, a, btype, b) \
-type name(atype a, btype b) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b) \
- : "cc", "er1", "er2"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define SUBSTITUTE_ARGS_0 \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_1 \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_2 \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_3 \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_4 \
+ "mov.l %5, er4\n\t" \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_5 \
+ /*"mov.l %6, er5\n\t"*/ \
+ "mov.l %5, er4\n\t" \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
+#define SUBSTITUTE_ARGS_6 \
+ /*"mov.l %7, er6\n\t"*/ \
+ /*"mov.l %6, er5\n\t"*/ \
+ "mov.l %5, er4\n\t" \
+ "mov.l %4, er3\n\t" \
+ "mov.l %3, er2\n\t" \
+ "mov.l %2, er1\n\t" \
+ "mov.l %1, er0\n\t"
-#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
-type name(atype a, btype b, ctype c) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c) \
- : "cc", "er1", "er2", "er3"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+/* The _NCS variant allows non-constant syscall numbers. */
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ register long int er0 __asm__ ("er0"); \
+ __asm__ __volatile__ ( \
+ SUBSTITUTE_ARGS_##nr \
+ "trapa #0" \
+ : "=r" (er0) \
+ : "ir" (name) ASMFMT_##nr(args) \
+ : "memory" \
+ ); \
+ (int) er0; \
+ }) \
+)
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c, dtype d) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %5, er4\n\t" \
- "mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c), \
- "g" ((long)d) \
- : "cc", "er1", "er2", "er3", "er4"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ( \
- "mov.l er5,@-sp\n\t" \
- "mov.l %5, er4\n\t" \
- "mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "mov.l %6, er5\n\t" \
- "trapa #0\n\t" \
- "mov.l @sp+,er5\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c), \
- "g" ((long)d), \
- "m" ((long)e) \
- : "cc", "er1", "er2", "er3", "er4"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
#else
.h8300h
#endif
+/*
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+ char **argv, void (*app_init)(void), void (*app_fini)(void),
+ void (*rtld_fini)(void),void *stack_end attribute_unused)
+*/
.text
_start: /* put here so that references to _start work with elf-PIC */
- mov.l @(0,sp),er0 /* argc */
- mov.l @(4,sp),er1 /* argv */
- mov.l @(8,sp),er2 /* envp */
+ mov.l @sp+,er1 /* argc */
+ mov.l @sp+,er2 /* argv */
+ add.l #4,sp
+
#if !defined(__PIC__)
- jsr @___uClibc_main
+ mov.l sp, @-sp
+ sub.l er0,er0
+ mov.l er0,@-sp
+ mov.l #_fini,er0
+ mov.l er0,@-sp
+ mov.l #_init,er0
+ mov.l er0,@-sp
+ mov.l #main,er0
+ jsr @__uClibc_main
#else
- mov.l @(___uClibc_main@GOTOFF,er5),er3
+ mov.l sp, @-sp
+ sub.l er0,er0
+ mov.l er0,@-sp
+ mov.l @(_fini@GOTOFF,er5),er0
+ mov.l er0,@-sp
+ mov.l @(_init@GOTOFF,er5),er0
+ mov.l er0,@-sp
+ mov.l @(main@GOTOFF,er5),er0
+ mov.l @(__uClibc_main@GOTOFF,er5),er3
jsr @er3
#endif
/* Define a symbol for the first piece of initialized data. */
.data
- .globl __data_start
-__data_start:
+ .globl _data_start
+_data_start:
.long 0
.weak data_start
- data_start = __data_start
+ data_start = _data_start