Skip to content

Commit 3eb7b27

Browse files
committed
Conform MPIR_Breakpoint to MPIR standard.
- Fix MPIR_Breakpoint standard violation by returning void instead of a void*. Signed-off-by: Austen Lauria <[email protected]> (cherry picked from commit 067adfa)
1 parent 90b55db commit 3eb7b27

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

orte/orted/orted_submit.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ char MPIR_attach_fifo[MPIR_MAX_PATH_LENGTH] = {0};
173173
int MPIR_force_to_main = 0;
174174
static void orte_debugger_init_before_spawn(orte_job_t *jdata);
175175

176-
ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void);
176+
ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint(void);
177177

178178
/*
179179
* Attempt to prevent the compiler from optimizing out
@@ -191,14 +191,26 @@ ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void);
191191
* See the following git issue for more discussion:
192192
* https://github.com/open-mpi/ompi/issues/5501
193193
*/
194-
static volatile void* volatile noop_mpir_breakpoint_ptr = NULL;
194+
volatile void* volatile noop_mpir_breakpoint_ptr = NULL;
195195

196196
/*
197197
* Breakpoint function for parallel debuggers
198198
*/
199-
void* MPIR_Breakpoint(void)
199+
void MPIR_Breakpoint(void)
200200
{
201-
return noop_mpir_breakpoint_ptr;
201+
/*
202+
* Actually do something with this pointer to make
203+
* sure the compiler does not optimize out this function.
204+
* The compiler should be forced to keep this
205+
* function around due to the volatile void* type.
206+
*
207+
* This pointer doesn't actually do anything other than
208+
* prevent unwanted optimization, and
209+
* *should not* be used anywhere else in the code.
210+
* So pointing this to the weeds should be OK.
211+
*/
212+
noop_mpir_breakpoint_ptr = (volatile void *) 0x42;
213+
return;
202214
}
203215

204216
/* local objects */

0 commit comments

Comments
 (0)