xref: /php-src/Zend/zend_mmap.h (revision ecc3fc18)
1 /*
2    +----------------------------------------------------------------------+
3    | This source file is subject to version 2.00 of the Zend license,     |
4    | that is bundled with this package in the file LICENSE, and is        |
5    | available through the world-wide-web at the following url:           |
6    | http://www.zend.com/license/2_00.txt.                                |
7    | If you did not receive a copy of the Zend license and are unable to  |
8    | obtain it through the world-wide-web, please send a note to          |
9    | license@zend.com so we can mail you a copy immediately.              |
10    +----------------------------------------------------------------------+
11    | Authors: Max Kellermann <max.kellermann@ionos.com>                   |
12    +----------------------------------------------------------------------+
13 */
14 
15 #ifndef ZEND_MMAP_H
16 #define ZEND_MMAP_H
17 
18 #include "zend_portability.h"
19 
20 #ifdef HAVE_PRCTL
21 # include <sys/prctl.h>
22 
23 /* fallback definitions if our libc is older than the kernel */
24 # ifndef PR_SET_VMA
25 #  define PR_SET_VMA 0x53564d41
26 # endif
27 # ifndef PR_SET_VMA_ANON_NAME
28 #  define PR_SET_VMA_ANON_NAME 0
29 # endif
30 #endif // HAVE_PRCTL
31 
32 /**
33  * Set a name for the specified memory area.
34  *
35  * This feature requires Linux 5.17.
36  */
zend_mmap_set_name(const void * start,size_t len,const char * name)37 static zend_always_inline void zend_mmap_set_name(const void *start, size_t len, const char *name)
38 {
39 #ifdef HAVE_PRCTL
40 	prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)start, len, (unsigned long)name);
41 #endif
42 }
43 
44 #endif /* ZEND_MMAP_H */
45