File tree 5 files changed +37
-2
lines changed
5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 77
77
#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
78
78
#endif
79
79
80
- /* #define _POSIX_MEMORY_PROTECTION (-1L) */
80
+ #ifdef CONFIG_POSIX_MEMORY_PROTECTION
81
+ #define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
82
+ #endif
81
83
82
84
#ifdef CONFIG_POSIX_MESSAGE_PASSING
83
85
#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
Original file line number Diff line number Diff line change @@ -159,7 +159,8 @@ enum {
159
159
COND_CODE_1(CONFIG_POSIX_MEMLOCK, (_POSIX_MEMLOCK), (-1L))
160
160
#define __z_posix_sysconf_SC_MEMLOCK_RANGE \
161
161
COND_CODE_1(CONFIG_POSIX_MEMLOCK_RANGE, (_POSIX_MEMLOCK_RANGE), (-1L))
162
- #define __z_posix_sysconf_SC_MEMORY_PROTECTION (-1L)
162
+ #define __z_posix_sysconf_SC_MEMORY_PROTECTION \
163
+ COND_CODE_1(CONFIG_POSIX_MEMORY_PROTECTION, (_POSIX_MEMORY_PROTECTION), (-1L))
163
164
#define __z_posix_sysconf_SC_MESSAGE_PASSING \
164
165
COND_CODE_1(CONFIG_POSIX_MESSAGE_PASSING, (_POSIX_MESSAGE_PASSING), (-1L))
165
166
#define __z_posix_sysconf_SC_MONOTONIC_CLOCK \
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ zephyr_library_sources_ifdef(CONFIG_POSIX_FILE_SYSTEM fs.c)
53
53
zephyr_library_sources_ifdef(CONFIG_POSIX_FSYNC fsync.c)
54
54
zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK mlockall.c)
55
55
zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK_RANGE mlock.c)
56
+ zephyr_library_sources_ifdef(CONFIG_POSIX_MEMORY_PROTECTION mprotect.c)
56
57
zephyr_library_sources_ifdef(CONFIG_POSIX_MAPPED_FILES mmap.c)
57
58
zephyr_library_sources_ifdef(CONFIG_POSIX_MESSAGE_PASSING mqueue.c)
58
59
zephyr_library_sources_ifdef(CONFIG_POSIX_MULTI_PROCESS
Original file line number Diff line number Diff line change @@ -63,4 +63,14 @@ config POSIX_MEMLOCK_RANGE
63
63
64
64
endif
65
65
66
+ config POSIX_MEMORY_PROTECTION
67
+ bool "POSIX memory protection [EXPERIMENTAL]"
68
+ select EXPERIMENTAL
69
+ help
70
+ Select 'y' here and Zephyr will provide support for mprotect().
71
+
72
+ For more information, please see
73
+ https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/V2_chap02.html
74
+ https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_port.html#tag_24_03_04
75
+
66
76
endmenu
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2024, Tenstorrent AI ULC
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <errno.h>
8
+ #include <stddef.h>
9
+ #include <sys/types.h>
10
+
11
+ #include <zephyr/posix/sys/mman.h>
12
+
13
+ int mprotect (void * addr , size_t len , int prot )
14
+ {
15
+ ARG_UNUSED (addr );
16
+ ARG_UNUSED (len );
17
+ ARG_UNUSED (prot );
18
+
19
+ errno = ENOSYS ;
20
+ return -1 ;
21
+ }
You can’t perform that action at this time.
0 commit comments