+2017-11-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+
+ [BZ #22457]
+ * sysdeps/posix/preadv_common.c (PREADV): Use mmap/munmap instead of
+ posix_memalign/free.
+ * sysdeps/posix/pwritev_common.c (PWRITEV): Likewise.
+
2017-11-22 Mike FABIAN <mfabian@redhat.com>
[BZ #22469]
#include <malloc.h>
#include <ldsodefs.h>
+#include <libc-pointer-arith.h>
/* Read data from file descriptor FD at the given position OFFSET
without change the file pointer, and put the result in the buffers
but 1. it is system specific (not meant in generic implementation), and
2. it would make the implementation more complex, and 3. it will require
another syscall (fcntl). */
- void *buffer = NULL;
- if (__posix_memalign (&buffer, GLRO(dl_pagesize), bytes) != 0)
+ void *buffer = __mmap (NULL, bytes, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (__glibc_unlikely (buffer == MAP_FAILED))
return -1;
ssize_t bytes_read = PREAD (fd, buffer, bytes, offset);
}
end:
- free (buffer);
+ __munmap (buffer, bytes);
return bytes_read;
}
#include <malloc.h>
#include <ldsodefs.h>
+#include <libc-pointer-arith.h>
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
but 1. it is system specific (not meant in generic implementation), and
2. it would make the implementation more complex, and 3. it will require
another syscall (fcntl). */
- void *buffer = NULL;
- if (__posix_memalign (&buffer, GLRO(dl_pagesize), bytes) != 0)
+ void *buffer = __mmap (NULL, bytes, PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (__glibc_unlikely (buffer == MAP_FAILED))
return -1;
/* Copy the data from BUFFER into the memory specified by VECTOR. */
ssize_t ret = PWRITE (fd, buffer, bytes, offset);
- free (buffer);
+ __munmap (buffer, bytes);
return ret;
}