Commit 5102d021 authored by Philip Carns's avatar Philip Carns Committed by Shane Snyder

alternative implementation of DARSHAN_WRAPPER_MAP

- uses function alias (via glibc's __REDIRECT macro) rather than
  generating a shim function
- this is intended to avoid possibility of infinite loop if a
  conventional PMPI instrumentation tool is used at the same time as an
  explicitly linked darshan library
parent 428247f4
......@@ -33,13 +33,13 @@
/* creates P* variant of MPI symbols for LD_PRELOAD so that we can handle
* language bindings that map to MPI or PMPI symbols under the covers.
*/
*
* We use an alias attribute rather than generating a function shim in order
* to prevent accidental function call loop if there a conventional PMPI
* profiler is attempting to intercept the same function name.
*/
#define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret __func __args { \
__ret i; \
i = __fcall; \
return i; \
}
__ret __func __args __attribute__ ((alias (#__fcall)));
/* Map the desired function call to a pointer called __real_NAME at run
* time. Note that we fall back to looking for the same symbol with a P
......@@ -64,13 +64,13 @@
/* creates P* variant of MPI symbols for static linking so that we can handle
* language bindings that map to MPI or PMPI symbols under the covers.
*
* We use an alias attribute rather than generating a function shim in order
* to prevent accidental function call loop if there a conventional PMPI
* profiler is attempting to intercept the same function name.
*/
#define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret __wrap_ ## __func __args { \
__ret i; \
i = __wrap_ ## __fcall; \
return i; \
}
__ret __wrap_ ## __func __args __attribute__ ((alias ("__wrap_" #__fcall)));
#define MAP_OR_FAIL(__func)
......
......@@ -48,7 +48,7 @@ int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv)
return(ret);
}
DARSHAN_WRAPPER_MAP(PMPI_Init, int, (int *argc, char ***argv), MPI_Init(argc,argv))
DARSHAN_WRAPPER_MAP(PMPI_Init, int, (int *argc, char ***argv), MPI_Init)
int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *provided)
{
......@@ -74,7 +74,7 @@ int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *pr
return(ret);
}
DARSHAN_WRAPPER_MAP(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided), MPI_Init_thread(argc,argv,required,provided))
DARSHAN_WRAPPER_MAP(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided), MPI_Init_thread)
int DARSHAN_DECL(MPI_Finalize)(void)
{
......@@ -87,7 +87,7 @@ int DARSHAN_DECL(MPI_Finalize)(void)
ret = __real_PMPI_Finalize();
return(ret);
}
DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize())
DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize)
#endif
/*
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment