]> git.ozlabs.org Git - ccan/blob - ccan/failtest/failtest_override.h
d5be2829d5e0dd418ae35eb4dd7b2f26543cccf7
[ccan] / ccan / failtest / failtest_override.h
1 #ifndef CCAN_FAILTEST_OVERRIDE_H
2 #define CCAN_FAILTEST_OVERRIDE_H
3 /* This file is included before the source file to test. */
4
5 /* Replacement of allocators. */
6 #include <stdlib.h>
7
8 #undef calloc
9 #define calloc(nmemb, size)     \
10         failtest_calloc((nmemb), (size), __FILE__, __LINE__)
11
12 #undef malloc
13 #define malloc(size)    \
14         failtest_malloc((size), __FILE__, __LINE__)
15
16 #undef realloc
17 #define realloc(ptr, size)                                      \
18         failtest_realloc((ptr), (size), __FILE__, __LINE__)
19
20 #undef free
21 #define free(ptr) \
22         failtest_free(ptr)
23
24 /* Replacement of I/O. */
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29
30 #undef open
31 #define open(pathname, ...) \
32         failtest_open((pathname), __FILE__, __LINE__, __VA_ARGS__)
33
34 #undef pipe
35 #define pipe(pipefd) \
36         failtest_pipe((pipefd), __FILE__, __LINE__)
37
38 #undef read
39 #define read(fd, buf, count) \
40         failtest_read((fd), (buf), (count), __FILE__, __LINE__)
41
42 #undef write
43 #define write(fd, buf, count) \
44         failtest_write((fd), (buf), (count), __FILE__, __LINE__)
45
46 #undef pread
47 #define pread(fd, buf, count, off)                              \
48         failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
49
50 #undef pwrite
51 #define pwrite(fd, buf, count, off)                                     \
52         failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
53
54 #undef close
55 #define close(fd) failtest_close(fd)
56
57 #undef fcntl
58 #define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
59
60 #include <ccan/failtest/failtest_proto.h>
61
62 #endif /* CCAN_FAILTEST_OVERRIDE_H */