Open josephholsten opened 2 years ago
This is quite important to support FreeBSD on aarch64, riscv which have not implemented sbrk()
Looks like the musl sbrk in @ryanwoodsmall branch is still relying on the brk syscall, which is not implemented in FreeBSD aarch64: https://cgit.freebsd.org/src/tree/lib/libc/aarch64/Symbol.map?id=0b51c11a0e75197a8791f6e635a08e36d5a42bd5
Looks like @edeemer is using a pool from malloc, so this should be preferred. I’ll test on FreeBSD now.
wrapping malloc is the right move here. my changes were as minimal as possible to get ex-vi building and functional with musl on linux and brk/sbrk were the path of least resistance.
The problem with malloc pool is that its address could change after realloc. So here comes the hacky part with shifting pointers to the pool. While I haven't seen any bugs (besides fixed in the second patch) for nearly-everyday use of my fork linked with musl, there was a rare case of segfault while editing file on OpenBSD/amd64. AFAIR, it was arising after longjmp(3). Unfortunately, I have no access right now to the OpenBSD machine to get a list of actions to reproduce and even more hacky patch.
See especially the malloc based
sbrk(3)
replacement in: