symbol tables of the current process. */
#if defined(HAVE_PRAGMA_WEAK_REF) && !defined(NO_WEAK_PTHREADS)
-# pragma weak pthread_once
-# pragma weak pthread_mutex_lock
-# pragma weak pthread_mutex_unlock
-# pragma weak pthread_mutex_destroy
-# pragma weak pthread_mutex_init
-# pragma weak pthread_self
-# pragma weak pthread_equal
-# define USE_PTHREAD_LOCK_ONLY_IF_LOADED
+# define USE_CONDITIONAL_PTHREADS
+#endif
+
+#ifdef USE_CONDITIONAL_PTHREADS
/* Can't rely on useful stubs -- see above regarding Solaris. */
typedef struct {
# define K5_OS_MUTEX_PARTIAL_INITIALIZER \
PTHREAD_MUTEX_INITIALIZER
-#ifdef USE_PTHREAD_LOCK_ONLY_IF_LOADED
+#ifdef USE_CONDITIONAL_PTHREADS
-# define USE_PTHREAD_LOADED_MUTEX_FUNCTIONS
# define k5_os_mutex_finish_init(M) (0)
int k5_os_mutex_init(k5_os_mutex *m);
int k5_os_mutex_destroy(k5_os_mutex *m);
MAKE_INIT_FUNCTION(krb5int_thread_support_init);
MAKE_FINI_FUNCTION(krb5int_thread_support_fini);
-#undef k5_once
+/* This function used to be referenced from elsewhere in the tree, but is now
+ * only used internally. Keep it linker-visible for now. */
+int krb5int_pthread_loaded(void);
#ifndef ENABLE_THREADS /* no thread support */
return 0;
}
-int
-k5_once(k5_once_t *once, void (*fn)(void))
-{
- return k5_os_nothread_once(once, fn);
-}
-
#elif defined(_WIN32)
static DWORD tls_idx;
}
}
-/* Stub functions not used on Windows. */
+/* Stub function not used on Windows. */
int krb5int_pthread_loaded (void)
{
return 0;
}
-int
-k5_once(k5_once_t *once, void (*fn)(void))
-{
- return 0;
-}
#else /* POSIX threads */
/* Must support register/delete/register sequence, e.g., if krb5 is
};
#ifdef HAVE_PRAGMA_WEAK_REF
+# pragma weak pthread_once
+# pragma weak pthread_mutex_lock
+# pragma weak pthread_mutex_unlock
+# pragma weak pthread_mutex_destroy
+# pragma weak pthread_mutex_init
+# pragma weak pthread_self
+# pragma weak pthread_equal
# pragma weak pthread_getspecific
# pragma weak pthread_setspecific
# pragma weak pthread_key_create
return flag_pthread_loaded;
}
-int
-k5_once(k5_once_t *once, void (*fn)(void))
-{
- if (krb5int_pthread_loaded())
- return pthread_once(&once->o, fn);
- else
- return k5_os_nothread_once(&once->n, fn);
-}
-
static struct tsd_block tsd_if_single;
# define GET_NO_PTHREAD_TSD() (&tsd_if_single)
#else
return 1;
}
-int
-k5_once(k5_once_t *once, void (*fn)(void))
-{
- return pthread_once(once, fn);
-}
# define GET_NO_PTHREAD_TSD() (abort(),(struct tsd_block *)0)
#endif
k5_mutex_unlock (m);
}
-#ifdef USE_PTHREAD_LOADED_MUTEX_FUNCTIONS
+#ifdef USE_CONDITIONAL_PTHREADS
int
k5_os_mutex_init(k5_os_mutex *m)
return 0;
}
-#else /* USE_PTHREAD_LOADED_MUTEX_FUNCTIONS */
+int
+k5_once(k5_once_t *once, void (*fn)(void))
+{
+ if (krb5int_pthread_loaded())
+ return pthread_once(&once->o, fn);
+ else
+ return k5_os_nothread_once(&once->n, fn);
+}
+
+#else /* USE_CONDITIONAL_PTHREADS */
#undef k5_os_mutex_init
#undef k5_os_mutex_destroy
#undef k5_os_mutex_lock
#undef k5_os_mutex_unlock
+#undef k5_once
+
+int k5_os_mutex_init(k5_os_mutex *m);
+int k5_os_mutex_destroy(k5_os_mutex *m);
+int k5_os_mutex_lock(k5_os_mutex *m);
+int k5_os_mutex_unlock(k5_os_mutex *m);
+int k5_once(k5_once_t *once, void (*fn)(void));
/* Stub functions */
int
{
return 0;
}
+int
+k5_once(k5_once_t *once, void (*fn)(void))
+{
+ return 0;
+}
-#endif /* USE_PTHREAD_LOADED_MUTEX_FUNCTIONS */
+#endif /* not USE_CONDITIONAL_PTHREADS */