-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a hook for the cinder interpreter loop in third-party/python/3.12
Summary: Add a hook for the cinder interpreter loop in third-party/python/3.12 * Add version guards to reflect the changed signature of `_PyFrameEvalFunction` between 3.10 and 3.12 * Link `cinderx/Interpreter:Interpreter3.12` into `cinderx:_cinderx-lib` * Add `Include/cinder/hooks.h` in `third-party/python/3.12` * Add a call to cinderx's `Ci_hook_EvalFrame` from `third-party/python/3.12` NOTE: The hook is currently not initialised, so that we can check this code in without all the runtime tests passing. This seems to be the best way to break the large diff up into smaller pieces. Reviewed By: jbower-fb Differential Revision: D62222196 fbshipit-source-id: 87384e77d40a67795f596c160c09c11de686f8f7
- Loading branch information
1 parent
f290b9e
commit 9b84a02
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
/* | ||
* Macros for marking components in core CPython we currently export for the | ||
* CinderX module. This includes things added by Cinder and things which | ||
* already existed but which weren't public. | ||
* | ||
* The intent is grepping for "CiAPI" reveals everything the CinderX module may | ||
* depend on in the core CPython code. Eliminating all of these is one of the | ||
* prerequisites for CinderX being compatible with non-Cinder Python. | ||
*/ | ||
|
||
// These function the same as PyAPI_* - exporting symbols for use in .so's etc. | ||
#define CiAPI_FUNC(RTYPE) __attribute__ ((visibility ("default"))) RTYPE | ||
#ifdef __clang__ | ||
# ifdef __cplusplus | ||
# define CiAPI_DATA(RTYPE) __attribute__ ((visibility ("default"))) extern "C" RTYPE | ||
# else | ||
# define CiAPI_DATA(RTYPE) __attribute__ ((visibility ("default"))) extern RTYPE | ||
# endif | ||
#else | ||
# ifdef __cplusplus | ||
# define CiAPI_DATA(RTYPE) extern "C" __attribute__ ((visibility ("default")))RTYPE | ||
# else | ||
# define CiAPI_DATA(RTYPE) extern __attribute__ ((visibility ("default"))) RTYPE | ||
# endif | ||
#endif | ||
|
||
// Clang seems to (always?) make symbols for static inline functions. | ||
#ifdef __clang__ | ||
# define CiAPI_STATIC_INLINE_FUNC(RTYPE) static inline __attribute__ ((visibility ("default"))) RTYPE | ||
#else | ||
# define CiAPI_STATIC_INLINE_FUNC(RTYPE) static inline RTYPE | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "cinder/ci_api.h" | ||
#include "pystate.h" // PyThreadState | ||
|
||
/* Hooks needed by CinderX that have not been added to upstream. */ | ||
|
||
CiAPI_DATA(_PyFrameEvalFunction) Ci_hook_EvalFrame; | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
#include "Python.h" | ||
#include "cinder/hooks.h" | ||
|
||
/* Interpreter */ | ||
_PyFrameEvalFunction Ci_hook_EvalFrame = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters