add GET_LAST_ERROR macro
authorLuke Howard <lukeh@padl.com>
Tue, 13 Sep 2011 05:29:19 +0000 (15:29 +1000)
committerLuke Howard <lukeh@padl.com>
Tue, 13 Sep 2011 05:29:19 +0000 (15:29 +1000)
mech_eap/util.h
mech_eap/util_context.c
mech_eap/util_cred.c
mech_eap/util_name.c

index 6fd31d7..5f0bc9d 100644 (file)
@@ -776,6 +776,8 @@ verifyTokenHeader(OM_uint32 *minor,
 
 #include <winbase.h>
 
+#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 <pthread.h>
 
+#define GSSEAP_GET_LAST_ERROR()                (errno)
+
 #define GSSEAP_MUTEX                    pthread_mutex_t
 
 #define GSSEAP_MUTEX_INIT(m)            pthread_mutex_init((m), NULL)
index 80324bf..61b9b23 100644 (file)
@@ -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;
     }
index 0479c59..11dcfeb 100644 (file)
@@ -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;
         }
 
index e20dffd..f14ca4c 100644 (file)
@@ -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;
     }