/usr/include/ple_defs.h is in code-saturne-include 4.3.3+repack-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | #ifndef __PLE_DEFS_H__
#define __PLE_DEFS_H__
/*============================================================================
* Definitions, global variables, and base functions
*============================================================================*/
/*
This file is part of the "Parallel Location and Exchange" library,
intended to provide mesh or particle-based code coupling services.
Copyright (C) 2005-2016 EDF
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*----------------------------------------------------------------------------*/
#include "ple_config.h"
/*----------------------------------------------------------------------------*/
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#if 0
} /* Fake brace to force back Emacs auto-indentation back to column 0 */
#endif
#endif /* __cplusplus */
/*=============================================================================
* Macro definitions
*============================================================================*/
/* Absolute, minimum, and maximum values */
#define PLE_ABS(a) ((a) < 0 ? -(a) : (a)) /* Absolute value of a */
#define PLE_MIN(a,b) ((a) > (b) ? (b) : (a)) /* Minimum of a et b */
#define PLE_MAX(a,b) ((a) < (b) ? (b) : (a)) /* Maximum of a et b */
/*
* Allocate memory for _ni items of type _type.
*
* This macro calls ple_mem_malloc(), automatically setting the
* allocated variable name and source file name and line arguments.
*
* parameters:
* _ptr --> pointer to allocated memory.
* _ni <-- number of items.
* _type <-- element type.
*/
#define PLE_MALLOC(_ptr, _ni, _type) \
_ptr = (_type *) ple_mem_malloc(_ni, sizeof(_type), \
#_ptr, __FILE__, __LINE__)
/*
* Reallocate memory for _ni items of type _type.
*
* This macro calls ple_mem_realloc(), automatically setting the
* allocated variable name and source file name and line arguments.
*
* parameters:
* _ptr <-> pointer to allocated memory.
* _ni <-- number of items.
* _type <-- element type.
*/
#define PLE_REALLOC(_ptr, _ni, _type) \
_ptr = (_type *) ple_mem_realloc(_ptr, _ni, sizeof(_type), \
#_ptr, __FILE__, __LINE__)
/*
* Free allocated memory.
*
* This macro calls ple_mem_free(), automatically setting the
* allocated variable name and source file name and line arguments.
*
* The freed pointer is set to NULL to avoid accidental reuse.
*
* parameters:
* _ptr <-> pointer to allocated memory.
*/
#ifdef __cplusplus /* avoid casting from void for C++ */
#define PLE_FREE(_ptr) \
ple_mem_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
#else
#define PLE_FREE(_ptr) \
_ptr = ple_mem_free(_ptr, #_ptr, __FILE__, __LINE__)
#endif /* __cplusplus */
/*============================================================================
* Type definitions
*============================================================================*/
/*----------------------------------------------------------------------------
* General C types such as size_t which should be known
*----------------------------------------------------------------------------*/
/*
* Obtain definitions such as that of size_t through stddef.h (C99 standard)
* if available (preferred method), or through stdlib.h (which defines
* malloc() and family and so must define size_t some way) otherwise.
* This must be done in ple_defs.h in a way independent of the private
* configuration files, as size_t is used in many public FVM headers.
*/
#if defined(__STDC_VERSION__)
# if (__STDC_VERSION__ >= 199901L)
# include <stddef.h>
# else
# include <stdlib.h>
# endif
#else
# include <stdlib.h>
#endif
/*----------------------------------------------------------------------------
* Variable value type.
*----------------------------------------------------------------------------*/
typedef enum {
PLE_DATATYPE_NULL, /* empty datatype */
PLE_CHAR, /* character values */
PLE_FLOAT, /* 4-byte floating point values */
PLE_DOUBLE, /* 8-byte floating point values */
PLE_INT32, /* 4-byte signed integer values */
PLE_INT64, /* 8-byte signed integer values */
PLE_UINT32, /* 4-byte unsigned integer values */
PLE_UINT64 /* 8-byte unsigned integer values */
} ple_datatype_t;
/*----------------------------------------------------------------------------
* Basic types used by PLE.
* They may be modified here to better map to a given library, with the
* following constraints:
* - ple_lnum_t must be signed
*----------------------------------------------------------------------------*/
/* Other types */
typedef int ple_lnum_t; /* Local integer index or number */
typedef double ple_coord_t; /* Real number (coordinate value) */
/* Mappings to PLE datatypes */
/*---------------------------*/
#define PLE_COORD PLE_DOUBLE
#if (PLE_SIZEOF_INT == 4)
#define PLE_LNUM PLE_INT32
#elif (PLE_SIZEOF_INT == 8)
#define PLE_LNUM PLE_INT64
#else
#error
#endif
/*----------------------------------------------------------------------------
* MPI datatypes.
*----------------------------------------------------------------------------*/
#if defined(PLE_HAVE_MPI)
#define PLE_MPI_TAG (int)('P'+'L'+'E') /* MPI tag for PLE operations */
#define PLE_MPI_LNUM MPI_INT /* MPI type for ple_lnum_t type */
#define PLE_MPI_COORD MPI_DOUBLE /* MPI type for ple_coord_t type */
#endif
/*----------------------------------------------------------------------------
* Macro used to silence "unused argument" warnings.
*
* This is useful when a function must match a given function pointer
* type, but does not use all possible arguments.
*----------------------------------------------------------------------------*/
#define PLE_UNUSED(x) (void)(x)
/*----------------------------------------------------------------------------
* Macros for compilation with a C++ compiler
*----------------------------------------------------------------------------*/
#undef PLE_BEGIN_C_DECLS
#undef PLE_END_C_DECLS
#if defined(__cplusplus)
# define PLE_BEGIN_C_DECLS extern "C" {
# define PLE_END_C_DECLS }
#else
# define PLE_BEGIN_C_DECLS
# define PLE_END_C_DECLS
#endif
/*----------------------------------------------------------------------------
* Macros for scoping of examples
*----------------------------------------------------------------------------*/
#undef PLE_BEGIN_EXAMPLE_SCOPE
#undef PLE_END_EXAMPLE_SCOPE
#define PLE_BEGIN_EXAMPLE_SCOPE {
#define PLE_END_EXAMPLE_SCOPE }
/*----------------------------------------------------------------------------
* Function pointer types
*----------------------------------------------------------------------------*/
typedef int
(ple_printf_t) (const char *const format,
va_list arg_ptr);
typedef void
(ple_error_handler_t) (const char *file_name,
const int line_num,
const int sys_error_code,
const char *format,
va_list arg_ptr);
typedef void *
(ple_mem_malloc_t)(size_t ni,
size_t size,
const char *var_name,
const char *file_name,
int line_num);
typedef void *
(ple_mem_realloc_t)(void *ptr,
size_t ni,
size_t size,
const char *var_name,
const char *file_name,
int line_num);
typedef void *
(ple_mem_free_t)(void *ptr,
const char *var_name,
const char *file_name,
int line_num);
/*=============================================================================
* Static global variables
*============================================================================*/
/* Sizes and names associated with datatypes */
extern const size_t ple_datatype_size[];
extern const char *ple_datatype_name[];
/*============================================================================
* Public function prototypes
*============================================================================*/
/*!
* \brief Replacement for printf() with modifiable behavior.
*
* This function calls vprintf() by default, or a function with similar
* arguments indicated by ple_printf_function_set().
*
* \param [in] format format string, as printf() and family.
* \param [in] ... variable arguments based on format string.
*
* \return number of characters printed, not counting the trailing '\\0'
* used to end output strings
*/
int
ple_printf(const char *const format,
...);
/* Returns function associated with the ple_printf() function.
*
* returns:
* pointer to the vprintf() or replacement function.
*/
ple_printf_t *
ple_printf_function_get(void);
/*
* Associates a vprintf() type function with the ple_printf() function.
*
* parameters:
* f <-- pointer to a vprintf() type function.
*/
void
ple_printf_function_set(ple_printf_t *f);
/*
* Calls the error handler (set by ple_error_handler_set() or default).
*
* With the default error handler, an error message is output to stderr,
* and the current process exits with an EXIT_FAILURE code.
*
* parameters:
* file_name <-- name of source file from which error handler called.
* line_num <-- line of source file from which error handler called.
* sys_error_code <-- error code if error in system or libc call,
* 0 otherwise.
* format <-- format string, as printf() and family.
* ... <-- variable arguments based on format string.
*/
void
ple_error(const char *file_name,
const int line_num,
const int sys_error_code,
const char *format,
...);
/*
* Returns the error handler associated with the ple_error() function.
*
* returns:
* pointer to the error handler function.
*/
ple_error_handler_t *
ple_error_handler_get(void);
/*
* Associates an error handler with the ple_error() function.
*
* parameters:
* handler <-- pointer to the error handler function.
*/
void
ple_error_handler_set(ple_error_handler_t *handler);
/*
* Allocate memory for ni items of size bytes.
*
* This function calls malloc(), but adds tracing capabilities, and
* automatically calls the ple_error() errorhandler if it fails to
* allocate the required memory.
*
* parameters:
* ni <-- number of items.
* size <-- element size.
* var_name <-- allocated variable name string.
* file_name <-- name of calling source file.
* line_num <-- line number in calling source file.
*
* returns:
* pointer to allocated memory.
*/
void *
ple_mem_malloc(size_t ni,
size_t size,
const char *var_name,
const char *file_name,
int line_num);
/*
* Reallocate memory for ni items of size bytes.
*
* This function calls realloc(), but adds tracing capabilities, and
* automatically calls the ple_error() errorhandler if it fails to
* allocate the required memory.
*
* parameters:
* ptr <-> pointer to previous memory location
* (if NULL, ple_alloc() called).
* ni <-- number of items.
* size <-- element size.
* var_name <-- allocated variable name string.
* file_name <-- name of calling source file.
* line_num -> line number in calling source file
*
* returns:
* pointer to allocated memory.
*/
void *
ple_mem_realloc(void *ptr,
size_t ni,
size_t size,
const char *var_name,
const char *file_name,
int line_num);
/*
* Free allocated memory.
*
* This function calls free(), but adds tracing capabilities, and
* automatically calls the ple_error() errorhandler if it fails to
* free the corresponding memory. In case of a NULL pointer argument,
* the function simply returns.
*
* parameters:
* ptr <-> pointer to previous memory location
* (if NULL, ple_alloc() called).
* var_name <-- allocated variable name string.
* file_name <-- name of calling source file.
* line_num <-- line number in calling source file.
*
* returns:
* NULL pointer.
*/
void *
ple_mem_free(void *ptr,
const char *var_name,
const char *file_name,
int line_num);
/* Return the function pointers associated with PLE's memory management.
*
* All arguments are optional.
*
* parameters:
* malloc_func <-- pointer to ple_mem_malloc function pointer (or NULL).
* realloc_func <-- pointer to ple_mem_realloc function pointer (or NULL).
* free_func <-- pointer to ple_mem_free function pointer (or NULL).
*/
void
ple_mem_functions_get(ple_mem_malloc_t **malloc_func,
ple_mem_realloc_t **realloc_func,
ple_mem_free_t **free_func);
/* Associate functions to modifiy PLE's memory management.
*
* All arguments are optional, so the previously set functions pointers will
* not be modified if an argument value is NULL.
*
* parameters:
* malloc_func <-- ple_mem_malloc function pointer (or NULL).
* realloc_func <-- ple_mem_realloc function pointer (or NULL).
* free_func <-- ple_mem_free function pointer (or NULL).
*/
void
ple_mem_functions_set(ple_mem_malloc_t *malloc_func,
ple_mem_realloc_t *realloc_func,
ple_mem_free_t *free_func);
/*
* Return Wall clock time
*
* returns:
* elapsed time from first call of a function of the ple_timer_...()
* series, or -1 if unable to compute.
*/
double
ple_timer_wtime(void);
/*
* Return CPU time.
*
* Note that in the rare case that only the minimal C library clock()
* method is available (see ple_timer_cpu_time_method()), at least one of
* the ple_timer_...() functions (possibly this one) must be called
* upon program start for this function to be used. In addition,
* in this case, time may "loop" back to 0 every multiple of
* 2^size_t / CLOCKS_PER_SEC seconds.
*
* returns:
* current CPU time usage, or -1 if unable to compute.
*/
double
ple_timer_cpu_time(void);
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PLE_DEFS_H__ */
|