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. */
6 #if HAVE_FILE_OFFSET_BITS
7 #define _FILE_OFFSET_BITS 64
10 /* Replacement of allocators. */
18 #define calloc(nmemb, size) \
19 failtest_calloc((nmemb), (size), __FILE__, __LINE__)
22 #define malloc(size) \
23 failtest_malloc((size), __FILE__, __LINE__)
26 #define realloc(ptr, size) \
27 failtest_realloc((ptr), (size), __FILE__, __LINE__)
33 /* Replacement of I/O. */
34 #include <sys/types.h>
41 #define open(pathname, ...) \
42 failtest_open((pathname), __FILE__, __LINE__, __VA_ARGS__)
45 #define pipe(pipefd) \
46 failtest_pipe((pipefd), __FILE__, __LINE__)
49 #define read(fd, buf, count) \
50 failtest_read((fd), (buf), (count), __FILE__, __LINE__)
53 #define write(fd, buf, count) \
54 failtest_write((fd), (buf), (count), __FILE__, __LINE__)
57 #define pread(fd, buf, count, off) \
58 failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
61 #define pwrite(fd, buf, count, off) \
62 failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
65 #define close(fd) failtest_close(fd, __FILE__, __LINE__)
68 #define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
71 /* OpenBSD doesn't idempotent-protect sys/mman.h, so we can't add args. */
73 #define mmap(addr, length, prot, flags, fd, offset) \
74 failtest_mmap_noloc((addr), (length), (prot), (flags), (fd), (offset))
76 #define mmap(addr, length, prot, flags, fd, offset) \
77 failtest_mmap((addr), (length), (prot), (flags), (fd), (offset), \
79 #endif /* !__OpenBSD__ */
82 #define lseek(fd, offset, whence) \
83 failtest_lseek((fd), (offset), (whence), __FILE__, __LINE__)
85 /* Replacement of getpid (since failtest will fork). */
87 #define getpid() failtest_getpid(__FILE__, __LINE__)
89 #include <ccan/failtest/failtest_proto.h>
91 #endif /* CCAN_FAILTEST_OVERRIDE_H */