1
0
mirror of https://github.com/ErnyTech/neomimalloc synced 2024-06-18 10:50:01 +02:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Ernesto Castellotti
330af5b9ca
libmimalloc-sys: Updated to v1.0.6 2019-08-17 10:39:46 +02:00
Ernesto Castellotti
3e35f5593f
c bindings: Update header to v1.0.6 2019-08-17 10:38:29 +02:00
Ernesto Castellotti
a3ef3650c6
libmimalloc-sys: Updated to v1.0.5 2019-07-17 16:17:15 +02:00
Ernesto Castellotti
09ae5e9879
c bindings: Update header to v1.0.5 2019-07-17 16:16:36 +02:00
Ernesto Castellotti
a455e21c9b Remove old submodule path 2019-07-11 17:37:19 +02:00
Ernesto Castellotti
534550839c c bindings: Update header to v1.0.3 2019-07-11 17:29:12 +02:00
Ernesto Castellotti
35e3ed8b1a dub.json: switch to separed C dependency design 2019-07-11 17:28:55 +02:00
Ernesto Castellotti
f3efa1f672
dub: clean the temporary folder instead of just the build folder 2019-07-05 15:06:11 +02:00
4 changed files with 177 additions and 116 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "source/mimalloc"]
path = source/mimalloc
url = https://github.com/microsoft/mimalloc

View File

@ -6,61 +6,8 @@
],
"copyright": "Copyright © 2019, Ernesto Castellotti <erny.castell@gmail.com>",
"license": "MPL-2.0",
"configurations": [
{
"name" : "standard",
"preBuildCommands-posix" : [
"cd $PACKAGE_DIR && git clone --recursive https://github.com/ErnyTech/neomimalloc || true",
"cd $PACKAGE_DIR/neomimalloc/source/mimalloc && rm -rf build && mkdir build && cd build && cmake -DMI_OVERRIDE=OFF .. && make"
],
"libs-posix" : [
":libmimalloc.a"
],
"lflags-posix" : [
"-L$PACKAGE_DIR/neomimalloc/source/mimalloc/build"
]
},
{
"name" : "secure",
"preBuildCommands-posix" : [
"cd $PACKAGE_DIR && git clone --recursive https://github.com/ErnyTech/neomimalloc || true",
"cd $PACKAGE_DIR/neomimalloc/source/mimalloc && rm -rf build && mkdir build && cd build && cmake -DMI_OVERRIDE=OFF -DMI_SECURE=ON .. && make"
],
"libs-posix" : [
":ibmimalloc-secure.a"
],
"lflags-posix" : [
"-L$PACKAGE_DIR/neomimalloc/source/mimalloc/build"
]
},
{
"name" : "override-malloc",
"preBuildCommands-posix" : [
"cd $PACKAGE_DIR && git clone --recursive https://github.com/ErnyTech/neomimalloc || true",
"cd $PACKAGE_DIR/neomimalloc/source/mimalloc && rm -rf build && mkdir build && cd build && cmake -DMI_OVERRIDE=ON .. && make"
],
"libs-posix" : [
":libmimalloc.a"
],
"lflags-posix" : [
"-L$PACKAGE_DIR/neomimalloc/source/mimalloc/build"
]
},
{
"name" : "override-malloc-secure",
"preBuildCommands-posix" : [
"cd $PACKAGE_DIR && git clone --recursive https://github.com/ErnyTech/neomimalloc || true",
"cd $PACKAGE_DIR/neomimalloc/source/mimalloc && rm -rf build && mkdir build && cd build && cmake -DMI_OVERRIDE=ON -DMI_SECURE=ON .. && make"
],
"libs-posix" : [
":ibmimalloc-secure.a"
],
"lflags-posix" : [
"-L$PACKAGE_DIR/neomimalloc/source/mimalloc/build"
]
},
{
"name" : "manual-link"
}
]
"systemDependencies" : "libc and thread support (e.g. glibc and pthread), to build also needs for cmake and a C toolchain",
"dependencies": {
"libmimalloc-sys": "==1.0.6"
}
}

@ -1 +0,0 @@
Subproject commit 1125271c2756ee1db1303918816fea35e08b3405

View File

