Skip to content

Commit 137b6cf

Browse files
authored
Merge pull request #830 from apple/eng/PR-123808864-for-6.0
Switching back _dispatch_operation_perform to use posix_memalign from aligned_malloc for 6.0 release
2 parents 0ccbfe3 + 19e6dcd commit 137b6cf

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/io.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,10 @@ _dispatch_operation_perform(dispatch_operation_t op)
23742374
}
23752375
op->buf = _aligned_malloc(op->buf_siz, siInfo.dwPageSize);
23762376
#else
2377-
op->buf = aligned_alloc((size_t)PAGE_SIZE, op->buf_siz);
2377+
err = posix_memalign(&op->buf, (size_t)PAGE_SIZE, op->buf_siz);
2378+
if (err != 0) {
2379+
goto error;
2380+
}
23782381
#endif
23792382
_dispatch_op_debug("buffer allocated", op);
23802383
} else if (op->direction == DOP_DIR_WRITE) {

tests/dispatch_io.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ test_async_read(char *path, size_t size, int option, dispatch_queue_t queue,
398398
buffer = _aligned_malloc(size, si.dwPageSize);
399399
#else
400400
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
401-
buffer = aligned_alloc(pagesize, size);
401+
posix_memalign((void **)&buffer, pagesize, size);
402402
#endif
403403
ssize_t r = dispatch_test_fd_read(fd, buffer, size);
404404
if (r == -1) {

tests/dispatch_read2.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dispatch_read2(dispatch_fd_t fd,
9191
buffer = _aligned_malloc(bufsiz, pagesize);
9292
#else
9393
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE);
94-
buffer = aligned_alloc(pagesize, bufsiz);
94+
posix_memalign((void **)&buffer, pagesize, bufsiz);
9595
#endif
9696
ssize_t actual = dispatch_test_fd_read(fd, buffer, bufsiz);
9797
if (actual == -1) {
@@ -150,7 +150,7 @@ test_read(void)
150150
test_stop();
151151
}
152152
#else
153-
// investigate what the impact of lack of file cache disabling has
153+
// investigate what the impact of lack of file cache disabling has
154154
// for this test
155155
#endif
156156
size_t size = (size_t)dispatch_test_fd_lseek(fd, 0, SEEK_END);

0 commit comments

Comments
 (0)