mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Wrap code in #if defined(_WIN32)
This commit is contained in:
@ -46,7 +46,8 @@ extern "C" {
|
|||||||
|
|
||||||
#elif IS_PYTHON_3_14_PLUS && defined(_WIN32)
|
#elif IS_PYTHON_3_14_PLUS && defined(_WIN32)
|
||||||
|
|
||||||
#define F_CODE(x) ((PyCodeObject*)Torch_PyStackRef_AsPyObjectBorrow(&x->f_executable))
|
#define F_CODE(x) \
|
||||||
|
((PyCodeObject*)Torch_PyStackRef_AsPyObjectBorrow(&x->f_executable))
|
||||||
#define PREV_INSTR(x) (x)->instr_ptr
|
#define PREV_INSTR(x) (x)->instr_ptr
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
// initializers that are not supported in older C++ standards, but is supported
|
// initializers that are not supported in older C++ standards, but is supported
|
||||||
// in C.
|
// in C.
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#define Py_BUILD_CORE
|
#define Py_BUILD_CORE
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <internal/pycore_stackref.h>
|
#include <internal/pycore_stackref.h>
|
||||||
@ -16,4 +18,6 @@
|
|||||||
PyObject* Torch_PyStackRef_AsPyObjectBorrow(void* stackref) {
|
PyObject* Torch_PyStackRef_AsPyObjectBorrow(void* stackref) {
|
||||||
_PyStackRef *sr = (_PyStackRef*)stackref;
|
_PyStackRef *sr = (_PyStackRef*)stackref;
|
||||||
return PyStackRef_AsPyObjectBorrow(*sr);
|
return PyStackRef_AsPyObjectBorrow(*sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // __cplusplus
|
#endif
|
||||||
|
|
||||||
// Use a void* to avoid exposing the internal _PyStackRef union on this
|
// Use a void* to avoid exposing the internal _PyStackRef union on this
|
||||||
// translation unit
|
// translation unit
|
||||||
@ -12,6 +12,6 @@ PyObject* Torch_PyStackRef_AsPyObjectBorrow(void* stackref);
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif // #ifdef __cplusplus
|
#endif
|
||||||
|
|
||||||
#endif // #ifdef _WIN32
|
#endif
|
||||||
|
Reference in New Issue
Block a user