@ -73,15 +73,16 @@ extern(C) {
/**
* Runtime options.
*/
enum mi_option_t {
mi_option_page_reset = 0, /** Reset page memory when it becomes free. */
mi_option_cache_reset = 1, /** Reset segment memory when a segment is cached. */
mi_option_pool_commit = 2, /** Commit segments in large pools. */
mi_option_secure = 3,
mi_option_show_stats = 4, /** Print statistics to stderr when the program is done. */
mi_option_show_errors = 5, /** Print error messages to stderr. */
mi_option_verbose = 6, /** Print verbose messages to stderr. */
_mi_option_last = 7
enum mi_option_t {
mi_option_show_stats = 0, /** Print statistics to stderr when the program is done. */
mi_option_show_errors = 1, /** Print error messages to stderr. */
mi_option_verbose = 2, /** Print verbose messages to stderr. */
mi_option_secure = 3, /** Experimental*/
mi_option_pool_commit = 4, /** Experimental: Commit segments in large pools. */
mi_option_large_os_pages = 5, /** Experimental: Use large os pages */
mi_option_page_reset = 6, /** Experimental: Reset page memory when it becomes free. */
mi_option_cache_reset = 7, /** Experimental: Reset segment memory when a segment is cached. */
_mi_option_last = 8
}
/**
@ -174,32 +175,6 @@ extern(C) {
* Pointer to newly allocated zero initialized memory, or NULL if out of memory.
*/
@nogc pure @system nothrow void* mi_zalloc(size_t size);
/**
* Reallocate memory to newsize bytes, with extra memory initialized to zero.
*
* Params:
* p = Pointer to a previously allocated block (or NULL).
* newsize = The new required size in bytes.
*
* Returns:
* A pointer to a re-allocated block of newsize bytes, or NULL if out of memory.
*
* If the newsize is larger than the original allocated size of p, the extra bytes are initialized to zero.
*/
@nogc pure @system nothrow void* mi_rezalloc(void* p, size_t newsize);
/**
* Re-allocate memory to newsize bytes.
*
* Params:
* p = pointer to previously allocated memory (or NULL).
* newsize = the new required size in bytes.
*
* Returns:
* pointer to the re-allocated memory of newsize bytes, or NULL if out of memory. If NULL is returned, the pointer p is not freed. Otherwise the original pointer is either freed or returned as the reallocated result (in case it fits in-place with the new size). If the pointer p is NULL, it behaves as mi_malloc(newsize). If newsize is larger than the original size allocated for p, the bytes after size are uninitialized.
*/
@nogc pure @system nothrow void* mi_recalloc(void* p, size_t count, size_t size);
/**
* Try to re-allocate memory to newsize bytes in place.
@ -339,6 +314,12 @@ extern(C) {
*/
@nogc @system nothrow void mi_stats_reset();
/**
* Get mimalloc version
*/
@nogc pure @system nothrow int mi_version();
/**
* Initialize mimalloc on a process
*/
@ -436,26 +417,6 @@ extern(C) {
* Re-allocate memory to newsize bytes aligned by alignment at a specified offset.
*/
@nogc pure @system nothrow void* mi_realloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
/**
* Reallocate memory to newsize bytes, with extra memory initialized to zero aligned by alignment.
*/
@nogc pure @system nothrow void* mi_rezalloc_aligned(void* p, size_t newsize, size_t alignment);
/**
* Reallocate memory to newsize bytes, with extra memory initialized to zero aligned by alignment at a specified offset.
*/
@nogc pure @system nothrow void* mi_rezalloc_aligned_at(void* p, size_t newsize, size_t alignment, size_t offset);
/**
* Re-allocate memory to newsize bytes aligned by alignment.
*/
@nogc pure @system nothrow void* mi_recalloc_aligned(void* p, size_t count, size_t size, size_t alignment);
/**
* Re-allocate memory to newsize bytes aligned by alignment at a specified offset.
*/
@nogc pure @system nothrow void* mi_recalloc_aligned_at(void* p, size_t count, size_t size, size_t alignment, size_t offset);
/**
* Create a new heap that can be used for allocation.
@ -535,6 +496,21 @@ extern(C) {
* Allocate a small object in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_malloc_small(mi_heap_t* heap, size_t size);
/**
* Re-allocate memory to newsize bytes in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_realloc(mi_heap_t* heap, void* p, size_t newsize);
/**
* Re-allocate memory to count elements of size bytes in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_reallocn(mi_heap_t* heap, void* p, size_t count, size_t size);
/**
* Re-allocate memory to newsize bytes in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_reallocf(mi_heap_t* heap, void* p, size_t newsize);
/**
* Duplicate a string in a specific heap.
@ -550,6 +526,46 @@ extern(C) {
* Resolve a file path name using a specific heap to allocate the result.
*/
@nogc pure @system nothrow char* mi_heap_realpath(mi_heap_t* heap, const(char)* fname, char* resolved_name);
/**
* Allocate size bytes aligned by alignment in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_malloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
/**
* Allocate size bytes aligned by alignment at a specified offset in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_malloc_aligned_at(mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
/**
* Allocate zero-initialized size bytes aligned by alignment in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_zalloc_aligned(mi_heap_t* heap, size_t size, size_t alignment);
/**
* Allocate zero-initialized size bytes aligned by alignment at a specified offset in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_zalloc_aligned_at (mi_heap_t* heap, size_t size, size_t alignment, size_t offset);
/**
* Allocate zero-initialized count elements of size bytes aligned by alignment in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_calloc_aligned(mi_heap_t* heap, size_t count, size_t size, size_t alignment);
/**
* Allocate zero-initialized count elements of size bytes aligned by alignment at a specified offset in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_calloc_aligned_at(mi_heap_t* heap, size_t count, size_t size, size_t alignment, size_t offset);
/**
* Re-allocate memory to newsize bytes aligned by alignment in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_realloc_aligned(mi_heap_t* heap, void* p, size_t newsize, size_t alignment);
/**
* Re-allocate memory to newsize bytes aligned by alignment at a specified offset in a specific heap.
*/
@nogc pure @system nothrow void* mi_heap_realloc_aligned_at(mi_heap_t* heap, void* p, size_t newsize, size_t alignment, size_t offset);
/**
* Does a heap contain a pointer to a previously allocated block?
@ -604,6 +620,11 @@ extern(C) {
*/
@nogc pure @system nothrow bool mi_heap_visit_blocks(const(mi_heap_t)* heap, bool visit_all_blocks, mi_block_visit_fun visitor, const(void)* arg);
/**
* Inspect the heap at runtime.
*/
@nogc pure @system nothrow bool mi_is_in_heap_region(const(void)* p);
/**
* Set runtime behavior.
*/
@ -633,4 +654,101 @@ extern(C) {
* Set runtime behavior.
*/
@nogc @system nothrow void mi_option_set_default(mi_option_t option, c_long value);
/**
* Re-allocate memory to newsize bytes.
*
* Params:
* p = pointer to previously allocated memory (or NULL).
* newsize = the new required size in bytes.
*
* Returns:
* pointer to the re-allocated memory of newsize bytes, or NULL if out of memory. If NULL is returned, the pointer p is not freed. Otherwise the original pointer is either freed or returned as the reallocated result (in case it fits in-place with the new size). If the pointer p is NULL, it behaves as mi_malloc(newsize). If newsize is larger than the original size allocated for p, the bytes after size are uninitialized.
*/
@nogc pure @system nothrow void* mi_recalloc(void* p, size_t count, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow size_t mi_malloc_size(const(void)* p);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow size_t mi_malloc_usable_size(const(void)* p);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow size_t mi_cfree(void* p);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow int mi_posix_memalign(void** p, size_t alignment, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow int mi__posix_memalign(void** p, size_t alignment, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_memalign(size_t alignment, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_valloc(size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_pvalloc(size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_aligned_alloc(size_t alignment, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_reallocarray(void* p, size_t count, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void mi_free_size(void* p, size_t size);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void mi_free_size_aligned(void* p, size_t size, size_t alignment);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void mi_free_aligned(void* p, size_t alignment);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system void* mi_new(size_t n);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system void* mi_new_aligned(size_t n, size_t alignment);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_new_nothrow(size_t n);
/**
* mi prefixed implementations of various posix, unix, and C++ allocation functions
*/
@nogc pure @system nothrow void* mi_new_aligned_nothrow(size_t n, size_t alignment);
}