PoCC Version 1.0
|
00001 /* 00002 * common.h: this file is part of the PoCC project. 00003 * 00004 * PoCC, the Polyhedral Compiler Collection package 00005 * 00006 * Copyright (C) 2009 Louis-Noel Pouchet 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * The complete GNU General Public Licence Notice can be found as the 00019 * `COPYING.LESSER' file in the root directory. 00020 * 00021 * Author: 00022 * Louis-Noel Pouchet <Louis-Noel.Pouchet@inria.fr> 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 /*STDC_HEADERS*/ 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) x/**/y 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