Fix segfault when passing in size < block_size
[fio.git] / helpers.c
1 #include <stdlib.h>
2 #include <errno.h>
3 #include <sys/socket.h>
4 #include <sys/time.h>
5 #include <netinet/in.h>
6 #include <unistd.h>
7
8 #include "compiler/compiler.h"
9 #include "arch/arch.h"
10 #include "os/os.h"
11
12 #ifndef __NR_fallocate
13 int __weak posix_fallocate(int fd, off_t offset, off_t len)
14 {
15         return 0;
16 }
17 #endif
18
19 int __weak inet_aton(const char *cp, struct in_addr *inp)
20 {
21         return 0;
22 }
23
24 int __weak clock_gettime(clockid_t clk_id, struct timespec *ts)
25 {
26         struct timeval tv;
27         int ret;
28
29         ret = gettimeofday(&tv, NULL);
30
31         ts->tv_sec = tv.tv_sec;
32         ts->tv_nsec = tv.tv_usec * 1000;
33
34         return ret;
35 }
36
37 #ifndef __NR_sync_file_range
38 int __weak sync_file_range(int fd, off64_t offset, off64_t nbytes,
39                            unsigned int flags)
40 {
41         errno = ENOSYS;
42         return -1;
43 }
44 #endif