From 6996c5c48239852d4bd398c8ee98fa1d5602cc7c Mon Sep 17 00:00:00 2001 From: David McCullough Date: Mon, 6 Aug 2001 12:46:12 +0000 Subject: Fixup the pipe system call for the SH target. The FD's are returned in registers. --- libc/sysdeps/linux/common/syscalls.c | 5 +++++ libc/sysdeps/linux/sh/Makefile | 2 +- libc/sysdeps/linux/sh/pipe.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 libc/sysdeps/linux/sh/pipe.c diff --git a/libc/sysdeps/linux/common/syscalls.c b/libc/sysdeps/linux/common/syscalls.c index e7da59b63..2d2062686 100644 --- a/libc/sysdeps/linux/common/syscalls.c +++ b/libc/sysdeps/linux/common/syscalls.c @@ -312,8 +312,13 @@ _syscall1(int, dup, int, oldfd); //#define __NR_pipe 42 #ifdef L_pipe #include +/* + * SH has a weird register calling mechanism for pipe, see pipe.c + */ +#if !defined(__sh__) _syscall1(int, pipe, int *, filedes); #endif +#endif //#define __NR_times 43 #ifdef L_times diff --git a/libc/sysdeps/linux/sh/Makefile b/libc/sysdeps/linux/sh/Makefile index f24856ade..4f76b49a5 100644 --- a/libc/sysdeps/linux/sh/Makefile +++ b/libc/sysdeps/linux/sh/Makefile @@ -35,7 +35,7 @@ CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0)) SSRC=setjmp.S bsd-setjmp.S bsd-_setjmp.S __longjmp.S vfork.S SOBJS=$(patsubst %.S,%.o, $(SSRC)) -CSRC=_mmap.c longjmp.c +CSRC=_mmap.c longjmp.c pipe.c COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(SOBJS) $(MOBJ) $(COBJS) diff --git a/libc/sysdeps/linux/sh/pipe.c b/libc/sysdeps/linux/sh/pipe.c new file mode 100644 index 000000000..1fb399afc --- /dev/null +++ b/libc/sysdeps/linux/sh/pipe.c @@ -0,0 +1,30 @@ + +/* Copyright (C) 2001 Lineo, */ + +#include +#include + +int pipe(int *fd) +{ + long __res, __res2; + __asm__ __volatile__ ( + "mov %2, r3;" + "mov %3, r4;" + "trapa #0x13;" + "mov r1, %1;" + : "=z" (__res), + "=r" ((long) __res2) + : "r" ((long) __NR_pipe), + "r" ((long) fd) + : "cc", "memory", "r1", "r3", "r4"); + if ((unsigned long)(__res) >= (unsigned long)(-125)) { + int __err = -(__res); + errno = __err; + return(-1); + } + fd[0] = __res; + fd[1] = __res2; + return(0); +} + + -- cgit v1.2.3