OpenScop  0.9.0
macros.h
Go to the documentation of this file.
1 
2  /*+-----------------------------------------------------------------**
3  ** OpenScop Library **
4  **-----------------------------------------------------------------**
5  ** macros.h **
6  **-----------------------------------------------------------------**
7  ** First version: 30/04/2008 **
8  **-----------------------------------------------------------------**
9 
10 
11  *****************************************************************************
12  * OpenScop: Structures and formats for polyhedral tools to talk together *
13  *****************************************************************************
14  * ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
15  * / / / // // // // / / / // // / / // / /|,_, *
16  * / / / // // // // / / / // // / / // / / / /\ *
17  * |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
18  * | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
19  * | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
20  * | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
21  * | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
22  * | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
23  * | I | | | | e | | | | | | | | | | | | | \ \ \ *
24  * | T | | | | | | | | | | | | | | | | | \ \ \ *
25  * | E | | | | | | | | | | | | | | | | | \ \ \ *
26  * | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
27  * | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
28  * '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
29  * *
30  * Copyright (C) 2008 University Paris-Sud 11 and INRIA *
31  * *
32  * (3-clause BSD license) *
33  * Redistribution and use in source and binary forms, with or without *
34  * modification, are permitted provided that the following conditions *
35  * are met: *
36  * *
37  * 1. Redistributions of source code must retain the above copyright notice, *
38  * this list of conditions and the following disclaimer. *
39  * 2. Redistributions in binary form must reproduce the above copyright *
40  * notice, this list of conditions and the following disclaimer in the *
41  * documentation and/or other materials provided with the distribution. *
42  * 3. The name of the author may not be used to endorse or promote products *
43  * derived from this software without specific prior written permission. *
44  * *
45  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
46  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
47  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
48  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
49  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
50  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
51  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
52  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
53  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
54  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
55  * *
56  * OpenScop Library, a library to manipulate OpenScop formats and data *
57  * structures. Written by: *
58  * Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
59  * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
60  * *
61  *****************************************************************************/
62 
63 
64 #ifndef OSL_MACROS_H
65 # define OSL_MACROS_H
66 
67 # include "util.h"
68 
69 
70 # define OSL_DEBUG 0 // 1 for debug mode, 0 otherwise.
71 
72 # define OSL_URI_SCOP "OpenScop"
73 
74 # define OSL_PRECISION_ENV "OSL_PRECISION"
75 # define OSL_PRECISION_ENV_SP "32"
76 # define OSL_PRECISION_ENV_DP "64"
77 # define OSL_PRECISION_ENV_MP "0"
78 # define OSL_PRECISION_SP 32
79 # define OSL_PRECISION_DP 64
80 # define OSL_PRECISION_MP 0
81 
82 # define OSL_FMT_SP "%4ld"
83 # define OSL_FMT_DP "%4lld"
84 # define OSL_FMT_MP "%4s"
85 # define OSL_FMT_LENGTH 4 // Should be the same as FMT_*P.
86 # define OSL_FMT_TXT_SP "%ld"
87 # define OSL_FMT_TXT_DP "%lld"
88 # define OSL_FMT_TXT_MP "%s"
89 
90 
91 # define OSL_BACKEND_C 0
92 # define OSL_BACKEND_FORTRAN 1
93 # define OSL_UNDEFINED -1
94 # define OSL_MAX_STRING 2048
95 # define OSL_MIN_STRING 100
96 # define OSL_MAX_ARRAYS 128
97 
98 # define OSL_TYPE_GENERIC 0
99 # define OSL_TYPE_STRING 1
100 # define OSL_TYPE_CONTEXT 2
101 # define OSL_TYPE_DOMAIN 3
102 # define OSL_TYPE_SCATTERING 4
103 # define OSL_TYPE_ACCESS 5
104 # define OSL_TYPE_READ 6
105 # define OSL_TYPE_WRITE 7
106 # define OSL_TYPE_MAY_WRITE 8
107 
108 # define OSL_FAKE_ARRAY "fakearray"
109 
110 # define OSL_SYMBOL_TYPE_ITERATOR 1
111 # define OSL_SYMBOL_TYPE_PARAMETER 2
112 # define OSL_SYMBOL_TYPE_ARRAY 3
113 # define OSL_SYMBOL_TYPE_FUNCTION 4
114 
115 # define OSL_STRING_UNDEFINED "UNDEFINED"
116 # define OSL_STRING_CONTEXT "CONTEXT"
117 # define OSL_STRING_DOMAIN "DOMAIN"
118 # define OSL_STRING_SCATTERING "SCATTERING"
119 # define OSL_STRING_READ "READ"
120 # define OSL_STRING_WRITE "WRITE"
121 # define OSL_STRING_MAY_WRITE "MAY_WRITE"
122 
123 /*+***************************************************************************
124  * UTILITY MACROS *
125  *****************************************************************************/
126 
127 # define OSL_coucou(n) \
128  do { \
129  int i = n +0; \
130  fprintf(stderr,"[osl] Coucou %d (%s).\n", i, __func__); \
131  } while (0)
132 
133 # define OSL_debug(msg) \
134  do { \
135  if (OSL_DEBUG) \
136  fprintf(stderr,"[osl] Debug: " msg " (%s).\n", __func__); \
137  } while (0)
138 
139 # define OSL_info(msg) \
140  do { \
141  fprintf(stderr,"[osl] Info: " msg " (%s).\n", __func__); \
142  } while (0)
143 
144 # define OSL_warning(msg) \
145  do { \
146  fprintf(stderr,"[osl] Warning: " msg " (%s).\n", __func__); \
147  } while (0)
148 
149 # define OSL_error(msg) \
150  do { \
151  fprintf(stderr,"[osl] Error: " msg " (%s).\n", __func__); \
152  exit(1); \
153  } while (0)
154 
155 # define OSL_overflow(msg) OSL_error(msg)
156 
157 # define OSL_malloc(ptr, type, size) \
158  do { \
159  if (((ptr) = (type)malloc(size)) == NULL) \
160  OSL_error("memory overflow"); \
161  } while (0)
162 
163 # define OSL_realloc(ptr, type, size) \
164  do { \
165  if (((ptr) = (type)realloc(ptr, size)) == NULL) \
166  OSL_error("memory overflow"); \
167  } while (0)
168 
169 # define OSL_strdup(destination, source) \
170  do { \
171  if (source != NULL) { \
172  if (((destination) = osl_util_strdup(source)) == NULL) \
173  OSL_error("memory overflow"); \
174  } \
175  else { \
176  destination = NULL; \
177  OSL_warning("strdup of a NULL string"); \
178  } \
179  } while (0)
180 
181 # define OSL_max(x,y) ((x) > (y)? (x) : (y))
182 
183 # define OSL_min(x,y) ((x) < (y)? (x) : (y))
184 
185 
186 #endif /* define OSL_MACROS_H */