Skip to content

Switching back _dispatch_operation_perform to use posix_memalign from aligned_malloc #826

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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
endif()

check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT)
check_function_exists(aligned_alloc HAVE_ALIGNED_ALLOC)
check_function_exists(getprogname HAVE_GETPROGNAME)
check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
check_function_exists(mach_approximate_time HAVE_MACH_APPROXIMATE_TIME)
Expand Down
2 changes: 0 additions & 2 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,8 +2373,6 @@ _dispatch_operation_perform(dispatch_operation_t op)
bQueried = true;
}
op->buf = _aligned_malloc(op->buf_siz, siInfo.dwPageSize);
#elif defined(HAVE_ALIGNED_ALLOC)
op->buf = aligned_alloc((size_t)PAGE_SIZE, op->buf_siz);
#else
err = posix_memalign(&op->buf, (size_t)PAGE_SIZE, op->buf_siz);
if (err != 0) {
Expand Down
4 changes: 0 additions & 4 deletions tests/dispatch_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +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);
#if defined(HAVE_ALIGNED_ALLOC)
buffer = aligned_alloc(pagesize, size);
#else
posix_memalign((void **)&buffer, pagesize, size);
#endif
#endif
ssize_t r = dispatch_test_fd_read(fd, buffer, size);
if (r == -1) {
Expand Down
6 changes: 1 addition & 5 deletions tests/dispatch_read2.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ dispatch_read2(dispatch_fd_t fd,
buffer = _aligned_malloc(bufsiz, pagesize);
#else
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
#if defined(HAVE_ALIGNED_ALLOC)
buffer = aligned_alloc(pagesize, bufsiz);
#else
posix_memalign((void **)&buffer, pagesize, bufsiz);
#endif
#endif
ssize_t actual = dispatch_test_fd_read(fd, buffer, bufsiz);
if (actual == -1) {
Expand Down Expand Up @@ -154,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