Use pthread_once() when available

This commit is contained in:
Nicolas Williams
2015-11-30 11:03:56 -06:00
parent 9e359ac98f
commit 2cac8ca703
2 changed files with 83 additions and 1 deletions

View File

@@ -37,6 +37,9 @@
#define HEIM_BASE_H 1
#include <sys/types.h>
#if !defined(WIN32) && !defined(HAVE_DISPATCH_DISPATCH_H) && defined(ENABLE_PTHREAD_SUPPORT)
#include <pthread.h>
#endif
#include <krb5-types.h>
#include <stdarg.h>
#ifdef HAVE_STDBOOL_H
@@ -56,11 +59,18 @@ typedef void * heim_object_t;
typedef unsigned int heim_tid_t;
typedef heim_object_t heim_bool_t;
typedef heim_object_t heim_null_t;
# define HEIM_BASE_ONCE_INIT 0
#ifdef WIN32
typedef LONG heim_base_once_t;
#define HEIM_BASE_ONCE_INIT 0
#elif defined(HAVE_DISPATCH_DISPATCH_H)
typedef long heim_base_once_t; /* XXX arch dependant */
#define HEIM_BASE_ONCE_INIT 0
#elif defined(ENABLE_PTHREAD_SUPPORT)
typedef pthread_once_t heim_base_once_t;
#define HEIM_BASE_ONCE_INIT PTHREAD_ONCE_INIT
#else
typedef long heim_base_once_t; /* XXX arch dependant */
#define HEIM_BASE_ONCE_INIT 0
#endif
#if !defined(__has_extension)