1 /* Copyright (c) 2011. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 /* Macros used by coccinelle-generated code */
12 #define SMPI_INITIALIZE_GLOBAL(name,type) \
14 void __attribute__((weak,constructor)) __preinit_##name(void) { \
16 name = (type*)malloc(smpi_global_size() * sizeof(type)); \
18 void __attribute__((weak,destructor)) __postfini_##name(void) { \
23 #define SMPI_INITIALIZE_AND_SET_GLOBAl(name,type,expr) \
25 void __attribute__((weak,constructor)) __preinit_##name(void) { \
26 size_t size = smpi_global_size(); \
30 name = (type*)malloc(size * sizeof(type)); \
31 for(i = 0; i < size; i++) { \
36 void __attribute__((weak,destructor)) __postfini_##name(void) { \
41 #define SMPI_GLOBAL_VAR_LOCAL_ACCESS(name) name[__rank()]
43 /* This function stores the rank locally, so that a request in
44 SIMIX is not created each time */
45 int __attribute__((weak)) __rank(void) {
46 static __thread int rank = -1;
49 rank = smpi_global_rank();