Skip to content

Commit

Permalink
Remove HD from HDposix_memalign() (#3196)
Browse files Browse the repository at this point in the history
The posix_memalign call is only used in the direct VFD, which can only
be built if posix_memalign() is available.
  • Loading branch information
derobins authored Jun 28, 2023
1 parent 96d89bc commit 605cea4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/H5FDdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
* than the one where the program is running.
*/
/* NOTE: Use HDmalloc and HDfree here to ensure compatibility with
* HDposix_memalign.
* posix_memalign.
*/
buf1 = HDmalloc(sizeof(int));
if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed")
if (posix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "posix_memalign failed")

if (o_flags & O_CREAT) {
if (HDwrite(file->fd, buf1, sizeof(int)) < 0) {
Expand Down Expand Up @@ -944,8 +944,8 @@ H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U
if (alloc_size > _cbsize)
alloc_size = _cbsize;
assert(!(alloc_size % _fbsize));
if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
if (posix_memalign(&copy_buf, _boundary, alloc_size) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "posix_memalign failed")

/* look for the aligned position for reading the data */
assert(!(((addr / _fbsize) * _fbsize) % _fbsize));
Expand Down Expand Up @@ -1125,8 +1125,8 @@ H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_
alloc_size = _cbsize;
assert(!(alloc_size % _fbsize));

if (HDposix_memalign(&copy_buf, _boundary, alloc_size) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed")
if (posix_memalign(&copy_buf, _boundary, alloc_size) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "posix_memalign failed")

/* look for the right position for reading or writing the data */
if (HDlseek(file->fd, (HDoff_t)write_addr, SEEK_SET) < 0)
Expand Down
3 changes: 0 additions & 3 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,6 @@ H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDmalloc
#define HDmalloc(Z) malloc(Z)
#endif
#ifndef HDposix_memalign
#define HDposix_memalign(P, A, Z) posix_memalign(P, A, Z)
#endif
#ifndef HDmemcmp
#define HDmemcmp(X, Y, Z) memcmp(X, Y, Z)
#endif
Expand Down
4 changes: 2 additions & 2 deletions test/vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,10 @@ test_direct(void)

/* Allocate aligned memory for data set 1. For data set 1, everything is aligned including
* memory address, size of data, and file address. */
if (0 != HDposix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
if (0 != posix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
points = proto_points;
if (0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
if (0 != posix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int))))
TEST_ERROR;
check = proto_check;

Expand Down

0 comments on commit 605cea4

Please sign in to comment.