Skip to content

Switching back _dispatch_operation_perform to use posix_memalign from aligned_malloc for 6.0 release #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,10 @@ _dispatch_operation_perform(dispatch_operation_t op)
}
op->buf = _aligned_malloc(op->buf_siz, siInfo.dwPageSize);
#else
op->buf = aligned_alloc((size_t)PAGE_SIZE, op->buf_siz);
err = posix_memalign(&op->buf, (size_t)PAGE_SIZE, op->buf_siz);
if (err != 0) {
goto error;
}
#endif
_dispatch_op_debug("buffer allocated", op);
} else if (op->direction == DOP_DIR_WRITE) {
Expand Down
2 changes: 1 addition & 1 deletion tests/dispatch_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ test_async_read(char *path, size_t size, int option, dispatch_queue_t queue,
buffer = _aligned_malloc(size, si.dwPageSize);
#else
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
buffer = aligned_alloc(pagesize, size);
posix_memalign((void **)&buffer, pagesize, size);
#endif
ssize_t r = dispatch_test_fd_read(fd, buffer, size);
if (r == -1) {
Expand Down
4 changes: 2 additions & 2 deletions tests/dispatch_read2.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ dispatch_read2(dispatch_fd_t fd,
buffer = _aligned_malloc(bufsiz, pagesize);
#else
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
buffer = aligned_alloc(pagesize, bufsiz);
posix_memalign((void **)&buffer, pagesize, bufsiz);
#endif
ssize_t actual = dispatch_test_fd_read(fd, buffer, bufsiz);
if (actual == -1) {
Expand Down Expand Up @@ -150,7 +150,7 @@ test_read(void)
test_stop();
}
#else
// investigate what the impact of lack of file cache disabling has
// investigate what the impact of lack of file cache disabling has
// for this test
#endif
size_t size = (size_t)dispatch_test_fd_lseek(fd, 0, SEEK_END);
Expand Down