Fixes for FreeBSD

This commit is contained in:
Uffe Jakobsen 2014-08-22 17:16:27 +02:00 committed by Michel Machado
parent 397648282d
commit b4e8e6c9da
3 changed files with 11 additions and 8 deletions

View File

@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
#include <assert.h>
#include <stdint.h>
@ -10,6 +11,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <err.h>
#include <sys/time.h>
#include "utils.h"

View File

@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
#include <assert.h>
#include <stdint.h>
@ -9,10 +10,10 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/statvfs.h>
#include <sys/time.h>
#include <errno.h>
#include <unistd.h>
#include <err.h>
#include <alloca.h>
#include <math.h>
#include "utils.h"
@ -341,7 +342,7 @@ static int create_and_fill_file(const char *path, long number, size_t size,
char *full_fn;
const char *filename;
int fd, fine;
void *buf;
char buf[fw->block_size];
size_t remaining;
uint64_t offset;
ssize_t written;
@ -350,7 +351,7 @@ static int create_and_fill_file(const char *path, long number, size_t size,
assert(size % fw->block_size == 0);
/* Create the file. */
fine = 0;
full_fn = full_fn_from_number(&filename, path, number);
assert(full_fn);
@ -366,10 +367,6 @@ static int create_and_fill_file(const char *path, long number, size_t size,
}
assert(fd >= 0);
/* Obtain the buffer. */
buf = alloca(fw->block_size);
assert(buf);
/* Write content. */
fine = 1;
offset = (uint64_t)number * GIGABYTES;
@ -392,7 +389,7 @@ static int create_and_fill_file(const char *path, long number, size_t size,
assert(!fine || remaining == 0);
end_measurement(fd, fw);
close(fd);
printf("OK!\n");
out:

View File

@ -67,4 +67,8 @@ static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice)
#endif /* Apple Macintosh */
#ifdef __FreeBSD__
#define fdatasync(fd) fsync(fd)
#endif
#endif /* HEADER_UTILS_H */