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