| 1 | // 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 | |
| 12 | typedef struct _FILE FILE; |
| 13 | extern FILE *stdin; |
| 14 | extern FILE *stdout; |
| 15 | extern FILE *stderr; |
| 16 | // Include a variant of standard streams that occur in the pre-processed file. |
| 17 | extern FILE *__stdinp; |
| 18 | extern FILE *__stdoutp; |
| 19 | extern FILE *__stderrp; |
| 20 | |
| 21 | int scanf(const char *restrict format, ...); |
| 22 | int fscanf(FILE *restrict, const char *restrict, ...); |
| 23 | int printf(const char *restrict format, ...); |
| 24 | int fprintf(FILE *restrict, const char *restrict, ...); |
| 25 | int getchar(void); |
| 26 | |
| 27 | // Note, on some platforms errno macro gets replaced with a function call. |
| 28 | extern int errno; |
| 29 | |
| 30 | typedef __typeof(sizeof(int)) size_t; |
| 31 | |
| 32 | size_t strlen(const char *); |
| 33 | |
| 34 | char *strcpy(char *restrict, const char *restrict); |
| 35 | char *strncpy(char *dst, const char *src, size_t n); |
| 36 | void *memcpy(void *dst, const void *src, size_t n); |
| 37 | |
| 38 | typedef unsigned long __darwin_pthread_key_t; |
| 39 | typedef __darwin_pthread_key_t pthread_key_t; |
| 40 | int pthread_setspecific(pthread_key_t, const void *); |
| 41 | |
| 42 | typedef long long __int64_t; |
| 43 | typedef __int64_t __darwin_off_t; |
| 44 | typedef __darwin_off_t fpos_t; |
| 45 | |
| 46 | void setbuf(FILE * restrict, char * restrict); |
| 47 | int setvbuf(FILE * restrict, char * restrict, int, size_t); |
| 48 | |
| 49 | FILE *fopen(const char * restrict, const char * restrict); |
| 50 | int fclose(FILE *); |
| 51 | FILE *funopen(const void *, |
| 52 | int (*)(void *, char *, int), |
| 53 | int (*)(void *, const char *, int), |
| 54 | fpos_t (*)(void *, fpos_t, int), |
| 55 | int (*)(void *)); |
| 56 | |
| 57 | int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); |
| 58 | |
| 59 | typedef void (*freeCallback) (void*); |
| 60 | typedef struct { |
| 61 | int i; |
| 62 | freeCallback fc; |
| 63 | } StWithCallback; |
| 64 | |
| 65 | int dealocateMemWhenDoneByVal(void*, StWithCallback); |
| 66 | int dealocateMemWhenDoneByRef(StWithCallback*, const void*); |
| 67 | |
| 68 | typedef struct CGContext *CGContextRef; |
| 69 | CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, |
| 70 | size_t bitsPerComponent, size_t bytesPerRow, |
| 71 | CGColorSpaceRef space, |
| 72 | CGBitmapInfo bitmapInfo*/); |
| 73 | void *CGBitmapContextGetData(CGContextRef context); |
| 74 | |
| 75 | // Include xpc. |
| 76 | typedef struct _xpc_connection_s * xpc_connection_t; |
| 77 | typedef void (*xpc_finalizer_t)(void *value); |
| 78 | void xpc_connection_set_context(xpc_connection_t connection, void *context); |
| 79 | void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); |
| 80 | void xpc_connection_resume(xpc_connection_t connection); |
| 81 | |
| 82 | //The following are fake system header functions for generic testing. |
| 83 | void fakeSystemHeaderCallInt(int *); |
| 84 | void fakeSystemHeaderCallIntPtr(int **); |
| 85 | |
| 86 | // Some data strauctures may hold onto the pointer and free it later. |
| 87 | void fake_insque(void *, void *); |
| 88 | typedef struct fake_rb_tree { void *opaque[8]; } fake_rb_tree_t; |
| 89 | void fake_rb_tree_init(fake_rb_tree_t *, const void *); |
| 90 | void *fake_rb_tree_insert_node(fake_rb_tree_t *, void *); |
| 91 | |
| 92 | typedef struct __SomeStruct { |
| 93 | char * p; |
| 94 | } SomeStruct; |
| 95 | void fakeSystemHeaderCall(SomeStruct *); |
| 96 | |
| 97 | typedef int pid_t; |
| 98 | pid_t fork(void); |
| 99 | pid_t vfork(void); |
| 100 | int execl(const char *path, const char *arg, ...); |
| 101 | |
| 102 | void exit(int status) __attribute__ ((__noreturn__)); |
| 103 | void _exit(int status) __attribute__ ((__noreturn__)); |
| 104 | void _Exit(int status) __attribute__ ((__noreturn__)); |
| 105 | |
| 106 | #define UINT32_MAX 4294967295U |
| 107 | #define INT64_MIN (-INT64_MAX-1) |
| 108 | #define __DBL_MAX__ 1.7976931348623157e+308 |
| 109 | #define DBL_MAX __DBL_MAX__ |
| 110 | #ifndef NULL |
| 111 | #define __DARWIN_NULL 0 |
| 112 | #define NULL __DARWIN_NULL |
| 113 | #endif |
| 114 | |
| 115 | #define offsetof(t, d) __builtin_offsetof(t, d) |