31#include "ple_config.h"
50#define PLE_ABS(a) ((a) < 0 ? -(a) : (a))
51#define PLE_MIN(a,b) ((a) > (b) ? (b) : (a))
52#define PLE_MAX(a,b) ((a) < (b) ? (b) : (a))
66#define PLE_MALLOC(_ptr, _ni, _type) \
67_ptr = (_type *) ple_mem_malloc(_ni, sizeof(_type), \
68 #_ptr, __FILE__, __LINE__)
82#define PLE_REALLOC(_ptr, _ni, _type) \
83_ptr = (_type *) ple_mem_realloc(_ptr, _ni, sizeof(_type), \
84 #_ptr, __FILE__, __LINE__)
100#define PLE_FREE(_ptr) \
101ple_mem_free(_ptr, #_ptr, __FILE__, __LINE__), _ptr = NULL
105#define PLE_FREE(_ptr) \
106_ptr = ple_mem_free(_ptr, #_ptr, __FILE__, __LINE__)
126#if defined(__STDC_VERSION__)
127# if (__STDC_VERSION__ >= 199901L)
143typedef int ple_lnum_t;
144typedef double ple_coord_t;
150#if defined(PLE_HAVE_MPI)
152#define PLE_MPI_TAG (int)('P'+'L'+'E')
154#define PLE_MPI_LNUM MPI_INT
155#define PLE_MPI_COORD MPI_DOUBLE
166#define PLE_UNUSED(x) (void)(x)
172#undef PLE_BEGIN_C_DECLS
173#undef PLE_END_C_DECLS
175#if defined(__cplusplus)
176# define PLE_BEGIN_C_DECLS extern "C" {
177# define PLE_END_C_DECLS }
179# define PLE_BEGIN_C_DECLS
180# define PLE_END_C_DECLS
187#undef PLE_BEGIN_EXAMPLE_SCOPE
188#undef PLE_END_EXAMPLE_SCOPE
190#define PLE_BEGIN_EXAMPLE_SCOPE {
191#define PLE_END_EXAMPLE_SCOPE }
198(ple_printf_t) (
const char *
const format,
202(ple_error_handler_t) (
const char *file_name,
204 const int sys_error_code,
209(ple_mem_malloc_t)(
size_t ni,
211 const char *var_name,
212 const char *file_name,
216(ple_mem_realloc_t)(
void *ptr,
219 const char *var_name,
220 const char *file_name,
224(ple_mem_free_t)(
void *ptr,
225 const char *var_name,
226 const char *file_name,
287 const int sys_error_code,
332 const char *var_name,
333 const char *file_name,
360 const char *var_name,
361 const char *file_name,
385 const char *var_name,
386 const char *file_name,
401 ple_mem_realloc_t **realloc_func,
402 ple_mem_free_t **free_func);
417 ple_mem_realloc_t *realloc_func,
418 ple_mem_free_t *free_func);
void ple_printf_function_set(ple_printf_t *const fct)
Associates a vprintf() type function with the ple_printf() function.
Definition ple_defs.c:401
void ple_mem_functions_get(ple_mem_malloc_t **malloc_func, ple_mem_realloc_t **realloc_func, ple_mem_free_t **free_func)
Return the function pointers associated with PLE's memory management.
Definition ple_defs.c:557
void ple_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by ple_error_handler_set() or default).
Definition ple_defs.c:423
int ple_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition ple_defs.c:367
void ple_mem_functions_set(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.
Definition ple_defs.c:583
void * ple_mem_free(void *ptr, const char *var_name, const char *file_name, int line_num)
Free allocated memory.
Definition ple_defs.c:535
double ple_timer_wtime(void)
Return Wall clock time.
Definition ple_defs.c:605
void ple_error_handler_set(ple_error_handler_t *handler)
Associates an error handler with the ple_error() function.
Definition ple_defs.c:457
void * ple_mem_malloc(size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Allocate memory for ni elements of size bytes.
Definition ple_defs.c:479
ple_printf_t * ple_printf_function_get(void)
Returns function associated with the ple_printf() function.
Definition ple_defs.c:389
void * ple_mem_realloc(void *ptr, size_t ni, size_t size, const char *var_name, const char *file_name, int line_num)
Reallocate memory for ni elements of size bytes.
Definition ple_defs.c:507
ple_error_handler_t * ple_error_handler_get(void)
Returns the error handler associated with the ple_error() function.
Definition ple_defs.c:445
double ple_timer_cpu_time(void)
Return CPU time.
Definition ple_defs.c:673