source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/mman/mmap.c@ 400

Last change on this file since 400 was 400, checked in by coas-nagasima, 5 years ago

ファイルヘッダーの更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 946 bytes
Line 
1#include <unistd.h>
2#include <sys/mman.h>
3#include <errno.h>
4#include <stdint.h>
5#include <limits.h>
6#include "syscall.h"
7#include "libc.h"
8
9static void dummy(void) { }
10weak_alias(dummy, __vm_wait);
11
12#define UNIT SYSCALL_MMAP2_UNIT
13#define OFF_MASK ((-0x2000ULL << (8*sizeof(syscall_arg_t)-1)) | (UNIT-1))
14
15void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
16{
17 long ret;
18 if (off & OFF_MASK) {
19 errno = EINVAL;
20 return MAP_FAILED;
21 }
22 if (len >= PTRDIFF_MAX) {
23 errno = ENOMEM;
24 return MAP_FAILED;
25 }
26 if (flags & MAP_FIXED) {
27 __vm_wait();
28 }
29#ifdef SYS_mmap2
30 ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
31#else
32 ret = __syscall(SYS_mmap, start, len, prot, flags, fd, off);
33#endif
34 /* Fixup incorrect EPERM from kernel. */
35 if (ret == -EPERM && !start && (flags&MAP_ANON) && !(flags&MAP_FIXED))
36 ret = -ENOMEM;
37 return (void *)__syscall_ret(ret);
38}
39
40weak_alias(__mmap, mmap);
41
42LFS64(mmap);
Note: See TracBrowser for help on using the repository browser.