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 198 #define PLE_UNUSED(x) (void)(x) 204 #undef PLE_BEGIN_C_DECLS 205 #undef PLE_END_C_DECLS 207 #if defined(__cplusplus) 208 # define PLE_BEGIN_C_DECLS extern "C" { 209 # define PLE_END_C_DECLS } 211 # define PLE_BEGIN_C_DECLS 212 # define PLE_END_C_DECLS 219 #undef PLE_BEGIN_EXAMPLE_SCOPE 220 #undef PLE_END_EXAMPLE_SCOPE 222 #define PLE_BEGIN_EXAMPLE_SCOPE { 223 #define PLE_END_EXAMPLE_SCOPE } 230 (ple_printf_t) (
const char *
const format,
234 (ple_error_handler_t) (
const char *file_name,
236 const int sys_error_code,
241 (ple_mem_malloc_t)(
size_t ni,
243 const char *var_name,
244 const char *file_name,
248 (ple_mem_realloc_t)(
void *ptr,
251 const char *var_name,
252 const char *file_name,
256 (ple_mem_free_t)(
void *ptr,
257 const char *var_name,
258 const char *file_name,
267 extern const size_t ple_datatype_size[];
268 extern const char *ple_datatype_name[];
328 const int sys_error_code,
339 ple_error_handler_t *
373 const char *var_name,
374 const char *file_name,
401 const char *var_name,
402 const char *file_name,
426 const char *var_name,
427 const char *file_name,
442 ple_mem_realloc_t **realloc_func,
443 ple_mem_free_t **free_func);
458 ple_mem_realloc_t *realloc_func,
459 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:457
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
double ple_timer_cpu_time(void)
Return CPU time.
Definition: ple_defs.c:673
ple_error_handler_t * ple_error_handler_get(void)
Returns the error handler associated with the ple_error() function.
Definition: ple_defs.c:445
int ple_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: ple_defs.c:367
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_printf_t * ple_printf_function_get(void)
Returns function associated with the ple_printf() function.
Definition: ple_defs.c:389
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_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
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_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_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