1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <sys/mman.h>
30
31 #include "header_checks.h"
32
sys_mman_h()33 static void sys_mman_h() {
34 MACRO(PROT_EXEC);
35 MACRO(PROT_NONE);
36 MACRO(PROT_READ);
37 MACRO(PROT_WRITE);
38
39 MACRO(MAP_FIXED);
40 MACRO(MAP_PRIVATE);
41 MACRO(MAP_SHARED);
42
43 MACRO(MS_ASYNC);
44 MACRO(MS_INVALIDATE);
45 MACRO(MS_SYNC);
46
47 MACRO(MCL_CURRENT);
48 MACRO(MCL_FUTURE);
49
50 void* p;
51 p = MAP_FAILED;
52
53 MACRO(POSIX_MADV_DONTNEED);
54 MACRO(POSIX_MADV_NORMAL);
55 MACRO(POSIX_MADV_RANDOM);
56 MACRO(POSIX_MADV_SEQUENTIAL);
57 MACRO(POSIX_MADV_WILLNEED);
58
59 #if !defined(__linux__)
60 MACRO(POSIX_TYPED_MEM_ALLOCATE);
61 MACRO(POSIX_TYPED_MEM_ALLOCATE_CONTIG);
62 MACRO(POSIX_TYPED_MEM_ALLOCATABLE);
63 #endif
64
65 TYPE(mode_t);
66 TYPE(off_t);
67 TYPE(size_t);
68
69 #if !defined(__linux__)
70 TYPE(struct posix_typed_mem_info);
71 STRUCT_MEMBER(struct posix_typed_mem_info, size_t, posix_tmi_length);
72 #endif
73
74 FUNCTION(mlock, int (*f)(const void*, size_t));
75 FUNCTION(mlockall, int (*f)(int));
76 FUNCTION(mmap, void* (*f)(void*, size_t, int, int, int, off_t));
77 FUNCTION(mprotect, int (*f)(void*, size_t, int));
78 FUNCTION(msync, int (*f)(void*, size_t, int));
79 FUNCTION(munlock, int (*f)(const void*, size_t));
80 FUNCTION(munlockall, int (*f)(void));
81 FUNCTION(munmap, int (*f)(void*, size_t));
82 FUNCTION(posix_madvise, int (*f)(void*, size_t, int));
83 #if !defined(__linux__)
84 FUNCTION(posix_mem_offset, int (*f)(const void*, size_t, off_t*, size_t*, int*));
85 FUNCTION(posix_typed_mem_get_info, int (*f)(int, struct posix_typed_mem_info*));
86 FUNCTION(posix_typed_mem_open, int (*f)(const char*, int, int));
87 #endif
88 #if !defined(__BIONIC__) // Disallowed by SELinux, so not implemented.
89 FUNCTION(shm_open, int (*f)(const char*, int, mode_t));
90 FUNCTION(shm_unlink, int (*f)(const char*));
91 #endif
92 }
93