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_VARINIT_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_VARINIT_GLOBAL_AND_SET(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_VARGET_GLOBAL(name) name[smpi_process_index()]