Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef POCC_COMMON_H
00026 # define POCC_COMMON_H
00027
00028 # if HAVE_CONFIG_H
00029 # include <pocc-utils/config.h>
00030 # endif
00031
00032 # include <stdio.h>
00033 # include <sys/types.h>
00034
00035 # if STDC_HEADERS
00036 # include <stdlib.h>
00037 # include <string.h>
00038 # elif HAVE_STRINGS_H
00039 # include <strings.h>
00040 # endif
00041
00042 # if HAVE_UNISTD_H
00043 # include <unistd.h>
00044 # endif
00045
00046
00047 # ifdef __cplusplus
00048 # define BEGIN_C_DECLS extern "C" {
00049 # define END_C_DECLS }
00050 # else
00051 # define BEGIN_C_DECLS
00052 # define END_C_DECLS
00053 # endif
00054
00055
00056 # ifdef __GNUC__
00057 # ifndef const
00058 # define const __const
00059 # endif
00060 # ifndef signed
00061 # define signed __signed
00062 # endif
00063 # ifndef volatile
00064 # define volatile __volatile
00065 # endif
00066 # else
00067 # ifdef __STDC__
00068 # undef signed
00069 # define signed
00070 # undef volatile
00071 # define volatile
00072 # endif
00073 # endif
00074
00075 # ifdef __STDC__
00076 # define STR(x) #x
00077 # define CONC(x, y) x##y
00078 # else
00079 # define STR(x) "x"
00080 # define CONC(x, y) xy
00081 # endif
00082
00083
00084 # ifndef EXIT_SUCCESS
00085 # define EXIT_SUCCESS 0
00086 # define EXIT_FAILURE 1
00087 # endif
00088
00089
00090 # define XCALLOC(type, num) \
00091 ((type *) xcalloc ((num), sizeof(type)))
00092 # define XMALLOC(type, num) \
00093 ((type *) xmalloc ((num) * sizeof(type)))
00094 # define XREALLOC(type, p, num) \
00095 ((type *) xrealloc ((p), (num) * sizeof(type)))
00096 # define XFREE(stale) do { \
00097 if (stale) { free (stale); stale = 0; } \
00098 } while (0)
00099
00100 # define pocc_debug(S) { fprintf (stderr, #S); fprintf (stderr, "\n"); }
00101
00102 BEGIN_C_DECLS
00103
00104 extern void *xcalloc (size_t num, size_t size);
00105 extern void *xmalloc (size_t num);
00106 extern void *xrealloc (void *p, size_t num);
00107 extern char *xstrdup (const char *string);
00108 extern char *xstrerror (int errnum);
00109
00110
00111 END_C_DECLS
00112
00113 #endif // POCC_COMMON_H