Skip to content

Commit 33e10bf

Browse files
committed
Add a bunch of macros
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent e000d0e commit 33e10bf

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Objects/perf_trampoline.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ typedef enum {
149149
#include <sys/types.h>
150150
#include <unistd.h>
151151

152+
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
153+
#define PY_HAVE_INVALIDATE_ICACHE
154+
155+
#if defined(__clang__) || defined(__GNUC__)
156+
extern void __clear_cache(void *, void*);
157+
#endif
158+
159+
static void invalidate_icache(char* begin, char*end) {
160+
#if defined(__clang__) || defined(__GNUC__)
161+
return __clear_cache(begin, end);
162+
#else
163+
return;
164+
#endif
165+
}
166+
#endif
167+
152168
/* The function pointer is passed as last argument. The other three arguments
153169
* are passed in the same order as the function requires. This results in
154170
* shorter, more efficient ASM code for trampoline.
@@ -185,17 +201,9 @@ struct trampoline_api_st {
185201

186202
typedef struct trampoline_api_st trampoline_api_t;
187203

188-
#if defined(__clang__) || defined(__GNUC__)
189-
extern void __clear_cache(void *, void*);
190-
#endif
204+
#ifdef PY_HAVE_INVALIDATE_ICACHE
191205

192-
static void invalidate_icache(char* begin, char*end) {
193-
#if defined(__clang__) || defined(__GNUC__)
194-
return __clear_cache(begin, end);
195-
#else
196-
return;
197206
#endif
198-
}
199207

200208
static perf_status_t perf_status = PERF_STATUS_NO_INIT;
201209
static Py_ssize_t extra_code_index = -1;
@@ -319,7 +327,7 @@ new_code_arena(void)
319327
return -1;
320328
}
321329

322-
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
330+
#ifdef PY_HAVE_INVALIDATE_ICACHE
323331
// Before the JIT can run a block of code that has been emitted it must invalidate
324332
// the instruction cache on some platforms like arm and aarch64.
325333
invalidate_icache(memory, memory + mem_size);

0 commit comments

Comments
 (0)