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) \
101 ple_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)
162 typedef int ple_lnum_t;
163 typedef double ple_coord_t;
168 #define PLE_COORD PLE_DOUBLE
170 #if (PLE_SIZEOF_INT == 4)
171 #define PLE_LNUM PLE_INT32
172 #elif (PLE_SIZEOF_INT == 8)
173 #define PLE_LNUM PLE_INT64
182 #if defined(PLE_HAVE_MPI)
184 #define PLE_MPI_TAG (int)('P'+'L'+'E')
186 #define PLE_MPI_LNUM MPI_INT
187 #define PLE_MPI_COORD MPI_DOUBLE
195 #undef PLE_BEGIN_C_DECLS
196 #undef PLE_END_C_DECLS
198 #if defined(__cplusplus)
199 # define PLE_BEGIN_C_DECLS extern "C" {
200 # define PLE_END_C_DECLS }
202 # define PLE_BEGIN_C_DECLS
203 # define PLE_END_C_DECLS
210 #undef PLE_BEGIN_EXAMPLE_SCOPE
211 #undef PLE_END_EXAMPLE_SCOPE
213 #define PLE_BEGIN_EXAMPLE_SCOPE {
214 #define PLE_END_EXAMPLE_SCOPE }
221 (ple_printf_t) (
const char *
const format,
225 (ple_error_handler_t) (
const char *file_name,
227 const int sys_error_code,
232 (ple_mem_malloc_t)(
size_t ni,
234 const char *var_name,
235 const char *file_name,
239 (ple_mem_realloc_t)(
void *ptr,
242 const char *var_name,
243 const char *file_name,
247 (ple_mem_free_t)(
void *ptr,
248 const char *var_name,
249 const char *file_name,
258 extern const size_t ple_datatype_size[];
259 extern const char *ple_datatype_name[];
320 const int sys_error_code,
331 ple_error_handler_t *
365 const char *var_name,
366 const char *file_name,
393 const char *var_name,
394 const char *file_name,
418 const char *var_name,
419 const char *file_name,
434 ple_mem_realloc_t **realloc_func,
435 ple_mem_free_t **free_func);
450 ple_mem_realloc_t *realloc_func,
451 ple_mem_free_t *free_func);
void ple_error_handler_set(ple_error_handler_t *handler)
Associates an error handler with the ple_error() function.
Definition: ple_defs.c:453
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:419
double ple_timer_cpu_time(void)
Return CPU time.
Definition: ple_defs.c:669
ple_error_handler_t * ple_error_handler_get(void)
Returns the error handler associated with the ple_error() function.
Definition: ple_defs.c:441
int ple_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: ple_defs.c:363
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:503
ple_printf_t * ple_printf_function_get(void)
Returns function associated with the ple_printf() function.
Definition: ple_defs.c:385
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:579
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:475
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:553
void ple_printf_function_set(ple_printf_t *const fct)
Associates a vprintf() type function with the ple_printf() function.
Definition: ple_defs.c:397
void * ple_mem_free(void *ptr, const char *var_name, const char *file_name, int line_num)
Free allocated memory.
Definition: ple_defs.c:531
double ple_timer_wtime(void)
Return Wall clock time.
Definition: ple_defs.c:601