brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.8 KiB · fadc09f Raw
165 lines · c
1// Like the compiler, the static analyzer treats some functions differently if2// they come from a system header -- for example, it is assumed that system3// functions do not arbitrarily free() their parameters, and that some bugs4// found in system headers cannot be fixed by the user and should be5// suppressed.6#pragma clang system_header7 8#ifdef __cplusplus9#define restrict /*restrict*/10#endif11 12typedef __typeof(sizeof(int)) size_t;13typedef long long __int64_t;14typedef __int64_t __darwin_off_t;15typedef __darwin_off_t fpos_t;16typedef int off_t;17typedef long ssize_t;18 19typedef struct _FILE FILE;20#define SEEK_SET 0 /* Seek from beginning of file. */21#define SEEK_CUR 1 /* Seek from current position. */22#define SEEK_END 2 /* Seek from end of file. */23 24extern FILE *stdin;25extern FILE *stdout;26extern FILE *stderr;27// Include a variant of standard streams that occur in the pre-processed file.28extern FILE *__stdinp;29extern FILE *__stdoutp;30extern FILE *__stderrp;31 32int scanf(const char *restrict format, ...);33int fscanf(FILE *restrict, const char *restrict, ...);34int printf(const char *restrict format, ...);35int fprintf(FILE *restrict, const char *restrict, ...);36int getchar(void);37 38void setbuf(FILE *restrict, char *restrict);39int setvbuf(FILE *restrict, char *restrict, int, size_t);40 41FILE *funopen(const void *,42              int (*)(void *, char *, int),43              int (*)(void *, const char *, int),44              fpos_t (*)(void *, fpos_t, int),45              int (*)(void *));46 47FILE *fopen(const char *restrict path, const char *restrict mode);48FILE *fdopen(int fd, const char *mode);49FILE *tmpfile(void);50FILE *freopen(const char *restrict pathname, const char *restrict mode, FILE *restrict stream);51FILE *popen(const char *command, const char *mode);52int fclose(FILE *fp);53int pclose(FILE *stream);54size_t fread(void *restrict, size_t, size_t, FILE *restrict);55size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);56int fgetc(FILE *stream);57char *fgets(char *restrict str, int count, FILE *restrict stream);58int fputc(int ch, FILE *stream);59int fputs(const char *restrict s, FILE *restrict stream);60int ungetc(int c, FILE *stream);61ssize_t getdelim(char **restrict lineptr, size_t *restrict n, int delimiter, FILE *restrict stream);62ssize_t getline(char **restrict lineptr, size_t *restrict n, FILE *restrict stream);63int fseek(FILE *__stream, long int __off, int __whence);64int fseeko(FILE *__stream, off_t __off, int __whence);65long int ftell(FILE *__stream);66off_t ftello(FILE *__stream);67void rewind(FILE *__stream);68int fgetpos(FILE *restrict stream, fpos_t *restrict pos);69int fsetpos(FILE *stream, const fpos_t *pos);70void clearerr(FILE *stream);71int feof(FILE *stream);72int ferror(FILE *stream);73int fileno(FILE *stream);74int fflush(FILE *stream);75 76 77int getc(FILE *stream);78 79size_t strlen(const char *);80 81char *strcpy(char *restrict, const char *restrict);82char *strncpy(char *restrict dst, const char *restrict src, size_t n);83char *strsep(char **restrict stringp, const char *restrict delim);84void *memcpy(void *restrict dst, const void *restrict src, size_t n);85void *memset(void *s, int c, size_t n);86 87typedef unsigned long __darwin_pthread_key_t;88typedef __darwin_pthread_key_t pthread_key_t;89int pthread_setspecific(pthread_key_t, const void *);90 91int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*));92 93typedef void (*freeCallback) (void*);94typedef struct {95  int i;96  freeCallback fc;97} StWithCallback;98 99int dealocateMemWhenDoneByVal(void*, StWithCallback);100int dealocateMemWhenDoneByRef(StWithCallback*, const void*);101 102typedef struct CGContext *CGContextRef;103CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height,104                                   size_t bitsPerComponent, size_t bytesPerRow,105                                   CGColorSpaceRef space,106                                   CGBitmapInfo bitmapInfo*/);107void *CGBitmapContextGetData(CGContextRef context);108 109// Include xpc.110typedef struct _xpc_connection_s * xpc_connection_t;111typedef void (*xpc_finalizer_t)(void *value);112void xpc_connection_set_context(xpc_connection_t connection, void *context);113void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer);114void xpc_connection_resume(xpc_connection_t connection);115 116//The following are fake system header functions for generic testing.117void fakeSystemHeaderCallInt(int *);118void fakeSystemHeaderCallIntPtr(int **);119 120// Some data strauctures may hold onto the pointer and free it later.121void fake_insque(void *, void *);122typedef struct fake_rb_tree { void *opaque[8]; } fake_rb_tree_t;123void fake_rb_tree_init(fake_rb_tree_t *, const void *);124void *fake_rb_tree_insert_node(fake_rb_tree_t *, void *);125 126typedef struct __SomeStruct {127  char * p;128} SomeStruct;129void fakeSystemHeaderCall(SomeStruct *);130 131typedef int pid_t;132pid_t fork(void);133pid_t vfork(void);134int execl(const char *path, const char *arg, ...);135int execle(const char *path, const char *arg, ...);136int execlp(const char *file, const char *arg, ...);137int execv(const char *path, char *const argv[]);138int execve(const char *path, char *const argv[], char *const envp[]);139int execvp(const char *file, char *const argv[]);140int execvpe(const char *file, char *const argv[], char *const envp[]);141 142void exit(int status) __attribute__ ((__noreturn__));143void _exit(int status) __attribute__ ((__noreturn__));144void _Exit(int status) __attribute__ ((__noreturn__));145 146#define UINT32_MAX        4294967295U147#define INT64_MIN        (-INT64_MAX-1)148#define __DBL_MAX__ 1.7976931348623157e+308149#define DBL_MAX __DBL_MAX__150#ifndef NULL151#define __DARWIN_NULL 0152#define NULL __DARWIN_NULL153#endif154#define EOF (-1)155 156#define offsetof(t, d) __builtin_offsetof(t, d)157 158struct sigaction {159  void (*sa_handler)(int);160};161#define SIGINT 2162#define	SIG_IGN (void (*)(int))1163 164int sigaction(int, const struct sigaction *restrict, struct sigaction *restrict);165