Portability fixes for musl libc