OpenScop  0.9.0
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 # include "util.h"
00068 
00069 
00070 # define OSL_DEBUG                 0       // 1 for debug mode, 0 otherwise.
00071 
00072 # define OSL_URI_SCOP              "OpenScop"
00073 
00074 # define OSL_PRECISION_ENV         "OSL_PRECISION"
00075 # define OSL_PRECISION_ENV_SP      "32"
00076 # define OSL_PRECISION_ENV_DP      "64"
00077 # define OSL_PRECISION_ENV_MP      "0"
00078 # define OSL_PRECISION_SP          32
00079 # define OSL_PRECISION_DP          64
00080 # define OSL_PRECISION_MP          0
00081 
00082 # define OSL_FMT_SP                "%4ld"
00083 # define OSL_FMT_DP                "%4lld"
00084 # define OSL_FMT_MP                "%4s"
00085 # define OSL_FMT_LENGTH            4       // Should be the same as FMT_*P.
00086 # define OSL_FMT_TXT_SP            "%ld"
00087 # define OSL_FMT_TXT_DP            "%lld"
00088 # define OSL_FMT_TXT_MP            "%s"
00089 
00090 
00091 # define OSL_BACKEND_C             0
00092 # define OSL_BACKEND_FORTRAN       1
00093 # define OSL_UNDEFINED             -1
00094 # define OSL_MAX_STRING            2048
00095 # define OSL_MIN_STRING            100
00096 # define OSL_MAX_ARRAYS            128
00097 
00098 # define OSL_TYPE_GENERIC          0
00099 # define OSL_TYPE_STRING           1
00100 # define OSL_TYPE_CONTEXT          2
00101 # define OSL_TYPE_DOMAIN           3
00102 # define OSL_TYPE_SCATTERING       4
00103 # define OSL_TYPE_ACCESS           5
00104 # define OSL_TYPE_READ             6
00105 # define OSL_TYPE_WRITE            7
00106 # define OSL_TYPE_MAY_WRITE        8
00107 
00108 # define OSL_FAKE_ARRAY            "fakearray"
00109 
00110 # define OSL_SYMBOL_TYPE_ITERATOR       1
00111 # define OSL_SYMBOL_TYPE_PARAMETER      2
00112 # define OSL_SYMBOL_TYPE_ARRAY          3
00113 # define OSL_SYMBOL_TYPE_FUNCTION       4
00114 
00115 # define OSL_STRING_UNDEFINED      "UNDEFINED"
00116 # define OSL_STRING_CONTEXT        "CONTEXT"
00117 # define OSL_STRING_DOMAIN         "DOMAIN"
00118 # define OSL_STRING_SCATTERING     "SCATTERING"
00119 # define OSL_STRING_READ           "READ"
00120 # define OSL_STRING_WRITE          "WRITE"
00121 # define OSL_STRING_MAY_WRITE      "MAY_WRITE"
00122 
00123 /*+***************************************************************************
00124  *                               UTILITY MACROS                              *
00125  *****************************************************************************/
00126 
00127 # define OSL_coucou(n)                                                     \
00128          do {                                                              \
00129            int i = n +0;                                                   \
00130            fprintf(stderr,"[osl] Coucou %d (%s).\n", i, __func__);         \
00131          } while (0)
00132 
00133 # define OSL_debug(msg)                                                    \
00134          do {                                                              \
00135            if (OSL_DEBUG)                                                  \
00136              fprintf(stderr,"[osl] Debug: " msg " (%s).\n", __func__);     \
00137          } while (0)
00138 
00139 # define OSL_info(msg)                                                     \
00140          do {                                                              \
00141            fprintf(stderr,"[osl] Info: " msg " (%s).\n", __func__);        \
00142          } while (0)
00143 
00144 # define OSL_warning(msg)                                                  \
00145          do {                                                              \
00146            fprintf(stderr,"[osl] Warning: " msg " (%s).\n", __func__);     \
00147          } while (0)
00148 
00149 # define OSL_error(msg)                                                    \
00150          do {                                                              \
00151            fprintf(stderr,"[osl] Error: " msg " (%s).\n", __func__);       \
00152            exit(1);                                                        \
00153          } while (0)
00154 
00155 # define OSL_overflow(msg) OSL_error(msg)
00156 
00157 # define OSL_malloc(ptr, type, size)                                       \
00158          do {                                                              \
00159            if (((ptr) = (type)malloc(size)) == NULL)                       \
00160              OSL_error("memory overflow");                                 \
00161          } while (0)
00162 
00163 # define OSL_realloc(ptr, type, size)                                      \
00164          do {                                                              \
00165            if (((ptr) = (type)realloc(ptr, size)) == NULL)                 \
00166              OSL_error("memory overflow");                                 \
00167          } while (0)
00168 
00169 # define OSL_strdup(destination, source)                                   \
00170          do {                                                              \
00171            if (source != NULL) {                                           \
00172              if (((destination) = osl_util_strdup(source)) == NULL)                 \
00173                OSL_error("memory overflow");                               \
00174            }                                                               \
00175            else {                                                          \
00176              destination = NULL;                                           \
00177              OSL_warning("strdup of a NULL string");                       \
00178            }                                                               \
00179          } while (0)
00180 
00181 # define OSL_max(x,y) ((x) > (y)? (x) : (y))
00182 
00183 # define OSL_min(x,y) ((x) < (y)? (x) : (y))
00184 
00185 
00186 #endif /* define OSL_MACROS_H */