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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#define __CHECK_RETURN_ADDR
#include <syscall.h>
#include <sys/types.h>
#include <sys/mman.h>
#define SYS__mmap SYS_mmap
#ifdef __sparc__
#if 0
_syscall6(caddr_t,mmap,caddr_t,addr,size_t,len,int,prot,int,flags,int,fd,off_t,off);
#endif
__ptr_t
mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, off_t off)
{
caddr_t __res;
__asm__ __volatile__("mov %1, %%o0\n\t"
"mov %2, %%o1\n\t"
"mov %3, %%o2\n\t"
"mov %4, %%o3\n\t"
"mov %5, %%o4\n\t"
"mov %6, %%o5\n\t"
"mov %7, %%g1\n\t"
"t 0x10\n\t"
"bcc 1f\n\t"
" mov %%o0, %0\n\t"
"sub %%g0, %%o0, %0\n\t"
"1:\n\t" :
"=r" (__res) :
"0" (addr), "r" (len), "r" (prot), "r" (flags),
"r" (fd), "r" (off), "i" (__NR_mmap) :
"g1", "o0", "o1", "o2", "o3", "o4", "o5");
return __res;
}
#else
static inline
_syscall1(long,_mmap,unsigned long *,buffer);
__ptr_t
mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, off_t off)
{
unsigned long buffer[6];
buffer[0] = (unsigned long)addr;
buffer[1] = (unsigned long)len;
buffer[2] = (unsigned long)prot;
buffer[3] = (unsigned long)flags;
buffer[4] = (unsigned long)fd;
buffer[5] = (unsigned long)off;
return (__ptr_t) _mmap(buffer);
}
#endif
|