Skip to content

Commit 067adfa

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]>
1 parent c672a51 commit 067adfa

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
@@ -174,7 +174,7 @@ char MPIR_attach_fifo[MPIR_MAX_PATH_LENGTH] = {0};
174174
int MPIR_force_to_main = 0;
175175
static void orte_debugger_init_before_spawn(orte_job_t *jdata);
176176

177-
ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void);
177+
ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint(void);
178178

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

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

205217
/* local objects */

0 commit comments

Comments
 (0)