From de0856b198be8de817d9c0d496f5bdc0f426084a Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 25 Jun 2013 17:57:46 +0200 Subject: [PATCH] try again and again to be more portable with this test --- include/smpi/smpi.h | 2 +- teshsuite/smpi/shared.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 52e112d215..035c074bdd 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -516,7 +516,7 @@ XBT_PUBLIC(void*) smpi_shared_get_call(const char* func, const char* input); XBT_PUBLIC(void*) smpi_shared_set_call(const char* func, const char* input, void* data); #define SMPI_SHARED_CALL(func, input, ...) \ (smpi_shared_known_call(#func, input) ? smpi_shared_get_call(#func, input) \ - : smpi_shared_set_call(#func, input, (void*)(func(__VA_ARGS__)))) + : smpi_shared_set_call(#func, input, (func(__VA_ARGS__)))) /* Fortran specific stuff */ XBT_PUBLIC(int) __attribute__((weak)) smpi_simulated_main_(int argc, char** argv); diff --git a/teshsuite/smpi/shared.c b/teshsuite/smpi/shared.c index 15b1a3a6cd..1a6ac0554d 100644 --- a/teshsuite/smpi/shared.c +++ b/teshsuite/smpi/shared.c @@ -11,16 +11,16 @@ #include #include -uint64_t hash(char *str); +void* hash(char *str, uint64_t* ans); -uint64_t hash(char *str) +void* hash(char *str, uint64_t* ans) { - uint64_t hash = 5381; + *ans=5381; int c; printf("hashing !\n"); while ((c = *str++)!=0) - hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ - return hash; + *ans = ((*ans << 5) + *ans) + c; /* hash * 33 + c */ + return NULL; } @@ -46,15 +46,16 @@ int main(int argc, char *argv[]) //Try SMPI_SHARED_CALL function, which should call hash only once and for all. char *str = strdup("onceandforall"); if(rank==size-1){ - *buf=(uint64_t)SMPI_SHARED_CALL(hash,str,str); + SMPI_SHARED_CALL(hash,str,str,buf); } MPI_Barrier(MPI_COMM_WORLD); - printf("[%d] After change, the value in the shared buffer is: %lu\n", rank, *buf); - + printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf); SMPI_SHARED_FREE(buf); + buf=NULL; + free(str); MPI_Finalize(); return 0; -- 2.20.1