misc.h
Go to the documentation of this file.00001 #ifndef SIM_MISC_H
00002 #define SIM_MISC_H
00003
00004
00005 #ifdef __GNUC__
00006 #define NORETURN __attribute__((__noreturn__))
00007 #else
00008 #define NORETURN
00009 #endif
00010
00011 #define CLEN(s) (sizeof((s))-1)
00012
00013 void fatal(const char *msg) NORETURN;
00014 void fatalf(const char *fmt, ...) NORETURN;
00015 void fatalfr(const char *fmt, ...) NORETURN;
00016 void debugf(const char *fmt, ...);
00017 void debugff(const char *fmt, ...);
00018
00019 FILE *ckpopen(const char *name, const char *mode);
00020 void ckpclose(FILE*);
00021
00022 FILE *ckopen(const char *name, const char *mode);
00023 void *ckalloc(size_t amount);
00024 void *ckallocz(size_t amount);
00025 void *ckfree(void *p);
00026 bool same_string(const char *s, const char *t);
00027 char *copy_string(const char *s);
00028 char *copy_substring(const char *s, int n);
00029 long ckftell(FILE*);
00030 int ckfseek(FILE*,long,int);
00031 void *ckrealloc(void *, size_t);
00032
00033 #define ZFREE(p) do{free(p);(p)=0;}while(0)
00034
00035 #ifndef RCSID
00036 #define RCSID(id) static const char rcsid[] = id
00037 #endif
00038
00039 #undef MAX
00040 #define MAX(x,y) ((x) > (y) ? (x) : (y))
00041 #undef MIN
00042 #define MIN(x,y) ((x) < (y) ? (x) : (y))
00043 #undef ICEIL
00044 #define ICEIL(x,y) ((((x)-1)/(y))+1)
00045
00046 extern int psublast_debug;
00047
00048 #endif