5 ms·
If you have no threads at all, I would naively think it should be fairly simple to just stub out the locking and similar calls. Have you looked at dlmalloc, wh
by pm215 9y ago
If you have no threads at all, I would naively think it should be fairly simple to just stub out the locking and similar calls.
Have you looked at dlmalloc, which lets you build with USE_LOCKS=0 to turn off the threadsafety?
- saurik 9y agoThank you so much! I had stared at a few malloc implementations (both standalone and from a few libcs), and I had finally gotten to the point (after seeing how thouroughly integrated the threading often is, with not just atomic variables and locks but sometimes thread local storage) that I had largely given up on any implementation that even mentioned multithreading as a feature, but I clearly should have kept going: I just managed to get dlmalloc compiled using nothing but mmap, munmap, abort, memcpy, memset, sysconf (which should be fine), and time (which also should be fine). That just did not seem to be plausible with TCMalloc or jemalloc. Again: thanks so much!!
- justincormack 9y agoNetBSD and Musl libc are good sources for simpler implementations. From memory the NetBSD jemalloc is an early simple single file version that is pretty easy to adapt.