libc - Use sbrk() system call, remove brk()
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 16 Feb 2019 19:40:04 +0000 (11:40 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 18 Feb 2019 01:48:24 +0000 (17:48 -0800)
commit8618d94a0e2ff8303ad93c123a3fa598c26a116e
tree5f025e999c4ad9b3b887a46e76ba2f2d54335e9c
parent6cee0fd2d3f6895d4a214164d0a7fca1a3841d66
libc - Use sbrk() system call, remove brk()

* Attempt to use the kernel sbrk() system call.  If it fails
  with EOPNOTSUPP, back-off to the older libc sbrk() emulation
  code which uses still-present but obsolete break() system call.

* Changes support both old and new kernels.  Older kernels do not
  implement the sbrk() system call, causing the call to return
  -1/EOPNOTSUPP.  Note that older kernels did not generate an
  ENOSYS/signal for sbrk().

* sbrk() cannot support negative increments.  Allow only 0 and positive
  increments.

* Fix MPSAFE issues (requires new kernels) while we are here.

* Remove brk() support entirely.  This was also emulated in older
  kernels using break().

* These changes are necessary in order to support mmap() hinting above
  RLIMIT_DATA's current value.  Older kernels only support hinting above
  the system maximum value (above the 32GB mark).  Several languages in
  dports really want to mmap() addresses below 4GB.
lib/libc/gen/Makefile.inc
lib/libc/gen/ovsbrk.c [new file with mode: 0644]
lib/libc/x86_64/sys/Makefile.inc
lib/libc/x86_64/sys/brk.S [deleted file]
lib/libc/x86_64/sys/fake_sbrk.S [moved from lib/libc/x86_64/sys/sbrk.S with 98% similarity]