From 55de26d432636a95fb0dc025fa77f8bda6aca71a Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Tue, 13 Sep 2011 15:29:19 +1000 Subject: [PATCH] add GET_LAST_ERROR macro --- moonshot/mech_eap/util.h | 8 ++++++++ moonshot/mech_eap/util_context.c | 2 +- moonshot/mech_eap/util_cred.c | 4 ++-- moonshot/mech_eap/util_name.c | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/moonshot/mech_eap/util.h b/moonshot/mech_eap/util.h index 6fd31d7..5f0bc9d 100644 --- a/moonshot/mech_eap/util.h +++ b/moonshot/mech_eap/util.h @@ -776,6 +776,8 @@ verifyTokenHeader(OM_uint32 *minor, #include +#define GSSEAP_GET_LAST_ERROR() (GetLastError()) + #define GSSEAP_MUTEX CRITICAL_SECTION #define GSSEAP_MUTEX_INIT(m) (InitializeCriticalSection((m)), 0) @@ -785,10 +787,16 @@ verifyTokenHeader(OM_uint32 *minor, /* XXX yet to implement thread-local wrappers */ +#define GSSEAP_THREAD_ONCE INIT_ONCE +#define GSSEAP_ONCE(o, i) InitOnceExecuteOnce((o), (i)) +#define GSSEAP_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT + #else #include +#define GSSEAP_GET_LAST_ERROR() (errno) + #define GSSEAP_MUTEX pthread_mutex_t #define GSSEAP_MUTEX_INIT(m) pthread_mutex_init((m), NULL) diff --git a/moonshot/mech_eap/util_context.c b/moonshot/mech_eap/util_context.c index 80324bf..61b9b23 100644 --- a/moonshot/mech_eap/util_context.c +++ b/moonshot/mech_eap/util_context.c @@ -52,7 +52,7 @@ gssEapAllocContext(OM_uint32 *minor, } if (GSSEAP_MUTEX_INIT(&ctx->mutex) != 0) { - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); gssEapReleaseContext(&tmpMinor, &ctx); return GSS_S_FAILURE; } diff --git a/moonshot/mech_eap/util_cred.c b/moonshot/mech_eap/util_cred.c index 0479c59..11dcfeb 100644 --- a/moonshot/mech_eap/util_cred.c +++ b/moonshot/mech_eap/util_cred.c @@ -57,7 +57,7 @@ gssEapAllocCred(OM_uint32 *minor, gss_cred_id_t *pCred) } if (GSSEAP_MUTEX_INIT(&cred->mutex) != 0) { - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); gssEapReleaseCred(&tmpMinor, &cred); return GSS_S_FAILURE; } @@ -167,7 +167,7 @@ readStaticIdentityFile(OM_uint32 *minor, if (getpwuid_r(getuid(), &pwd, pwbuf, sizeof(pwbuf), &pw) != 0 || pw == NULL || pw->pw_dir == NULL) { major = GSS_S_CRED_UNAVAIL; - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); goto cleanup; } diff --git a/moonshot/mech_eap/util_name.c b/moonshot/mech_eap/util_name.c index e20dffd..f14ca4c 100644 --- a/moonshot/mech_eap/util_name.c +++ b/moonshot/mech_eap/util_name.c @@ -81,7 +81,7 @@ gssEapAllocName(OM_uint32 *minor, gss_name_t *pName) } if (GSSEAP_MUTEX_INIT(&name->mutex) != 0) { - *minor = errno; + *minor = GSSEAP_GET_LAST_ERROR(); gssEapReleaseName(&tmpMinor, &name); return GSS_S_FAILURE; } -- 2.1.4