From b13970685ad8102b897c8d5f17fb64aebdc9e602 Mon Sep 17 00:00:00 2001 From: Roman Kvasnytskyi Date: Tue, 2 Dec 2025 12:27:28 +0100 Subject: [PATCH] fix: Cleanup old INTERNA_API flag --- src/spprof/_ext/platform/darwin_mach.c | 4 --- src/spprof/_ext/signal_handler.c | 39 +++++++------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/spprof/_ext/platform/darwin_mach.c b/src/spprof/_ext/platform/darwin_mach.c index 337b08c..7eb00dc 100644 --- a/src/spprof/_ext/platform/darwin_mach.c +++ b/src/spprof/_ext/platform/darwin_mach.c @@ -59,9 +59,7 @@ #include "../code_registry.h" /* Internal API for Python frame capture */ -#ifdef SPPROF_USE_INTERNAL_API #include "../internal/pycore_tstate.h" -#endif /* Architecture-specific includes */ #if defined(__x86_64__) @@ -913,7 +911,6 @@ static void sample_all_threads(ThreadSnapshot* snapshot, MachSamplerState* state uintptr_t instr_ptrs[SPPROF_MAX_STACK_DEPTH]; int python_depth = 0; -#ifdef SPPROF_USE_INTERNAL_API /* Capture Python frames from the suspended thread's state. * This is safe because the target thread is suspended. */ python_depth = _spprof_capture_frames_with_instr_from_tstate( @@ -945,7 +942,6 @@ static void sample_all_threads(ThreadSnapshot* snapshot, MachSamplerState* state uint64_t gc_epoch = code_registry_get_gc_epoch(); code_registry_add_refs_batch(python_frames, python_depth, gc_epoch); } -#endif /* ================================================================ * Resume thread IMMEDIATELY after capture and INCREF diff --git a/src/spprof/_ext/signal_handler.c b/src/spprof/_ext/signal_handler.c index 919cd52..7bb40a9 100644 --- a/src/spprof/_ext/signal_handler.c +++ b/src/spprof/_ext/signal_handler.c @@ -77,10 +77,8 @@ * This file is still compiled on Darwin for compatibility but the signal * handler is not used. */ -#ifdef SPPROF_USE_INTERNAL_API #include "internal/pycore_frame.h" #include "internal/pycore_tstate.h" -#endif /* * FREE-THREADING SAFETY CHECK @@ -92,12 +90,10 @@ * Darwin uses Mach-based sampling (darwin_mach.c) which is safe. * This file is still compiled but the handler is effectively disabled. */ -#ifdef SPPROF_USE_INTERNAL_API #if !SPPROF_FREE_THREADING_SAFE /* Signal handler will return immediately without capturing frames */ #define SPPROF_SIGNAL_HANDLER_DISABLED 1 #endif -#endif /* * ============================================================================= @@ -209,17 +205,12 @@ static inline uint64_t get_thread_id_unsafe(void) { */ static inline int capture_python_stack_unsafe(uintptr_t* frames, int max_depth) { -#ifdef SPPROF_USE_INTERNAL_API - #if SPPROF_FREE_THREADED && defined(__linux__) - /* Free-threaded Linux: Use speculative capture with validation */ - return _spprof_capture_frames_speculative(frames, max_depth); - #else - /* GIL-enabled or Darwin (uses Mach sampler): Use direct capture */ - return _spprof_capture_frames_unsafe(frames, max_depth); - #endif +#if SPPROF_FREE_THREADED && defined(__linux__) + /* Free-threaded Linux: Use speculative capture with validation */ + return _spprof_capture_frames_speculative(frames, max_depth); #else - /* Fallback: use framewalker (may not be fully signal-safe) */ - return framewalker_capture_raw(frames, max_depth); + /* GIL-enabled or Darwin (uses Mach sampler): Use direct capture */ + return _spprof_capture_frames_unsafe(frames, max_depth); #endif } @@ -232,22 +223,12 @@ capture_python_stack_unsafe(uintptr_t* frames, int max_depth) { */ static inline int capture_python_stack_with_instr_unsafe(uintptr_t* frames, uintptr_t* instr_ptrs, int max_depth) { -#ifdef SPPROF_USE_INTERNAL_API - #if SPPROF_FREE_THREADED && defined(__linux__) - /* Free-threaded Linux: Use speculative capture with validation */ - return _spprof_capture_frames_with_instr_speculative(frames, instr_ptrs, max_depth); - #else - /* GIL-enabled or Darwin (uses Mach sampler): Use direct capture */ - return _spprof_capture_frames_with_instr_unsafe(frames, instr_ptrs, max_depth); - #endif +#if SPPROF_FREE_THREADED && defined(__linux__) + /* Free-threaded Linux: Use speculative capture with validation */ + return _spprof_capture_frames_with_instr_speculative(frames, instr_ptrs, max_depth); #else - /* Fallback: capture frames only, no instruction pointers */ - int depth = framewalker_capture_raw(frames, max_depth); - /* Zero out instruction pointers - resolver will use first line */ - for (int i = 0; i < depth; i++) { - instr_ptrs[i] = 0; - } - return depth; + /* GIL-enabled or Darwin (uses Mach sampler): Use direct capture */ + return _spprof_capture_frames_with_instr_unsafe(frames, instr_ptrs, max_depth); #endif }