logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

madvise_preserve_errno.patch (662B)


  1. # SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
  2. # SPDX-License-Identifier: MIT
  3. diff -r -u musl-1.1.24.orig/src/malloc/malloc.c musl-1.1.24/src/malloc/malloc.c
  4. --- musl-1.1.24/src/malloc/malloc.c 2019-10-13 21:58:27.000000000 +0000
  5. +++ musl-1.1.24/src/malloc/malloc.c 2023-12-22 23:18:21.088570834 +0000
  6. @@ -496,7 +496,9 @@
  7. uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE;
  8. uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE;
  9. #if 1
  10. + int e = errno;
  11. __madvise((void *)a, b-a, MADV_DONTNEED);
  12. + errno = e;
  13. #else
  14. __mmap((void *)a, b-a, PROT_READ|PROT_WRITE,
  15. MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);