X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mech_eap%2Futil.h;h=04fa4b9db59061e29efbfb0dc74fd4ff30ed48f8;hb=733651ae26e4d340969941676fdd3021a1de16d2;hp=a27209f4a142074276b012ba8182acb2d484e084;hpb=5104037ae15cdc1cf39eb27baf2a4e73d044ff9f;p=mech_eap.orig diff --git a/mech_eap/util.h b/mech_eap/util.h index a27209f..04fa4b9 100644 --- a/mech_eap/util.h +++ b/mech_eap/util.h @@ -61,12 +61,22 @@ #ifndef _UTIL_H_ #define _UTIL_H_ 1 +#ifdef HAVE_SYS_PARAM_H #include +#endif +#ifdef HAVE_STDINT_H +#include +#endif #include #include #include +#ifdef WIN32 +#define inline __inline +#define snprintf _snprintf +#endif + #ifdef __cplusplus extern "C" { #endif @@ -75,7 +85,7 @@ extern "C" { #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) #endif -#if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +#if !defined(WIN32) && (!(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))) #define GSSEAP_UNUSED __attribute__ ((__unused__)) #else #define GSSEAP_UNUSED @@ -748,8 +758,13 @@ verifyTokenHeader(OM_uint32 *minor, #define GSSAPI_CALLCONV KRB5_CALLCONV #endif +#ifdef WIN32 +#define GSSEAP_CONSTRUCTOR +#define GSSEAP_DESTRUCTOR +#else #define GSSEAP_CONSTRUCTOR __attribute__((constructor)) #define GSSEAP_DESTRUCTOR __attribute__((destructor)) +#endif #define GSSEAP_NOT_IMPLEMENTED do { \ assert(0 && "not implemented"); \ @@ -757,10 +772,24 @@ verifyTokenHeader(OM_uint32 *minor, return GSS_S_FAILURE; \ } while (0) +#ifdef WIN32 + +#include + +#define GSSEAP_MUTEX CRITICAL_SECTION + +#define GSSEAP_MUTEX_INIT(m) (InitializeCriticalSection((m)), 0) +#define GSSEAP_MUTEX_DESTROY(m) DeleteCriticalSection((m)) +#define GSSEAP_MUTEX_LOCK(m) EnterCriticalSection((m)) +#define GSSEAP_MUTEX_UNLOCK(m) LeaveCriticalSection((m)) + +/* XXX yet to implement thread-local wrappers */ + +#else + #include #define GSSEAP_MUTEX pthread_mutex_t -#define GSSEAP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define GSSEAP_MUTEX_INIT(m) pthread_mutex_init((m), NULL) #define GSSEAP_MUTEX_DESTROY(m) pthread_mutex_destroy((m)) @@ -776,6 +805,8 @@ verifyTokenHeader(OM_uint32 *minor, #define GSSEAP_ONCE(o, i) pthread_once((o), (i)) #define GSSEAP_ONCE_INITIALIZER PTHREAD_ONCE_INIT +#endif /* WIN32 */ + /* Helper functions */ static inline void store_uint16_be(uint16_t val, void *vp)