File tree Expand file tree Collapse file tree 6 files changed +29
-12
lines changed
Expand file tree Collapse file tree 6 files changed +29
-12
lines changed Original file line number Diff line number Diff line change 99#include <stdio.h>
1010#include <string.h>
1111
12- void AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * funcptrs )
12+ int AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * funcptrs , size_t size )
1313{
14+ if (sizeof (* funcptrs ) != size )
15+ return 1 ;
16+
1417#define AMPI_CUSTOM_FUNC (return_type , function_name , ...) \
1518 funcptrs->function_name = &function_name;
1619#if AMPI_HAVE_PMPI
@@ -27,6 +30,8 @@ void AMPI_FuncPtr_Pack(struct AMPI_FuncPtr_Transport * funcptrs)
2730#undef AMPI_FUNC
2831#undef AMPI_FUNC_NOIMPL
2932#undef AMPI_CUSTOM_FUNC
33+
34+ return 0 ;
3035}
3136
3237AMPI_FuncPtr_Unpack_t AMPI_FuncPtr_Unpack_Locate (SharedObject myexe )
Original file line number Diff line number Diff line change 44#include "ampiimpl.h"
55#include "ampi_funcptr.h"
66
7- void AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * );
7+ int AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * , size_t );
88
9- typedef int (* AMPI_FuncPtr_Unpack_t )(const struct AMPI_FuncPtr_Transport * );
9+ typedef int (* AMPI_FuncPtr_Unpack_t )(const struct AMPI_FuncPtr_Transport * , size_t );
1010AMPI_FuncPtr_Unpack_t AMPI_FuncPtr_Unpack_Locate (SharedObject );
1111
1212#endif /* AMPI_FUNCPTR_LOADER_H_ */
Original file line number Diff line number Diff line change 11
22#include "ampi_funcptr_loader.h"
33
4- void AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * funcptrs )
4+ int AMPI_FuncPtr_Pack (struct AMPI_FuncPtr_Transport * , size_t )
55{
6- ( void ) funcptrs ;
6+ return 0 ;
77}
88
9- AMPI_FuncPtr_Unpack_t AMPI_FuncPtr_Unpack_Locate (SharedObject myexe )
9+ AMPI_FuncPtr_Unpack_t AMPI_FuncPtr_Unpack_Locate (SharedObject )
1010{
11- (void )myexe ;
1211 return nullptr ;
1312}
Original file line number Diff line number Diff line change 2121
2222// Provide an interface to link the function pointers at runtime.
2323
24- extern "C" CMI_EXPORT void AMPI_FuncPtr_Unpack (const struct AMPI_FuncPtr_Transport * funcptrs )
24+ extern "C" CMI_EXPORT int AMPI_FuncPtr_Unpack (const struct AMPI_FuncPtr_Transport * funcptrs , size_t size )
2525{
26+ if (sizeof (* funcptrs ) != size )
27+ return 1 ;
28+
2629#define AMPI_CUSTOM_FUNC (return_type , function_name , ...) \
2730 function_name = funcptrs->function_name;
2831#if AMPI_HAVE_PMPI
@@ -39,4 +42,6 @@ extern "C" CMI_EXPORT void AMPI_FuncPtr_Unpack(const struct AMPI_FuncPtr_Transpo
3942#undef AMPI_FUNC
4043#undef AMPI_FUNC_NOIMPL
4144#undef AMPI_CUSTOM_FUNC
45+
46+ return 0 ;
4247}
Original file line number Diff line number Diff line change @@ -84,7 +84,8 @@ void AMPI_Node_Setup(int numranks)
8484 CmiPrintf ("AMPI> Using fsglobals privatization method.\n" );
8585
8686 AMPI_FuncPtr_Transport funcptrs {};
87- AMPI_FuncPtr_Pack (& funcptrs );
87+ if (AMPI_FuncPtr_Pack (& funcptrs , sizeof (funcptrs )))
88+ CkAbort ("Globals runtime linking pack failed due to mismatch!" );
8889
8990 static const char exe_suffix [] = STRINGIFY (CMK_POST_EXE );
9091 static const char user_suffix [] = STRINGIFY (CMK_USER_SUFFIX );
@@ -124,7 +125,10 @@ void AMPI_Node_Setup(int numranks)
124125
125126 auto unpack = AMPI_FuncPtr_Unpack_Locate (myexe );
126127 if (unpack != nullptr )
127- unpack (& funcptrs );
128+ {
129+ if (unpack (& funcptrs , sizeof (funcptrs )))
130+ CkAbort ("Globals runtime linking unpack failed due to mismatch!" );
131+ }
128132
129133 rankdata [myrank ].exe = myexe ;
130134 rankdata [myrank ].mainstruct = AMPI_Main_Get (myexe );
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ void AMPI_Node_Setup(int numranks)
1919 CmiPrintf ("AMPI> Using pipglobals privatization method.\n" );
2020
2121 AMPI_FuncPtr_Transport funcptrs {};
22- AMPI_FuncPtr_Pack (& funcptrs );
22+ if (AMPI_FuncPtr_Pack (& funcptrs , sizeof (funcptrs )))
23+ CkAbort ("Globals runtime linking pack failed due to mismatch!" );
2324
2425 static const char exe_suffix [] = STRINGIFY (CMK_POST_EXE );
2526 static const char suffix [] = STRINGIFY (CMK_USER_SUFFIX ) "." STRINGIFY (CMK_SHARED_SUF );
@@ -49,7 +50,10 @@ void AMPI_Node_Setup(int numranks)
4950
5051 auto unpack = AMPI_FuncPtr_Unpack_Locate (myexe );
5152 if (unpack != nullptr )
52- unpack (& funcptrs );
53+ {
54+ if (unpack (& funcptrs , sizeof (funcptrs )))
55+ CkAbort ("Globals runtime linking unpack failed due to mismatch!" );
56+ }
5357
5458 rankdata [myrank ].exe = myexe ;
5559 rankdata [myrank ].mainstruct = AMPI_Main_Get (myexe );
You can’t perform that action at this time.
0 commit comments