Nits for rust release (#419)

* adjust gitignore

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* also add prefix for rust objects

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* export statistics api for rust

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* conform clang-format-9

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>
This commit is contained in:
Schrodinger ZHU Yifan
2021-11-18 00:02:47 +08:00
committed by GitHub
parent dc542cdc9d
commit cd0311b26f
2 changed files with 27 additions and 5 deletions

12
.gitignore vendored
View File

@@ -1,8 +1,20 @@
# conventional build dirs
release*/
debug*/
build*/
cmake-build-*/
# cmake intermediate files
CMakeFiles/
# vscode dirs
.vscode/
.vs/
# jetbrains IDE dirs
.idea/
# special endings
*~
*.sw?

View File

@@ -9,25 +9,26 @@
using namespace snmalloc;
extern "C" SNMALLOC_EXPORT void* rust_alloc(size_t alignment, size_t size)
extern "C" SNMALLOC_EXPORT void*
SNMALLOC_NAME_MANGLE(rust_alloc)(size_t alignment, size_t size)
{
return ThreadAlloc::get().alloc(aligned_size(alignment, size));
}
extern "C" SNMALLOC_EXPORT void*
rust_alloc_zeroed(size_t alignment, size_t size)
SNMALLOC_NAME_MANGLE(rust_alloc_zeroed)(size_t alignment, size_t size)
{
return ThreadAlloc::get().alloc<YesZero>(aligned_size(alignment, size));
}
extern "C" SNMALLOC_EXPORT void
rust_dealloc(void* ptr, size_t alignment, size_t size)
SNMALLOC_NAME_MANGLE(rust_dealloc)(void* ptr, size_t alignment, size_t size)
{
ThreadAlloc::get().dealloc(ptr, aligned_size(alignment, size));
}
extern "C" SNMALLOC_EXPORT void*
rust_realloc(void* ptr, size_t alignment, size_t old_size, size_t new_size)
extern "C" SNMALLOC_EXPORT void* SNMALLOC_NAME_MANGLE(rust_realloc)(
void* ptr, size_t alignment, size_t old_size, size_t new_size)
{
size_t aligned_old_size = aligned_size(alignment, old_size),
aligned_new_size = aligned_size(alignment, new_size);
@@ -43,3 +44,12 @@ rust_realloc(void* ptr, size_t alignment, size_t old_size, size_t new_size)
}
return p;
}
extern "C" SNMALLOC_EXPORT void SNMALLOC_NAME_MANGLE(rust_statistics)(
size_t* current_memory_usage, size_t* peak_memory_usage)
{
auto unused_chunks = Globals::get_chunk_allocator_state().unused_memory();
auto peak = Globals::get_chunk_allocator_state().peak_memory_usage();
*current_memory_usage = peak - unused_chunks;
*peak_memory_usage = peak;
}