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