Commit 405131f9 authored by Shane Snyder's avatar Shane Snyder

Merge branch 'carns/dev-wrapper-map-alias' into 'master'

alternative implementation of DARSHAN_WRAPPER_MAP

See merge request !39
parents 428247f4 5102d021
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
/* creates P* variant of MPI symbols for LD_PRELOAD so that we can handle /* 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. * 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) \ #define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret __func __args { \ __ret __func __args __attribute__ ((alias (#__fcall)));
__ret i; \
i = __fcall; \
return i; \
}
/* Map the desired function call to a pointer called __real_NAME at run /* 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 * time. Note that we fall back to looking for the same symbol with a P
...@@ -64,13 +64,13 @@ ...@@ -64,13 +64,13 @@
/* creates P* variant of MPI symbols for static linking so that we can handle /* 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. * 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) \ #define DARSHAN_WRAPPER_MAP(__func,__ret,__args,__fcall) \
__ret __wrap_ ## __func __args { \ __ret __wrap_ ## __func __args __attribute__ ((alias ("__wrap_" #__fcall)));
__ret i; \
i = __wrap_ ## __fcall; \
return i; \
}
#define MAP_OR_FAIL(__func) #define MAP_OR_FAIL(__func)
......
...@@ -48,7 +48,7 @@ int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv) ...@@ -48,7 +48,7 @@ int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv)
return(ret); 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) 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 ...@@ -74,7 +74,7 @@ int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *pr
return(ret); 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) int DARSHAN_DECL(MPI_Finalize)(void)
{ {
...@@ -87,7 +87,7 @@ int DARSHAN_DECL(MPI_Finalize)(void) ...@@ -87,7 +87,7 @@ int DARSHAN_DECL(MPI_Finalize)(void)
ret = __real_PMPI_Finalize(); ret = __real_PMPI_Finalize();
return(ret); return(ret);
} }
DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize()) DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize)
#endif #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