From 3a3bf65fe403e30d7d21b88ceb4fc11d39af5713 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 12 Jun 2012 15:24:03 +0200 Subject: [PATCH] that's perfectly fine to not free that memory on process terminaison on Apple --- include/smpi/smpi_cocci.h | 13 ++++++++++++- src/smpi/smpi_c99.c | 9 +++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/smpi/smpi_cocci.h b/include/smpi/smpi_cocci.h index bcd150d3c8..2aff10b7af 100644 --- a/include/smpi/smpi_cocci.h +++ b/include/smpi/smpi_cocci.h @@ -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) \ diff --git a/src/smpi/smpi_c99.c b/src/smpi/smpi_c99.c index 306478338a..df84a2e3b9 100644 --- a/src/smpi/smpi_c99.c +++ b/src/smpi/smpi_c99.c @@ -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 } -- 2.20.1