1
#ifndef _CFD_PROXY_DEF_H_
2
#define _CFD_PROXY_DEF_H_
4
//============================================================================
5
// Definitions, Global variables, and basic functions
6
//============================================================================
9
This file is part of Code_Saturne, a general-purpose CFD tool.
11
Copyright (C) 1998-2011 EDF S.A.
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
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
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.
28
#include "cs_config.h"
30
/*============================================================================
31
* Definitions that may not always be provided directly by the system
32
*============================================================================*/
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.
49
* Usually stdint.h is included by inttypes.h, but only inttypes.h exists
50
* on certain systems, such as Tru64Unix
56
# include <inttypes.h>
68
typedef unsigned char _Bool;
74
# define __bool_tru_false_are_defined 1
77
//----------------------------------------------------------------------------
82
} /* Fake brace to force back Emacs auto-indentation back to column 0 */
84
#endif /* __cplusplus */
86
//============================================================================
88
//============================================================================
90
// Enum for datatype description
97
CFD_PROXY_TYPE_double,
101
//=============================================================================
103
//=============================================================================
107
#if defined(__sgi__) || defined(__sgi) || defined(sgi)
108
#define CFD_PROXY_ARCH_IRIX_64
110
#elif defined(__hpux__) || defined(__hpux) || defined(hpux)
111
#define CFD_PROXY_ARCH_HP_UX
113
#elif defined(__linux__) || defined(__linux) || defined(linux)
114
#define CFD_PROXY_ARCH_Linux
116
#elif defined(__sun__) || defined(__sun) || defined(sun)
117
#define CFD_PROXY_ARCH_SunOS
119
#elif defined(__uxpv__) || defined(__uxpv) || defined(uxpv)
120
#define CFD_PROXY_ARCH_UNIX_System_V
124
// "Classical" macros
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))
130
// Internationalization macros (using gettext() or some similar function).
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
140
// Memory allocation macros
142
// Allocate memory for _ni items of type _type.
145
// _ptr --> pointer to allocated memory.
146
// _ni <-- number of items.
147
// _type <-- element type.
149
#define CFDP_MALLOC(_ptr, _ni, _type) \
150
_ptr = (_type *) cfd_proxy_malloc(_ni, sizeof(_type), \
151
#_ptr, __FILE__, __LINE__)
153
// Reallocate memory for _ni items of type _type.
156
// _ptr <-> pointer to allocated memory.
157
// _ni <-- number of items.
158
// _type <-- element type.
160
#define CFDP_REALLOC(_ptr, _ni, _type) \
161
_ptr = (_type *) cfd_proxy_realloc(_ptr, _ni, sizeof(_type), \
162
#_ptr, __FILE__, __LINE__)
164
// Free allocated memory.
166
// The freed pointer is set to NULL to avoid accidental reuse.
169
// _ptr <-> pointer to allocated memory.
171
#define CFDP_FREE(_ptr) \
172
cfd_proxy_free(_ptr), _ptr = NULL
174
//=============================================================================
176
//=============================================================================
178
extern int cfd_proxy_glob_base_rank; // Parallel rank; -1 if serial
180
extern char cfd_proxy_glob_build_date[]; // Build date
182
extern int cfd_proxy_glob_have_mpi; // Indicator for MPI support
183
extern int cfd_proxy_glob_have_socket; // Indicator for socket support
185
extern int cfd_proxy_glob_n_components;
186
extern void **cfd_proxy_glob_component;
188
extern size_t cfd_proxy_glob_type_size[]; // Size associated with each type
190
//=============================================================================
191
// Function prototypes
192
//=============================================================================
194
//----------------------------------------------------------------------------
196
//----------------------------------------------------------------------------
199
cfd_proxy_error(const char *filename,
205
//-----------------------------------------------------------------------------
206
// Print output (wrapper or replacement for printf)
207
//-----------------------------------------------------------------------------
210
cfd_proxy_printf(const char *format,
213
//-----------------------------------------------------------------------------
215
//-----------------------------------------------------------------------------
218
cfd_proxy_printf_flush(void);
220
//-----------------------------------------------------------------------------
222
//-----------------------------------------------------------------------------
225
cfd_proxy_warn(void);
227
// Allocate memory for ni elements of size bytes.
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.
237
// pointer to allocated memory.
240
cfd_proxy_malloc(size_t ni,
242
const char *var_name,
243
const char *file_name,
246
// Reallocate memory for ni elements of size bytes.
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
257
// pointer to allocated memory.
260
cfd_proxy_realloc(void *ptr,
263
const char *var_name,
264
const char *file_name,
267
// Free allocated memory.
270
// ptr <-- pointer to previous memory location
276
cfd_proxy_free(void *ptr);
278
//-----------------------------------------------------------------------------
282
#endif /* __cplusplus */
285
#endif /* _CFD_PROXY_DEF_H_ */