Skip to content

Commit 8ec4d73

Browse files
committed
Add Include/internal/pycore_mmap.h
1 parent a680677 commit 8ec4d73

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Include/internal/pycore_mmap.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef Py_INTERNAL_MMAP_H
2+
#define Py_INTERNAL_MMAP_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
#ifndef Py_BUILD_CORE
9+
# error "this header requires Py_BUILD_CORE define"
10+
#endif
11+
12+
#if defined(Py_DEBUG) && defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
13+
# include <linux/prctl.h>
14+
# include <sys/prctl.h>
15+
#endif
16+
17+
static inline int
18+
_PyAnnotateMemoryMap(void *addr, size_t size, const char *name)
19+
{
20+
#if defined(Py_DEBUG) && defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
21+
assert(strlen(name) < 80);
22+
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);
23+
// Ignore errno from prctl
24+
// See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746
25+
errno = 0;
26+
#endif
27+
return 0;
28+
}
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
#endif // !Py_INTERNAL_MMAP_H

0 commit comments

Comments
 (0)