diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-06-28 10:48:48 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-06-28 14:05:02 +0200 |
commit | 507f55c05f30c9eb80faf2546ec635c338c039eb (patch) | |
tree | 854760dd291baaa718f4f9a796fac5d056e19d97 /sysdeps | |
parent | 589787f8894251c3b114f4ce06a89ecf2763f1b4 (diff) | |
download | glibc-507f55c05f30c9eb80faf2546ec635c338c039eb.zip glibc-507f55c05f30c9eb80faf2546ec635c338c039eb.tar.gz glibc-507f55c05f30c9eb80faf2546ec635c338c039eb.tar.bz2 |
Linux: Use mmap instead of malloc in dirent/tst-getdents64
malloc dirties the entire allocated memory region due to M_PERTURB
in the test harness.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/unix/sysv/linux/tst-getdents64.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c index 24e77e0..8a28e6c 100644 --- a/sysdeps/unix/sysv/linux/tst-getdents64.c +++ b/sysdeps/unix/sysv/linux/tst-getdents64.c @@ -27,6 +27,7 @@ #include <support/check.h> #include <support/support.h> #include <support/xunistd.h> +#include <sys/mman.h> #include <unistd.h> /* Called by large_buffer_checks below. */ @@ -53,8 +54,13 @@ large_buffer_checks (int fd) size_t large_buffer_size; if (!__builtin_add_overflow (UINT_MAX, 2, &large_buffer_size)) { - char *large_buffer = malloc (large_buffer_size); - if (large_buffer == NULL) + int flags = MAP_ANONYMOUS | MAP_PRIVATE; +#ifdef MAP_NORESERVE + flags |= MAP_NORESERVE; +#endif + void *large_buffer = mmap (NULL, large_buffer_size, + PROT_READ | PROT_WRITE, flags, -1, 0); + if (large_buffer == MAP_FAILED) printf ("warning: could not allocate %zu bytes of memory," " subtests skipped\n", large_buffer_size); else @@ -65,8 +71,8 @@ large_buffer_checks (int fd) large_buffer_check (fd, large_buffer, UINT_MAX); large_buffer_check (fd, large_buffer, (size_t) UINT_MAX + 1); large_buffer_check (fd, large_buffer, (size_t) UINT_MAX + 2); + xmunmap (large_buffer, large_buffer_size); } - free (large_buffer); } } |