]> git.ozlabs.org Git - ccan/blob - ccan/failtest/failtest_override.h
dd328b508a5433911888affaa0f4e73227fdd67c
[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 /* Replacement of I/O. */
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include <fcntl.h>
24 #include <unistd.h>
25
26 #undef open
27 #define open(pathname, flags, ...) \
28         failtest_open((pathname), (flags), __FILE__, __LINE__, __VA_ARGS__)
29
30 #undef pipe
31 #define pipe(pipefd) \
32         failtest_pipe((pipefd), __FILE__, __LINE__)
33
34 #undef read
35 #define read(fd, buf, count) \
36         failtest_read((fd), (buf), (count), __FILE__, __LINE__)
37
38 #undef write
39 #define write(fd, buf, count) \
40         failtest_write((fd), (buf), (count), __FILE__, __LINE__)
41
42 #undef close
43 #define close(fd) failtest_close(fd)
44
45 #include <ccan/failtest/failtest_proto.h>
46
47 #endif /* CCAN_FAILTEST_OVERRIDE_H */