Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
extend std namespace with our own definitions.
[simgrid.git] / include / smpi / smpi_helpers.h
1 /* Copyright (c) 2018-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SMPI_HELPERS_H
7 #define SMPI_HELPERS_H
8
9 #ifndef _GNU_SOURCE
10 #define _GNU_SOURCE
11 #endif
12
13 #include <smpi/smpi_helpers_internal.h>
14 #ifndef TRACE_CALL_LOCATION /* Defined by smpicc on the command line */
15 #define sleep(x) smpi_sleep(x)
16 #define usleep(x) smpi_usleep(x)
17 #else
18 #define sleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_sleep(x))
19 #define usleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_usleep(x))
20 #endif
21
22 #define gettimeofday(x, y) smpi_gettimeofday((x), 0)
23 #if _POSIX_TIMERS > 0
24 #ifndef TRACE_CALL_LOCATION /* Defined by smpicc on the command line */
25 #define nanosleep(x, y) smpi_nanosleep((x), (y))
26 #else
27 #define nanosleep(x) (smpi_trace_set_call_location(__FILE__, __LINE__), smpi_nanosleep(x))
28 #endif
29 #define clock_gettime(x, y) smpi_clock_gettime((x), (y))
30 #endif
31
32 #define getopt(x, y, z) smpi_getopt((x), (y), (z))
33 #define getopt_long(x, y, z, a, b) smpi_getopt_long((x), (y), (z), (a), (b))
34 #define getopt_long_only(x, y, z, a, b) smpi_getopt_long_only((x), (y), (z), (a), (b))
35 #ifndef SMPI_NO_OVERRIDE_MALLOC
36 #ifdef __cplusplus
37 namespace std {
38     extern "C" void* smpi_shared_malloc_intercept(size_t size, const char* file, int line);
39     extern "C" void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line);
40     extern "C" void* smpi_shared_realloc_intercept(void* data, size_t size, const char* file, int line);
41     extern "C" void smpi_shared_free(void* ptr);
42 }
43 #endif
44 #define malloc(x) smpi_shared_malloc_intercept((x), __FILE__, __LINE__)
45 #define calloc(x, y) smpi_shared_calloc_intercept((x), (y), __FILE__, __LINE__)
46 #define realloc(x, y) smpi_shared_realloc_intercept((x), (y), __FILE__, __LINE__)
47 #define free(x) smpi_shared_free(x)
48 #endif
49
50 #ifdef __cplusplus
51 namespace std {
52   extern "C" __attribute__((noreturn)) void smpi_exit(int status);
53 }
54 #endif
55 #define exit(x) smpi_exit(x)
56
57 #endif