Skip to content

Commit 805c539

Browse files
committed
Address code review
1 parent a240b3c commit 805c539

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Include/internal/pycore_mmap.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,29 @@ extern "C" {
1616
# include <sys/prctl.h>
1717
#endif
1818

19-
#if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__) && defined(Py_DEBUG)
20-
# define _PyAnnotateMemoryMap(addr, size, name) \
21-
do { \
22-
assert(strlen(name) < 80); \
23-
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)(addr), (size), (name)); \
24-
/* Ignore errno from prctl */ \
25-
/* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */ \
26-
errno = 0; \
27-
} while (0)
28-
#elif defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
29-
# define _PyAnnotateMemoryMap(addr, size, name) \
30-
do { \
31-
if (_Py_GetConfig()->dev_mode) { \
32-
assert(strlen(name) < 80); \
33-
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)(addr), (size), (name)); \
34-
/* Ignore errno from prctl */ \
35-
/* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */ \
36-
errno = 0; \
37-
} \
38-
} while (0)
19+
#if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
20+
static inline void
21+
_PyAnnotateMemoryMap(void *addr, size_t size, const char *name)
22+
{
23+
#ifndef Py_DEBUG
24+
if (!_Py_GetConfig()->dev_mode) {
25+
return;
26+
}
27+
#endif
28+
assert(strlen(name) < 80);
29+
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)(addr), size, name);
30+
/* Ignore errno from prctl */
31+
/* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */
32+
errno = 0;
33+
}
3934
#else
40-
# define _PyAnnotateMemoryMap(addr, size, name) ((void)0)
35+
static inline void
36+
_PyAnnotateMemoryMap(void *addr, size_t size, const char *name)
37+
{
38+
(void)addr;
39+
(void)size;
40+
(void)name;
41+
}
4142
#endif
4243

4344
#ifdef __cplusplus

0 commit comments

Comments
 (0)