Debian Codegraph @

share/libc/sys/mman.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef __FC_SYS_MMAN_H__
24 #define __FC_SYS_MMAN_H__
25
26 #include "../features.h"
27 #include "../__fc_define_mode_t.h"
28 #include "../__fc_define_off_t.h"
29 #include "../__fc_define_size_t.h"
30 __PUSH_FC_STDLIB
31 __BEGIN_DECLS
32
33 // The values for the constants below are based on an x86 Linux,
34 // declared in the order given by POSIX.1-2008.
35
36 #define PROT_EXEC 0x4
37 #define PROT_NONE 0x0
38 #define PROT_READ 0x1
39 #define PROT_WRITE 0x2
40
41 #define MAP_FIXED 0x10
42 #define MAP_PRIVATE 0x02
43 #define MAP_SHARED 0x01
44
45 // Non-POSIX, but used in some Linux code, so required for parsing
46 #define MAP_ANONYMOUS 0x20
47 #define MAP_ANON MAP_ANONYMOUS
48 #define MAP_SHARED_VALIDATE 0x03
49
50 #define MAP_FAILED ((void*) -1)
51
52 #define MS_ASYNC 1
53 #define MS_INVALIDATE 2
54 #define MS_SYNC 4
55
56 #define MCL_CURRENT 1
57 #define MCL_FUTURE 2
58
59 #define POSIX_MADV_DONTNEED 4
60 #define POSIX_MADV_NORMAL 0
61 #define POSIX_MADV_RANDOM 1
62 #define POSIX_MADV_SEQUENTIAL 2
63 #define POSIX_MADV_WILLNEED 3
64
65 // Not currently defined in any Linux header
66 //#define POSIX_TYPED_MEM_ALLOCATE
67 //#define POSIX_TYPED_MEM_ALLOCATE_CONTIG
68 //#define POSIX_TYPED_MEM_MAP_ALLOCATABLE
69 //
70 //struct posix_typed_mem_info {
71 // size_t posix_tmi_length;
72 //}
73
74 extern int mlock (const void *addr, size_t len);
75 extern int mlockall (int __flags);
76
77 extern void *mmap(void *addr, size_t len, int prot, int flags,
78 int fildes, off_t off);
79
80 extern int mprotect (void *__addr, size_t __len, int __prot);
81 extern int msync (void *__addr, size_t __len, int __flags);
82 extern int munlock (const void *__addr, size_t __len);
83 extern int munlockall (void);
84 extern int munmap (void *__addr, size_t __len);
85 extern int posix_madvise (void *__addr, size_t __len, int __advice);
86
87 // Not currently defined in any Linux header
88 //int posix_mem_offset(const void *restrict, size_t, off_t *restrict,
89 // size_t *restrict, int *restrict);
90 //int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
91 //int posix_typed_mem_open(const char *, int, int);
92
93 extern int shm_open (const char *__name, int __oflag, mode_t __mode);
94 extern int shm_unlink (const char *__name);
95
96 __END_DECLS
97 __POP_FC_STDLIB
98 #endif