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