chiark / gitweb /
[PATCH] update klibc to version 0.181
[elogind.git] / klibc / klibc / arch / s390x / mmap.c
1 #include <sys/types.h>
2 #include <linux/unistd.h>
3
4 struct mmap_arg_struct {
5         unsigned long addr;
6         unsigned long len;
7         unsigned long prot;
8         unsigned long flags;
9         unsigned long fd;
10         unsigned long offset;
11 };
12
13 void * mmap(void * addr, size_t len, int prot, int flags,
14                                                  int fd, off_t offset)
15 {
16         struct mmap_arg_struct args = {
17                 (unsigned long) addr,
18                 (unsigned long) len,
19                 (unsigned long) prot,
20                 (unsigned long) flags,
21                 (unsigned long) fd,
22                 (unsigned long) offset,
23         };
24
25         register struct mmap_arg_struct *__arg1 asm("2") = &args;
26         register long __svcres asm("2");
27         unsigned long __res;
28
29         __asm__ __volatile__ (
30                 "    svc %b1\n"
31                 : "=d" (__svcres)
32                 : "i" (__NR_mmap),
33                   "0" (__arg1)
34                 : "1", "cc", "memory");
35         __res = __svcres;
36         if (__res >= (unsigned long)-125) {
37                 errno = -__res;
38                 __res = -1;
39         }
40         return (void *)__res;
41 }