Fix warning ``warning: function declaration isn’t a prototype`` when
building mimalloc with ``-Wstrict-prototypes`` flag. In C argumentless
functions should be declared as ``func(void)``.
Reproducer:
```shell
$ cmake ../.. -DCMAKE_C_FLAGS="-Wstrict-prototypes"
$ make VERBOSE=1
```
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Neil Schemenauer <nas@arctrix.com>
Signed-off-by: Christian Heimes <christian@python.org>
When building some code against mimalloc with C inside Visual Studio
with ClangCL, the compiler complains about __GNUC__ being undefined.
Reported by Mojca Miklavec.
Close#422
Android's Bionic libc stores the thread ID in TLS slot 1 instead of 0
on 32-bit ARM and AArch64. Slot 0 contains a pointer to the ELF DTV
(Dynamic Thread Vector) instead, which is constant for each loaded DSO.
Because mimalloc uses the thread ID to determine whether operations are
thread-local or cross-thread (atomic), all threads having the same ID
causes internal data structures to get corrupted quickly when multiple
threads are using the allocator:
mimalloc: assertion failed: at "external/mimalloc/src/page.c":563, mi_page_extend_free
assertion: "page->local_free == NULL"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init
assertion: "page->used <= page->capacity"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":100, mi_page_is_valid_init
assertion: "page->used + free_count == page->capacity"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init
assertion: "page->used <= page->capacity"
Add support for Android's alternate TLS layout to fix the crashes in
multi-threaded use cases.
Fixes#376.
- For MI_STAT == 0 no allocation stats are collected
- For MI_STAT == 1 only aggregated values (across normal, large and huge heaps) are collected
- For MI_STAT == 1 separate per-bin collection for normal heap is done as well
Warnings happen normally and could be safely ignored in the most cases,
however errors, if enabled, should not be ignored. Currently since warnings
and errors share the same counter we effectively stop showing errors after
16 warnings (which happen all the time).
Use different counters for errors and warnings.
The pthread slot approach is somewhat buggy (pretty visible
with the stress unit test which segfault more or less randomly,
but the stats never show up).
Using the default approach instead, the test passes eventough
it s relatively slow (e.g 1.5 sec on FreeBSD vs 4.5 on DragonFly with same
machine).