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 *restrict, size_t, size_t, FILE *restrict); 50 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict); 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 size_t strlen(const char *); 63 64 char *strcpy(char *restrict, const char *restrict); 65 char *strncpy(char *dst, const char *src, size_t n); 66 void *memcpy(void *dst, const void *src, size_t n); 67 68 typedef unsigned long __darwin_pthread_key_t; 69 typedef __darwin_pthread_key_t pthread_key_t; 70 int pthread_setspecific(pthread_key_t, const void *); 71 72 int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); 73 74 typedef void (*freeCallback) (void*); 75 typedef struct { 76 int i; 77 freeCallback fc; 78 } StWithCallback; 79 80 int dealocateMemWhenDoneByVal(void*, StWithCallback); 81 int dealocateMemWhenDoneByRef(StWithCallback*, const void*); 82 83 typedef struct CGContext *CGContextRef; 84 CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, 85 size_t bitsPerComponent, size_t bytesPerRow, 86 CGColorSpaceRef space, 87 CGBitmapInfo bitmapInfo*/); 88 void *CGBitmapContextGetData(CGContextRef context); 89 90 // Include xpc. 91 typedef struct _xpc_connection_s * xpc_connection_t; 92 typedef void (*xpc_finalizer_t)(void *value); 93 void xpc_connection_set_context(xpc_connection_t connection, void *context); 94 void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); 95 void xpc_connection_resume(xpc_connection_t connection); 96 97 //The following are fake system header functions for generic testing. 98 void fakeSystemHeaderCallInt(int *); 99 void fakeSystemHeaderCallIntPtr(int **); 100 101 // Some data strauctures may hold onto the pointer and free it later. 102 void fake_insque(void *, void *); 103 typedef struct fake_rb_tree { void *opaque[8]; } fake_rb_tree_t; 104 void fake_rb_tree_init(fake_rb_tree_t *, const void *); 105 void *fake_rb_tree_insert_node(fake_rb_tree_t *, void *); 106 107 typedef struct __SomeStruct { 108 char * p; 109 } SomeStruct; 110 void fakeSystemHeaderCall(SomeStruct *); 111 112 typedef int pid_t; 113 pid_t fork(void); 114 pid_t vfork(void); 115 int execl(const char *path, const char *arg, ...); 116 int execle(const char *path, const char *arg, ...); 117 int execlp(const char *file, const char *arg, ...); 118 int execv(const char *path, char *const argv[]); 119 int execve(const char *path, char *const argv[], char *const envp[]); 120 int execvp(const char *file, char *const argv[]); 121 int execvpe(const char *file, char *const argv[], char *const envp[]); 122 123 void exit(int status) __attribute__ ((__noreturn__)); 124 void _exit(int status) __attribute__ ((__noreturn__)); 125 void _Exit(int status) __attribute__ ((__noreturn__)); 126 127 #define UINT32_MAX 4294967295U 128 #define INT64_MIN (-INT64_MAX-1) 129 #define __DBL_MAX__ 1.7976931348623157e+308 130 #define DBL_MAX __DBL_MAX__ 131 #ifndef NULL 132 #define __DARWIN_NULL 0 133 #define NULL __DARWIN_NULL 134 #endif 135 #define EOF (-1) 136 137 #define offsetof(t, d) __builtin_offsetof(t, d) 138