summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sh/pipe.c
blob: e4cc0080d8d85bc445067278d87b963d7a1d5eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (C) 2001 Lineo, <davidm@lineo.com>
 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */

#include <errno.h>
#include <unistd.h>
#include <syscall.h>

libc_hidden_proto(pipe)

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);
}
libc_hidden_def(pipe)