diff options
Diffstat (limited to 'lib/base/baselocl.h')
| -rw-r--r-- | lib/base/baselocl.h | 107 |
1 files changed, 19 insertions, 88 deletions
diff --git a/lib/base/baselocl.h b/lib/base/baselocl.h index b24c13d4fb24..7ca6439b33b3 100644 --- a/lib/base/baselocl.h +++ b/lib/base/baselocl.h @@ -37,6 +37,13 @@ #include <roken.h> +#define ISTILDE(x) (x == '~') +#ifdef _WIN32 +# define ISPATHSEP(x) (x == '/' || x =='\\') +#else +# define ISPATHSEP(x) (x == '/') +#endif + #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif @@ -60,94 +67,6 @@ #include <dispatch/dispatch.h> #endif -#if defined(__GNUC__) && defined(HAVE___SYNC_ADD_AND_FETCH) - -#define heim_base_atomic_inc(x) __sync_add_and_fetch((x), 1) -#define heim_base_atomic_dec(x) __sync_sub_and_fetch((x), 1) -#define heim_base_atomic_type unsigned int -#define heim_base_atomic_max UINT_MAX - -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#if __has_builtin(__sync_swap) -#define heim_base_exchange_pointer(t,v) __sync_swap((t), (v)) -#else -#define heim_base_exchange_pointer(t,v) __sync_lock_test_and_set((t), (v)) -#endif - -#elif defined(__sun) - -#include <sys/atomic.h> - -#define heim_base_atomic_inc(x) atomic_inc_uint_nv((volatile uint_t *)(x)) -#define heim_base_atomic_dec(x) atomic_dec_uint_nv((volatile uint_t *)(x)) -#define heim_base_atomic_type uint_t -#define heim_base_atomic_max UINT_MAX - -#define heim_base_exchange_pointer(t,v) atomic_swap_ptr((volatile void *)(t), (void *)(v)) - -#elif defined(_AIX) - -#include <sys/atomic_op.h> - -#define heim_base_atomic_inc(x) (fetch_and_add((atomic_p)(x)) + 1) -#define heim_base_atomic_dec(x) (fetch_and_add((atomic_p)(x)) - 1) -#define heim_base_atomic_type unsigned int -#define heim_base_atomic_max UINT_MAX - -static inline void * -heim_base_exchange_pointer(void *p, void *newval) -{ - void *val = *(void **)p; - - while (!compare_and_swaplp((atomic_l)p, (long *)&val, (long)newval)) - ; - - return val; -} - -#elif defined(_WIN32) - -#define heim_base_atomic_inc(x) InterlockedIncrement(x) -#define heim_base_atomic_dec(x) InterlockedDecrement(x) -#define heim_base_atomic_type LONG -#define heim_base_atomic_max MAXLONG - -#define heim_base_exchange_pointer(t,v) InterlockedExchangePointer((t),(v)) - -#else - -#define HEIM_BASE_NEED_ATOMIC_MUTEX 1 -extern HEIMDAL_MUTEX _heim_base_mutex; - -#define heim_base_atomic_type unsigned int - -static inline heim_base_atomic_type -heim_base_atomic_inc(heim_base_atomic_type *x) -{ - heim_base_atomic_type t; - HEIMDAL_MUTEX_lock(&_heim_base_mutex); - t = ++(*x); - HEIMDAL_MUTEX_unlock(&_heim_base_mutex); - return t; -} - -static inline heim_base_atomic_type -heim_base_atomic_dec(heim_base_atomic_type *x) -{ - heim_base_atomic_type t; - HEIMDAL_MUTEX_lock(&_heim_base_mutex); - t = --(*x); - HEIMDAL_MUTEX_unlock(&_heim_base_mutex); - return t; -} - -#define heim_base_atomic_max UINT_MAX - -#endif - /* tagged strings/object/XXX */ #define heim_base_is_tagged(x) (((uintptr_t)(x)) & 0x3) @@ -165,3 +84,15 @@ heim_base_atomic_dec(heim_base_atomic_type *x) #define HEIMDAL_NORETURN_ATTRIBUTE #undef HEIMDAL_PRINTF_ATTRIBUTE #define HEIMDAL_PRINTF_ATTRIBUTE(x) + +struct heim_context_s { + heim_log_facility *log_dest; + heim_log_facility *warn_dest; + heim_log_facility *debug_dest; + char *time_fmt; + unsigned int log_utc:1; + unsigned int homedir_access:1; + struct et_list *et_list; + char *error_string; + heim_error_code error_code; +}; |
