2 * error.c: Error reporting
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
14 #include "mono/io-layer/wapi.h"
16 static pthread_key_t error_key;
17 static pthread_once_t error_key_once=PTHREAD_ONCE_INIT;
19 static void error_init(void)
21 pthread_key_create(&error_key, NULL);
27 * Retrieves the last error that occurred in the calling thread.
29 * Return value: The error code for the last error that happened on
32 guint32 GetLastError(void)
37 pthread_once(&error_key_once, error_init);
38 errptr=pthread_getspecific(error_key);
39 err=GPOINTER_TO_UINT(errptr);
46 * @code: The error code.
48 * Sets the error code in the calling thread.
50 void SetLastError(guint32 code)
52 /* Set the thread-local error code */
53 pthread_once(&error_key_once, error_init);
54 pthread_setspecific(error_key, GUINT_TO_POINTER(code));