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 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); 35void *memcpy(void *dst, const void *src, size_t n); 36 37typedef unsigned long __darwin_pthread_key_t; 38typedef __darwin_pthread_key_t pthread_key_t; 39int pthread_setspecific(pthread_key_t, const void *); 40 41typedef long long __int64_t; 42typedef __int64_t __darwin_off_t; 43typedef __darwin_off_t fpos_t; 44 45void setbuf(FILE * restrict, char * restrict); 46int setvbuf(FILE * restrict, char * restrict, int, size_t); 47 48FILE *fopen(const char * restrict, const char * restrict); 49int fclose(FILE *); 50FILE *funopen(const void *, 51 int (*)(void *, char *, int), 52 int (*)(void *, const char *, int), 53 fpos_t (*)(void *, fpos_t, int), 54 int (*)(void *)); 55 56int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); 57 58typedef void (*freeCallback) (void*); 59typedef struct { 60 int i; 61 freeCallback fc; 62} StWithCallback; 63 64int dealocateMemWhenDoneByVal(void*, StWithCallback); 65int dealocateMemWhenDoneByRef(StWithCallback*, const void*); 66 67typedef struct CGContext *CGContextRef; 68CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, 69 size_t bitsPerComponent, size_t bytesPerRow, 70 CGColorSpaceRef space, 71 CGBitmapInfo bitmapInfo*/); 72void *CGBitmapContextGetData(CGContextRef context); 73 74// Include xpc. 75typedef struct _xpc_connection_s * xpc_connection_t; 76typedef void (*xpc_finalizer_t)(void *value); 77void xpc_connection_set_context(xpc_connection_t connection, void *context); 78void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); 79void xpc_connection_resume(xpc_connection_t connection); 80 81//The following are fake system header functions for generic testing. 82void fakeSystemHeaderCallInt(int *); 83void fakeSystemHeaderCallIntPtr(int **); 84 85// Some data strauctures may hold onto the pointer and free it later. 86void fake_insque(void *, void *); 87typedef struct fake_rb_tree { void *opaque[8]; } fake_rb_tree_t; 88void fake_rb_tree_init(fake_rb_tree_t *, const void *); 89void *fake_rb_tree_insert_node(fake_rb_tree_t *, void *); 90 91typedef struct __SomeStruct { 92 char * p; 93} SomeStruct; 94void fakeSystemHeaderCall(SomeStruct *); 95 96typedef int pid_t; 97pid_t fork(void); 98pid_t vfork(void); 99int execl(const char *path, const char *arg, ...); 100 101void exit(int status) __attribute__ ((__noreturn__)); 102void _exit(int status) __attribute__ ((__noreturn__)); 103void _Exit(int status) __attribute__ ((__noreturn__)); 104 105