File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,14 @@ AC_DEFUN([OPAL_CHECK_ATTRIBUTES], [
559559 [],
560560 [])
561561
562+ _OPAL_CHECK_SPECIFIC_ATTRIBUTE([constructor],
563+ [
564+ void foo(void) __attribute__ (( __constructor__)) ;
565+ void foo(void) { return ; }
566+ ],
567+ [],
568+ [])
569+
562570 _OPAL_CHECK_SPECIFIC_ATTRIBUTE([destructor],
563571 [
564572 void foo(void) __attribute__ (( __destructor__)) ;
@@ -631,6 +639,8 @@ AC_DEFUN([OPAL_CHECK_ATTRIBUTES], [
631639 [Whether your compiler has __attribute__ warn unused result or not])
632640 AC_DEFINE_UNQUOTED(OPAL_HAVE_ATTRIBUTE_WEAK_ALIAS, [$opal_cv___attribute__weak_alias ],
633641 [Whether your compiler has __attribute__ weak alias or not])
642+ AC_DEFINE_UNQUOTED(OPAL_HAVE_ATTRIBUTE_CONSTRUCTOR, [$opal_cv___attribute__constructor ],
643+ [Whether your compiler has __attribute__ constructor or not])
634644 AC_DEFINE_UNQUOTED(OPAL_HAVE_ATTRIBUTE_DESTRUCTOR, [$opal_cv___attribute__destructor ],
635645 [Whether your compiler has __attribute__ destructor or not])
636646 AC_DEFINE_UNQUOTED(OPAL_HAVE_ATTRIBUTE_OPTNONE, [$opal_cv___attribute__optnone ],
Original file line number Diff line number Diff line change @@ -61,11 +61,13 @@ ompi_predefined_instance_t ompi_mpi_instance_null = {{{{0}}}};
6161
6262#if defined(OPAL_RECURSIVE_MUTEX_STATIC_INIT )
6363static opal_recursive_mutex_t instance_lock = OPAL_RECURSIVE_MUTEX_STATIC_INIT ;
64- #else
64+ #elif defined( OPAL_HAVE_ATTRIBUTE_CONSTRUCTOR )
6565static opal_recursive_mutex_t instance_lock ;
66- __attribute__(( __constructor__ )) static void instance_lock_init (void ) {
66+ __opal_attribute_constructor__ static void instance_lock_init (void ) {
6767 OBJ_CONSTRUCT (& instance_lock , opal_recursive_mutex_t );
6868}
69+ #else
70+ #error "No support for recursive mutexes available on this platform.
6971#endif /* defined(OPAL_RECURSIVE_MUTEX_STATIC_INIT) */
7072
7173/** MPI_Init instance */
Original file line number Diff line number Diff line change 229229# define __opal_attribute_weak_alias__ (a )
230230#endif
231231
232+ #if OPAL_HAVE_ATTRIBUTE_CONSTRUCTOR
233+ # define __opal_attribute_constructor__ __attribute__((__constructor__))
234+ #else
235+ # define __opal_attribute_constructor__
236+ #endif
237+
232238#if OPAL_HAVE_ATTRIBUTE_DESTRUCTOR
233239# define __opal_attribute_destructor__ __attribute__((__destructor__))
234240#else
You can’t perform that action at this time.
0 commit comments