Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
that's perfectly fine to not free that memory on process terminaison on Apple
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 12 Jun 2012 13:24:03 +0000 (15:24 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 12 Jun 2012 13:24:03 +0000 (15:24 +0200)
include/smpi/smpi_cocci.h
src/smpi/smpi_c99.c

index bcd150d..2aff10b 100644 (file)
@@ -43,7 +43,18 @@ void __attribute__((weak,destructor)) __postfini_##name(void) { \
 #define SMPI_VARGET_GLOBAL(name) name[smpi_process_index()]
 
 /* The following handle local static variables */
-
+/** @brief Make sure that the passed pointer is freed on process exit.
+ *
+ * This function is rather internal, mainly used for the
+ * privatization of global variables through coccinelle.
+ *
+ * Since its implementation relies on the on_exit() function that
+ * is not implemented on Mac, this function is a no-op on that
+ * architecture. But the only issue raised is that the memory is
+ * not raised right before the process terminaison. This is only
+ * important if you want to run valgrind on the code, or
+ * equivalent.
+ */
 XBT_PUBLIC(void) smpi_register_static(void* arg);
 
 #define SMPI_VARINIT_STATIC(name,type)                      \
index 3064783..df84a2e 100644 (file)
@@ -12,13 +12,10 @@ static void smpi_free_static(int status, void* arg) {
 }
 
 void smpi_register_static(void* arg) {
-
 #ifndef __APPLE__
-// FIXME
-// On Apple this error occurs:
-//     Undefined symbols for architecture x86_64:
-//       "_on_exit", referenced from:
-//           _smpi_register_static in smpi_c99.c.o
+  // on_exit is not implemented on Apple.
+  // That's fine, the memory won't be released on UNIX process terminaison.
+  // This means that valgrind will report it as leaked (but who cares?)
    on_exit(&smpi_free_static, arg);
 #endif
 }