system-header-simulator.h revision 262e0d41e49c6b823d62743535e2accb117a6ea9
1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Like the compiler, the static analyzer treats some functions differently if
2// they come from a system header -- for example, it is assumed that system
3// functions do not arbitrarily free() their parameters, and that some bugs
4// found in system headers cannot be fixed by the user and should be
5// suppressed.
6#pragma clang system_header
7
8#ifdef __cplusplus
9#define restrict /*restrict*/
10#endif
11
12typedef struct _FILE FILE;
13extern FILE *stdin;
14extern FILE *stdout;
15extern FILE *stderr;
16// Include a variant of standard streams that occur in the pre-processed file.
17extern FILE *__stdinp;
18extern FILE *__stdoutp;
19extern FILE *__stderrp;
20
21int scanf(const char *restrict format, ...);
22int fscanf(FILE *restrict, const char *restrict, ...);
23int printf(const char *restrict format, ...);
24int fprintf(FILE *restrict, const char *restrict, ...);
25int getchar(void);
26
27// Note, on some platforms errno macro gets replaced with a function call.
28extern int errno;
29
30typedef __typeof(sizeof(int)) size_t;
31
32size_t strlen(const char *);
33
34char *strcpy(char *restrict, const char *restrict);
35
36typedef unsigned long __darwin_pthread_key_t;
37typedef __darwin_pthread_key_t pthread_key_t;
38int pthread_setspecific(pthread_key_t, const void *);
39
40typedef long long __int64_t;
41typedef __int64_t __darwin_off_t;
42typedef __darwin_off_t fpos_t;
43
44void setbuf(FILE * restrict, char * restrict);
45int setvbuf(FILE * restrict, char * restrict, int, size_t);
46
47FILE *fopen(const char * restrict, const char * restrict);
48int fclose(FILE *);
49FILE *funopen(const void *,
50                 int (*)(void *, char *, int),
51                 int (*)(void *, const char *, int),
52                 fpos_t (*)(void *, fpos_t, int),
53                 int (*)(void *));
54
55int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*));
56
57typedef void (*freeCallback) (void*);
58typedef struct {
59  int i;
60  freeCallback fc;
61} StWithCallback;
62
63int dealocateMemWhenDoneByVal(void*, StWithCallback);
64int dealocateMemWhenDoneByRef(StWithCallback*, const void*);
65
66typedef struct CGContext *CGContextRef;
67CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height,
68                                   size_t bitsPerComponent, size_t bytesPerRow,
69                                   CGColorSpaceRef space,
70                                   CGBitmapInfo bitmapInfo*/);
71void *CGBitmapContextGetData(CGContextRef context);
72
73// Include xpc.
74typedef struct _xpc_connection_s * xpc_connection_t;
75typedef void (*xpc_finalizer_t)(void *value);
76void xpc_connection_set_context(xpc_connection_t connection, void *context);
77void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer);
78void xpc_connection_resume(xpc_connection_t connection);
79
80//The following is a fake system header function
81void fakeSystemHeaderCallInt(int *);
82
83typedef struct __SomeStruct {
84  char * p;
85} SomeStruct;
86void fakeSystemHeaderCall(SomeStruct *);
87