~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to salome/cfd_proxy/cfd_proxy_defs.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _CFD_PROXY_DEF_H_
 
2
#define _CFD_PROXY_DEF_H_
 
3
 
 
4
//============================================================================
 
5
// Definitions, Global variables, and basic functions
 
6
//============================================================================
 
7
 
 
8
/*
 
9
  This file is part of Code_Saturne, a general-purpose CFD tool.
 
10
 
 
11
  Copyright (C) 1998-2011 EDF S.A.
 
12
 
 
13
  This program is free software; you can redistribute it and/or modify it under
 
14
  the terms of the GNU General Public License as published by the Free Software
 
15
  Foundation; either version 2 of the License, or (at your option) any later
 
16
  version.
 
17
 
 
18
  This program is distributed in the hope that it will be useful, but WITHOUT
 
19
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
20
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
21
  details.
 
22
 
 
23
  You should have received a copy of the GNU General Public License along with
 
24
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
25
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
26
*/
 
27
 
 
28
#include "cs_config.h"
 
29
 
 
30
/*============================================================================
 
31
 * Definitions that may not always be provided directly by the system
 
32
 *============================================================================*/
 
33
 
 
34
#include <stdarg.h>
 
35
 
 
36
/*
 
37
 * Obtain definitions such as that of size_t through stddef.h (C99 standard)
 
38
 * if available (preferred method), or through stdlib.h (which defines
 
39
 * malloc() and family and so must define size_t some way) otherwise.
 
40
 */
 
41
 
 
42
#if HAVE_STDDEF_H
 
43
# include <stddef.h>
 
44
#else
 
45
# include <stdlib.h>
 
46
#endif
 
47
 
 
48
/*
 
49
 * Usually stdint.h is included by inttypes.h, but only inttypes.h exists
 
50
 * on certain systems, such as Tru64Unix
 
51
 */
 
52
 
 
53
#if HAVE_STDINT_H
 
54
# include <stdint.h>
 
55
#elif HAVE_INTTYPES_H
 
56
# include <inttypes.h>
 
57
#endif
 
58
 
 
59
/* C99 _Bool type */
 
60
 
 
61
#if HAVE_STDBOOL_H
 
62
# include <stdbool.h>
 
63
#else
 
64
# if !HAVE__BOOL
 
65
#  ifdef __cplusplus
 
66
typedef bool _Bool;
 
67
#  else
 
68
typedef unsigned char _Bool;
 
69
#  endif
 
70
# endif
 
71
# define bool _Bool
 
72
# define false 0
 
73
# define true 1
 
74
# define __bool_tru_false_are_defined 1
 
75
#endif
 
76
 
 
77
//----------------------------------------------------------------------------
 
78
 
 
79
#ifdef __cplusplus
 
80
extern "C" {
 
81
#if 0
 
82
} /* Fake brace to force back Emacs auto-indentation back to column 0 */
 
83
#endif
 
84
#endif /* __cplusplus */
 
85
 
 
86
//============================================================================
 
87
// Type definitions
 
88
//============================================================================
 
89
 
 
90
// Enum for datatype description
 
91
 
 
92
typedef enum {
 
93
  CFD_PROXY_TYPE_char,
 
94
  CFD_PROXY_TYPE_bool,
 
95
  CFD_PROXY_TYPE_int,
 
96
  CFD_PROXY_TYPE_float,
 
97
  CFD_PROXY_TYPE_double,
 
98
  CFD_PROXY_TYPE_void
 
99
} cfd_proxy_type_t;
 
100
 
 
101
//=============================================================================
 
102
// Macro definitions
 
103
//=============================================================================
 
104
 
 
105
// System name
 
106
 
 
107
#if defined(__sgi__) || defined(__sgi) || defined(sgi)
 
108
#define CFD_PROXY_ARCH_IRIX_64
 
109
 
 
110
#elif defined(__hpux__) || defined(__hpux) || defined(hpux)
 
111
#define CFD_PROXY_ARCH_HP_UX
 
112
 
 
113
#elif defined(__linux__) || defined(__linux) || defined(linux)
 
114
#define CFD_PROXY_ARCH_Linux
 
115
 
 
116
#elif defined(__sun__) || defined(__sun) || defined(sun)
 
117
#define CFD_PROXY_ARCH_SunOS
 
118
 
 
119
#elif defined(__uxpv__) || defined(__uxpv) || defined(uxpv)
 
120
#define CFD_PROXY_ARCH_UNIX_System_V
 
121
 
 
122
#endif
 
123
 
 
124
// "Classical" macros
 
125
 
 
126
#define CFD_PROXY_ABS(a)     ((a) <  0  ? -(a) : (a))
 
127
#define CFD_PROXY_MIN(a,b)   ((a) > (b) ?  (b) : (a))
 
128
#define CFD_PROXY_MAX(a,b)   ((a) < (b) ?  (b) : (a))
 
129
 
 
130
// Internationalization macros (using gettext() or some similar function).
 
131
 
 
132
#define _(String) String
 
133
#define N_(String) String
 
134
#define textdomain(String) String
 
135
#define gettext(String) String
 
136
#define dgettext(Domain,String) String
 
137
#define dcgettext(Domain,String,Type) String
 
138
#define bindtextdomain(Domain,Directory) Domain
 
139
 
 
140
// Memory allocation macros
 
