summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/mips/pipe.c
blob: bfca4b60d66f3d88b1f5d67b10dbb87ce42c6277 (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
/* pipe system call for Linux/MIPS */
/*
 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */
/*see uClibc's sh/pipe.c and glibc-2.2.4's mips/pipe.S */

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

libc_hidden_proto(pipe)

int pipe(int *fd)
{
    register long int res __asm__ ("$2"); // v0
    register long int res2 __asm__ ("$3"); // v1

    asm ("move\t$4,%2\n\t"		// $4 = a0
	 "syscall"		/* Perform the system call.  */
	 : "=r" (res)
	 : "0" (__NR_pipe), "r" (fd)
	 : "$4", "$7");

	fd[0] = res;
	fd[1] = res2;
	return(0);
}
libc_hidden_def(pipe)