pthread_mutex_unlock(&( m ## _mutex)); \
} while(0)
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
#else
*********************************************************/
bool uid_wrapper_enabled(void);
+void uwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
void uwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
/*********************************************************
UWRAP_LOG(UWRAP_LOG_DEBUG, "Initialize uid_wrapper");
- /*
- * If we hold a lock and the application forks, then the child
- * is not able to unlock the mutex and we are in a deadlock.
- * This should prevent such deadlocks.
- */
- pthread_atfork(&uwrap_thread_prepare,
- &uwrap_thread_parent,
- &uwrap_thread_child);
-
UWRAP_LOCK(uwrap_id);
uwrap.initialised = true;
#endif /* HAVE_SYSCALL */
#endif /* HAVE_SYS_SYSCALL_H || HAVE_SYSCALL_H */
+/****************************
+ * CONSTRUCTOR
+ ***************************/
+void uwrap_constructor(void)
+{
+ /*
+ * If we hold a lock and the application forks, then the child
+ * is not able to unlock the mutex and we are in a deadlock.
+ * This should prevent such deadlocks.
+ */
+ pthread_atfork(&uwrap_thread_prepare,
+ &uwrap_thread_parent,
+ &uwrap_thread_child);
+}
+
/****************************
* DESTRUCTOR
***************************/
addmain=False,
msg='Checking for thread local storage')
+ # check HAVE_CONSTRUCTOR_ATTRIBUTE
+ conf.CHECK_CODE('''
+ void test_constructor_attribute(void) __attribute__ ((constructor));
+
+ void test_constructor_attribute(void)
+ {
+ return;
+ }
+
+ int main(void) {
+ return 0;
+ }
+ ''',
+ 'HAVE_CONSTRUCTOR_ATTRIBUTE',
+ addmain=False,
+ msg='Checking for library constructor support')
+
# check HAVE_DESTRUCTOR_ATTRIBUTE
conf.CHECK_CODE('''
void test_destructor_attribute(void) __attribute__ ((destructor));