s3:winbindd: s/struct timed_event/struct tevent_timer
[Samba/gebeck_regimport.git] / lib / ccan / failtest / failtest_override.h
blob7d03188ea94e7ffc335685bcc655e58f6dd4cb1e
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
10 /* Replacement of allocators. */
11 #include <stdlib.h>
13 #ifdef HAVE_MALLOC_H
14 #include <malloc.h>
15 #endif
17 #undef calloc
18 #define calloc(nmemb, size) \
19 failtest_calloc((nmemb), (size), __FILE__, __LINE__)
21 #undef malloc
22 #define malloc(size) \
23 failtest_malloc((size), __FILE__, __LINE__)
25 #undef realloc
26 #define realloc(ptr, size) \
27 failtest_realloc((ptr), (size), __FILE__, __LINE__)
29 #undef free
30 #define free(ptr) \
31 failtest_free(ptr)
33 /* Replacement of I/O. */
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <sys/mman.h>
37 #include <fcntl.h>
38 #include <unistd.h>
40 #undef open
41 #define open(pathname, ...) \
42 failtest_open((pathname), __FILE__, __LINE__, __VA_ARGS__)
44 #undef pipe
45 #define pipe(pipefd) \
46 failtest_pipe((pipefd), __FILE__, __LINE__)
48 #undef read
49 #define read(fd, buf, count) \
50 failtest_read((fd), (buf), (count), __FILE__, __LINE__)
52 #undef write
53 #define write(fd, buf, count) \
54 failtest_write((fd), (buf), (count), __FILE__, __LINE__)
56 #undef pread
57 #define pread(fd, buf, count, off) \
58 failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
60 #undef pwrite
61 #define pwrite(fd, buf, count, off) \
62 failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
64 #undef close
65 #define close(fd) failtest_close(fd, __FILE__, __LINE__)
67 #undef fcntl
68 #define fcntl(fd, ...) failtest_fcntl((fd), __FILE__, __LINE__, __VA_ARGS__)
70 #undef mmap
71 /* OpenBSD doesn't idempotent-protect sys/mman.h, so we can't add args. */
72 #ifdef __OpenBSD__
73 #define mmap(addr, length, prot, flags, fd, offset) \
74 failtest_mmap_noloc((addr), (length), (prot), (flags), (fd), (offset))
75 #else
76 #define mmap(addr, length, prot, flags, fd, offset) \
77 failtest_mmap((addr), (length), (prot), (flags), (fd), (offset), \
78 __FILE__, __LINE__)
79 #endif /* !__OpenBSD__ */
81 #undef lseek
82 #define lseek(fd, offset, whence) \
83 failtest_lseek((fd), (offset), (whence), __FILE__, __LINE__)
85 /* Replacement of getpid (since failtest will fork). */
86 #undef getpid
87 #define getpid() failtest_getpid(__FILE__, __LINE__)
89 #include <ccan/failtest/failtest_proto.h>
91 #endif /* CCAN_FAILTEST_OVERRIDE_H */