OpenScop 0.8.1

macros.h

Go to the documentation of this file.
00001 
00002     /*+-----------------------------------------------------------------**
00003      **                       OpenScop Library                          **
00004      **-----------------------------------------------------------------**
00005      **                           macros.h                              **
00006      **-----------------------------------------------------------------**
00007      **                   First version: 30/04/2008                     **
00008      **-----------------------------------------------------------------**
00009 
00010  
00011  *****************************************************************************
00012  * OpenScop: Structures and formats for polyhedral tools to talk together    *
00013  *****************************************************************************
00014  *    ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__,                *
00015  *    /   / /  //  //  //  // /   / /  //  //   / /  // /  /|,_,             *
00016  *   /   / /  //  //  //  // /   / /  //  //   / /  // /  / / /\             *
00017  *  |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/  \            *
00018  *  | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\  \ /\           *
00019  *  | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\          *
00020  *  | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \  \         *
00021  *  | P |n| l | = | s | t |=| = |d| = | = | = | |   |=| o | | \# \  \        *
00022  *  | H | | y |   | e | o | | = |l|   |   | = | |   | | G | |  \  \  \       *
00023  *  | I | |   |   | e |   | |   | |   |   |   | |   | |   | |   \  \  \      *
00024  *  | T | |   |   |   |   | |   | |   |   |   | |   | |   | |    \  \  \     *
00025  *  | E | |   |   |   |   | |   | |   |   |   | |   | |   | |     \  \  \    *
00026  *  | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | /      \* \  \   *
00027  *  | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/        \  \ /   *
00028  *  '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---'          '--'    *
00029  *                                                                           *
00030  * Copyright (C) 2008 University Paris-Sud 11 and INRIA                      *
00031  *                                                                           *
00032  * (3-clause BSD license)                                                    *
00033  * Redistribution and use in source  and binary forms, with or without       *
00034  * modification, are permitted provided that the following conditions        *
00035  * are met:                                                                  *
00036  *                                                                           *
00037  * 1. Redistributions of source code must retain the above copyright notice, *
00038  *    this list of conditions and the following disclaimer.                  *
00039  * 2. Redistributions in binary form must reproduce the above copyright      *
00040  *    notice, this list of conditions and the following disclaimer in the    *
00041  *    documentation and/or other materials provided with the distribution.   *
00042  * 3. The name of the author may not be used to endorse or promote products  *
00043  *    derived from this software without specific prior written permission.  *
00044  *                                                                           *
00045  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR      *
00046  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
00047  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   *
00048  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,          *
00049  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT  *
00050  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
00051  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY     *
00052  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT       *
00053  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF  *
00054  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.         *
00055  *                                                                           *
00056  * OpenScop Library, a library to manipulate OpenScop formats and data       *
00057  * structures. Written by:                                                   *
00058  * Cedric Bastoul     <Cedric.Bastoul@u-psud.fr> and                         *
00059  * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr>                          *
00060  *                                                                           *
00061  *****************************************************************************/
00062 
00063 
00064 #ifndef OSL_MACROS_H
00065 # define OSL_MACROS_H
00066 
00067 # define OSL_DEBUG                 0       // 1 for debug mode, 0 otherwise.
00068 
00069 # define OSL_TAG_START_SCOP        "<OpenScop>"
00070 # define OSL_TAG_END_SCOP          "</OpenScop>"
00071 
00072 # define OSL_PRECISION_ENV         "OSL_PRECISION"
00073 # define OSL_PRECISION_ENV_SP      "32"
00074 # define OSL_PRECISION_ENV_DP      "64"
00075 # define OSL_PRECISION_ENV_MP      "0"
00076 # define OSL_PRECISION_SP          32
00077 # define OSL_PRECISION_DP          64
00078 # define OSL_PRECISION_MP          0
00079 
00080 # define OSL_FMT_SP                "%4ld"
00081 # define OSL_FMT_DP                "%4lld"
00082 # define OSL_FMT_MP                "%4s"
00083 # define OSL_FMT_LENGTH            4       // Should be the same as FMT_*P.
00084 # define OSL_FMT_TXT_SP            "%ld"
00085 # define OSL_FMT_TXT_DP            "%lld"
00086 # define OSL_FMT_TXT_MP            "%s"
00087 
00088 
00089 # define OSL_BACKEND_C             0
00090 # define OSL_BACKEND_FORTRAN       1
00091 # define OSL_UNDEFINED             -1
00092 # define OSL_MAX_STRING            2048
00093 # define OSL_MAX_ARRAYS            128
00094 
00095 # define OSL_TYPE_GENERIC          0
00096 # define OSL_TYPE_STRING           1
00097 # define OSL_TYPE_CONTEXT          2
00098 # define OSL_TYPE_DOMAIN           3
00099 # define OSL_TYPE_SCATTERING       4
00100 # define OSL_TYPE_ACCESS           5
00101 # define OSL_TYPE_READ             6
00102 # define OSL_TYPE_WRITE            7
00103 # define OSL_TYPE_MAY_WRITE        8
00104 
00105 # define OSL_FAKE_ARRAY            "fakearray"
00106 
00107 # define OSL_STRING_UNDEFINED      "UNDEFINED"
00108 # define OSL_STRING_CONTEXT        "CONTEXT"
00109 # define OSL_STRING_DOMAIN         "DOMAIN"
00110 # define OSL_STRING_SCATTERING     "SCATTERING"
00111 # define OSL_STRING_READ           "READ"
00112 # define OSL_STRING_WRITE          "WRITE"
00113 # define OSL_STRING_MAY_WRITE      "MAY_WRITE"
00114 
00115 /*+***************************************************************************
00116  *                               UTILITY MACROS                              *
00117  *****************************************************************************/
00118 
00119 # define OSL_coucou(n)                                                     \
00120          do {                                                              \
00121            int i = n +0;                                                   \
00122            fprintf(stderr,"[osl] Coucou %d (%s).\n", i, __func__);         \
00123          } while (0)
00124 
00125 # define OSL_debug(msg)                                                    \
00126          do {                                                              \
00127            if (OSL_DEBUG)                                                  \
00128              fprintf(stderr,"[osl] Debug: "msg" (%s).\n", __func__);       \
00129          } while (0)
00130 
00131 # define OSL_info(msg)                                                     \
00132          do {                                                              \
00133            fprintf(stderr,"[osl] Info: "msg" (%s).\n", __func__);          \
00134          } while (0)
00135 
00136 # define OSL_warning(msg)                                                  \
00137          do {                                                              \
00138            fprintf(stderr,"[osl] Warning: "msg" (%s).\n", __func__);       \
00139          } while (0)
00140 
00141 # define OSL_error(msg)                                                    \
00142          do {                                                              \
00143            fprintf(stderr,"[osl] Error: "msg" (%s).\n", __func__);         \
00144            exit(1);                                                        \
00145          } while (0)
00146 
00147 # define OSL_malloc(ptr, type, size)                                       \
00148          do {                                                              \
00149            if (((ptr) = (type)malloc(size)) == NULL)                       \
00150              OSL_error("memory overflow");                                 \
00151          } while (0)
00152 
00153 # define OSL_realloc(ptr, type, size)                                      \
00154          do {                                                              \
00155            if (((ptr) = (type)realloc(ptr, size)) == NULL)                 \
00156              OSL_error("memory overflow");                                 \
00157          } while (0)
00158 
00159 # define OSL_strdup(destination, source)                                   \
00160          do {                                                              \
00161            if (source != NULL) {                                           \
00162              if (((destination) = strdup(source)) == NULL)                 \
00163                OSL_error("memory overflow");                               \
00164            }                                                               \
00165            else {                                                          \
00166              destination = NULL;                                           \
00167              OSL_warning("strdup of a NULL string");                       \
00168            }                                                               \
00169          } while (0)
00170 
00171 # define OSL_max(x,y) ((x) > (y)? (x) : (y))
00172 
00173 # define OSL_min(x,y) ((x) < (y)? (x) : (y))
00174 
00175 
00176 #endif /* define OSL_MACROS_H */