141
 
 
142
// Allocate memory for _ni items of type _type.
 
143
//
 
144
// parameters:
 
145
//   _ptr  --> pointer to allocated memory.
 
146
//   _ni   <-- number of items.
 
147
//   _type <-- element type.
 
148
 
 
149
#define CFDP_MALLOC(_ptr, _ni, _type) \
 
150
_ptr = (_type *) cfd_proxy_malloc(_ni, sizeof(_type), \
 
151
                                  #_ptr, __FILE__, __LINE__)
 
152
 
 
153
// Reallocate memory for _ni items of type _type.
 
154
//
 
155
// parameters:
 
156
//   _ptr  <->  pointer to allocated memory.
 
157
//   _ni   <-- number of items.
 
158
//   _type <-- element type.
 
159
 
 
160
#define CFDP_REALLOC(_ptr, _ni, _type) \
 
161
_ptr = (_type *) cfd_proxy_realloc(_ptr, _ni, sizeof(_type), \
 
162
                                   #_ptr, __FILE__, __LINE__)
 
163
 
 
164
// Free allocated memory.
 
165
//
 
166
// The freed pointer is set to NULL to avoid accidental reuse.
 
167
//
 
168
// parameters:
 
169
//   _ptr  <->  pointer to allocated memory.
 
170
 
 
171
#define CFDP_FREE(_ptr) \
 
172
cfd_proxy_free(_ptr), _ptr = NULL
 
173
 
 
174
//=============================================================================
 
175
// Global variables
 
176
//=============================================================================
 
177
 
 
178
extern int cfd_proxy_glob_base_rank;      // Parallel rank; -1 if serial
 
179
 
 
180
extern char cfd_proxy_glob_build_date[];  // Build date
 
181
 
 
182
extern int  cfd_proxy_glob_have_mpi;      // Indicator for MPI support
 
183
extern int  cfd_proxy_glob_have_socket;   // Indicator for socket support
 
184
 
 
185
extern int     cfd_proxy_glob_n_components;
 
186
extern void  **cfd_proxy_glob_component;
 
187
 
 
188
extern size_t  cfd_proxy_glob_type_size[];  // Size associated with each type
 
189
 
 
190
//=============================================================================
 
191
// Function prototypes
 
192
//=============================================================================
 
193
 
 
194
//----------------------------------------------------------------------------
 
195
// Error handler
 
196
//----------------------------------------------------------------------------
 
197
 
 
198
void
 
199
cfd_proxy_error(const char  *filename,
 
200
                int          linenum,
 
201
                int          sys_err_code,
 
202
                const char  *format,
 
203
                ...);
 
204
 
 
205
//-----------------------------------------------------------------------------
 
206
// Print output (wrapper or replacement for printf)
 
207
//-----------------------------------------------------------------------------
 
208
 
 
209
int
 
210
cfd_proxy_printf(const char *format,
 
211
                 ...);
 
212
 
 
213
//-----------------------------------------------------------------------------
 
214
// Flush output
 
215
//-----------------------------------------------------------------------------
 
216
 
 
217
int
 
218
cfd_proxy_printf_flush(void);
 
219
 
 
220
//-----------------------------------------------------------------------------
 
221
// Print warning
 
222
//-----------------------------------------------------------------------------
 
223
 
 
224
void
 
225
cfd_proxy_warn(void);
 
226
 
 
227
// Allocate memory for ni elements of size bytes.
 
228
//
 
229
// parameters:
 
230
//   ni        <-- number of items.
 
231
//   size      <-- element size.
 
232
//   var_name  <-- allocated variable name string.
 
233
//   file_name <-- name of calling source file.
 
234
//   line_num  <-- line number in calling source file.
 
235
//
 
236
// returns:
 
237
//   pointer to allocated memory.
 
238
 
 
239
void *
 
240
cfd_proxy_malloc(size_t       ni,
 
241
                 size_t       size,
 
242
                 const char  *var_name,
 
243
                 const char  *file_name,
 
244
                 int          line_num);
 
245
 
 
246
// Reallocate memory for ni elements of size bytes.
 
247
//
 
248
// parameters:
 
249
//   ptr       <-- pointer to previous memory location
 
250
//   ni        <-- number of items.
 
251
//   size      <-- element size.
 
252
//   var_name  <-- allocated variable name string.
 
253
//   file_name <-- name of calling source file.
 
254
//   line_num   -> line number in calling source file
 
255
//
 
256
// returns:
 
257
//   pointer to allocated memory.
 
258
 
 
259
void *
 
260
cfd_proxy_realloc(void        *ptr,
 
261
                  size_t       ni,
 
262
                  size_t       size,
 
263
                  const char  *var_name,
 
264
                  const char  *file_name,
 
265
                  int          line_num);
 
266
 
 
267
// Free allocated memory.
 
268
//
 
269
// parameters:
 
270
//   ptr       <-- pointer to previous memory location
 
271
//
 
272
// returns:
 
273
//   NULL pointer.
 
274
 
 
275
void *
 
276
cfd_proxy_free(void  *ptr);
 
277
 
 
278
//-----------------------------------------------------------------------------
 
279
 
 
280
#ifdef __cplusplus
 
281
}
 
282
#endif /* __cplusplus */
 
283
 
 
284
 
 
285
#endif /* _CFD_PROXY_DEF_H_ */