| 1 | #ifndef __PYWHERE_H |
| 2 | #define __PYWHERE_H |
| 3 | |
| 4 | #include <atomic> |
| 5 | #include <string> |
| 6 | |
| 7 | /** |
| 8 | * Examines the current Python stack frame and let us know where in the code we |
| 9 | * are. |
| 10 | */ |
| 11 | extern "C" int whereInPython(std::string& filename, int& lineno, int& bytei); |
| 12 | |
| 13 | /** |
| 14 | * Pointer to "whereInPython" for efficient linkage between pywhere and |
| 15 | * libscalene. |
| 16 | */ |
| 17 | extern "C" std::atomic<decltype(whereInPython)*> p_whereInPython; |
| 18 | |
| 19 | extern "C" std::atomic<bool> p_scalene_done; |
| 20 | |
| 21 | /** |
| 22 | * Returns whether the Python interpreter was detected. |
| 23 | * It's possible (and in fact happens for any fork/exec from within Python, |
| 24 | * given the preload environment variables) for libscalene to be preloaded onto |
| 25 | * a different executable. |
| 26 | */ |
| 27 | inline bool pythonDetected() { return p_whereInPython != nullptr; } |
| 28 | #endif |