Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MPI_Win_post, MPI_Win_start, MPI_Win_complete, and MPI_Win_wait support.
[simgrid.git] / src / smpi / smpi_c99.c
1 /* Copyright (c) 2011-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <xbt/dynar.h>
8 #include "private.h"
9
10 typedef struct s_smpi_static {
11   void *ptr;
12   void_f_pvoid_t free_fn;
13 } s_smpi_static_t;
14
15 static xbt_dynar_t registered_static_stack = NULL;
16
17 void smpi_register_static(void* arg, void_f_pvoid_t free_fn)
18 {
19   s_smpi_static_t elm = { arg, free_fn };
20   if (!registered_static_stack)
21     registered_static_stack = xbt_dynar_new(sizeof(s_smpi_static_t), NULL);
22   xbt_dynar_push_as(registered_static_stack, s_smpi_static_t, elm);
23 }
24
25 void smpi_free_static(void)
26 {
27   while (!xbt_dynar_is_empty(registered_static_stack)) {
28     s_smpi_static_t elm =
29       xbt_dynar_pop_as(registered_static_stack, s_smpi_static_t);
30     elm.free_fn(elm.ptr);
31   }
32   xbt_dynar_free(&registered_static_stack);
33 }