Skip to content

Commit

Permalink
Merge pull request #33 from jake-b/master
Browse files Browse the repository at this point in the history
Poorly-tested fix for MacOS
  • Loading branch information
rico666 authored Jul 19, 2018
2 parents 929e26f + 7f59eca commit c10f6f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,19 @@ static void *alloc(size_t nmemb, size_t size) {
return calloc( nmemb, size );
}
else {

#if __APPLE__
// allocate memory on a 4K boundary for O_DIRECT. Otherwise `write` gives `errno` 22
void* return_ptr;
int err = posix_memalign(&return_ptr, 4096, nmemb * size);
if (err) {
printf("\n\nError while allocating memory with posix_memalign: %d\n\n", errno);
exit(1);
}
return return_ptr;
#else
return aligned_alloc( 4096, nmemb * size );
#endif
}
}

Expand Down
6 changes: 5 additions & 1 deletion test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@
cmp_digest('core2/11424087411148401423_0_128', $expected);
}

# Test Core 0 with Direct IO
print qx{$plotbin -D -a -v -k 11424087411148401423 -d core0_dio -x 0 -s 0 -n 128 -t 4};
cmp_digest('core0_dio/11424087411148401423_0_128_128', $expected);

# cleanup
qx{rm -rf core0 core1 core2} if (!$keep);
qx{rm -rf core0 core1 core2 core0_dio} if (!$keep);

sub cmp_digest {
my $file = shift;
Expand Down

0 comments on commit c10f6f6

Please sign in to comment.