Skip to content

Commit 1893f4d

Browse files
committed
add guards for PyPy
1 parent 1c8c053 commit 1893f4d

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

src/vmp_stack.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
#include "vmprof.h"
1515
#include "compat.h"
1616

17-
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
18-
#include "internal/pycore_frame.h"
19-
#include "populate_frames.h"
20-
#endif
21-
2217
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
2318

2419
#if defined(VMPROF_LINUX) || defined(VMPROF_BSD)

src/vmp_stack.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
#include "vmprof.h"
44

5-
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
6-
#include "internal/pycore_frame.h"
7-
#include "populate_frames.h"
5+
#ifndef RPYTHON_VMPROF
6+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
7+
#include "internal/pycore_frame.h"
8+
#include "populate_frames.h"
9+
#endif
810
#endif
911

10-
#if PY_VERSION_HEX >= 0x030B0000 /* >= 3.11 */
12+
#if PY_VERSION_HEX >= 0x030B0000 && !defined(RPYTHON_VMPROF) /* >= 3.11 */
1113
int vmp_walk_and_record_stack(_PyInterpreterFrame * frame, void **data,
1214
int max_depth, int signal, intptr_t pc);
1315
#else

src/vmprof_unix.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "vmprof_unix.h"
22

3-
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
4-
#include "populate_frames.h"
3+
#ifndef RPYTHON_VMPROF
4+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
5+
#include "populate_frames.h"
6+
#endif
57
#endif
68

79
#ifdef VMPROF_UNIX
@@ -479,7 +481,7 @@ int vmprof_register_virtual_function(char *code_name, intptr_t code_uid,
479481
return 0;
480482
}
481483

482-
#if PY_VERSION_HEX < 0x030900B1 /* < 3.9 */
484+
#if PY_VERSION_HEX < 0x030900B1 && ! defined(RPYTHON_VMPROF) /* < 3.9 */
483485
static inline PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate)
484486
{
485487
Py_XINCREF(tstate->frame);
@@ -511,8 +513,8 @@ int get_stack_trace(PY_THREAD_STATE_T * current, void** result, int max_depth, i
511513
frame = PyThreadState_GetFrame(current);
512514
#endif
513515

516+
#endif /* RPYTHON_VMPROF */
514517

515-
#endif
516518
if (frame == NULL) {
517519
#if DEBUG
518520
fprintf(stderr, "WARNING: get_stack_trace, frame is NULL\n");
@@ -522,7 +524,7 @@ int get_stack_trace(PY_THREAD_STATE_T * current, void** result, int max_depth, i
522524

523525
int res = vmp_walk_and_record_stack(frame, result, max_depth, 1, pc);
524526

525-
#if PY_VERSION_HEX < 0x030B0000 /* < 3.11 */
527+
#if PY_VERSION_HEX < 0x030B0000 && ! defined(RPYTHON_VMPROF) /* < 3.11 */
526528
Py_XDECREF(frame);
527529
#endif
528530

src/vmprof_win.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include "vmprof_win.h"
22

3-
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
4-
#include "internal/pycore_frame.h"
5-
#include "populate_frames.h"
3+
#ifndef RPYTHON_VMPROF
4+
#if PY_VERSION_HEX >= 0x030b00f0 /* >= 3.11 */
5+
#include "internal/pycore_frame.h"
6+
#include "populate_frames.h"
7+
#endif
68
#endif
79

810
volatile int thread_started = 0;
@@ -58,7 +60,7 @@ int vmp_write_all(const char *buf, size_t bufsize)
5860
return 0;
5961
}
6062

61-
#if PY_VERSION_HEX < 0x030900B1 /* < 3.9 */
63+
#if PY_VERSION_HEX < 0x030900B1 && not defined(RPYTHON_VMPROF) /* < 3.9 */
6264
static inline PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate)
6365
{
6466
Py_XINCREF(tstate->frame);

0 commit comments

Comments
 (0)