-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1823 from deantvv/ffi-cleanup
ffi cleanup: pylifecycle to pystate
- Loading branch information
Showing
7 changed files
with
71 additions
and
57 deletions.
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
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,46 @@ | ||
use libc::size_t; | ||
use std::os::raw::c_void; | ||
|
||
extern "C" { | ||
#[cfg_attr(PyPy, link_name = "PyPyMem_RawMalloc")] | ||
pub fn PyMem_RawMalloc(size: size_t) -> *mut c_void; | ||
#[cfg_attr(PyPy, link_name = "PyPyMem_RawCalloc")] | ||
pub fn PyMem_RawCalloc(nelem: size_t, elsize: size_t) -> *mut c_void; | ||
#[cfg_attr(PyPy, link_name = "PyPyMem_RawRealloc")] | ||
pub fn PyMem_RawRealloc(ptr: *mut c_void, new_size: size_t) -> *mut c_void; | ||
#[cfg_attr(PyPy, link_name = "PyPyMem_RawFree")] | ||
pub fn PyMem_RawFree(ptr: *mut c_void); | ||
|
||
// skipped _PyMem_GetCurrentAllocatorName | ||
// skipped _PyMem_RawStrdup | ||
// skipped _PyMem_Strdup | ||
// skipped _PyMem_RawWcsdup | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone)] | ||
pub enum PyMemAllocatorDomain { | ||
PYMEM_DOMAIN_RAW, | ||
PYMEM_DOMAIN_MEM, | ||
PYMEM_DOMAIN_OBJ, | ||
} | ||
|
||
// skipped PyMemAllocatorName | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone)] | ||
pub struct PyMemAllocatorEx { | ||
pub ctx: *mut c_void, | ||
pub malloc: Option<extern "C" fn(ctx: *mut c_void, size: size_t) -> *mut c_void>, | ||
pub calloc: | ||
Option<extern "C" fn(ctx: *mut c_void, nelem: size_t, elsize: size_t) -> *mut c_void>, | ||
pub realloc: | ||
Option<extern "C" fn(ctx: *mut c_void, ptr: *mut c_void, new_size: size_t) -> *mut c_void>, | ||
pub free: Option<extern "C" fn(ctx: *mut c_void, ptr: *mut c_void)>, | ||
} | ||
|
||
extern "C" { | ||
pub fn PyMem_GetAllocator(domain: PyMemAllocatorDomain, allocator: *mut PyMemAllocatorEx); | ||
pub fn PyMem_SetAllocator(domain: PyMemAllocatorDomain, allocator: *mut PyMemAllocatorEx); | ||
pub fn PyMem_SetupDebugHooks(); | ||
} |
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
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
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