7 #include "utils/mono-lazy-init.h"
9 static mono_lazy_init_t error_key_once
= MONO_LAZY_INIT_STATUS_NOT_INITIALIZED
;
11 static pthread_key_t error_key
;
17 ret
= pthread_key_create (&error_key
, NULL
);
22 mono_w32error_get_last (void)
24 mono_lazy_initialize (&error_key_once
, error_key_init
);
25 return GPOINTER_TO_UINT (pthread_getspecific (error_key
));
29 mono_w32error_set_last (guint32 error
)
32 mono_lazy_initialize (&error_key_once
, error_key_init
);
33 ret
= pthread_setspecific (error_key
, GUINT_TO_POINTER (error
));
38 mono_w32error_unix_to_win32 (guint32 error
)
40 /* mapping ideas borrowed from wine. they may need some work */
45 case EROFS
: return ERROR_ACCESS_DENIED
;
46 case EAGAIN
: return ERROR_SHARING_VIOLATION
;
47 case EBUSY
: return ERROR_LOCK_VIOLATION
;
48 case EEXIST
: return ERROR_FILE_EXISTS
;
50 case ESPIPE
: return ERROR_SEEK
;
51 case EISDIR
: return ERROR_CANNOT_MAKE
;
53 case EMFILE
: return ERROR_TOO_MANY_OPEN_FILES
;
55 case ENOTDIR
: return ERROR_FILE_NOT_FOUND
;
56 case ENOSPC
: return ERROR_HANDLE_DISK_FULL
;
57 #if !defined(_AIX) || (defined(_AIX) && defined(_LINUX_SOURCE_COMPAT))
58 case ENOTEMPTY
: return ERROR_DIR_NOT_EMPTY
;
60 case ENOEXEC
: return ERROR_BAD_FORMAT
;
61 case ENAMETOOLONG
: return ERROR_FILENAME_EXCED_RANGE
;
63 case EINPROGRESS
: return ERROR_IO_PENDING
;
65 case ENOSYS
: return ERROR_NOT_SUPPORTED
;
66 case EBADF
: return ERROR_INVALID_HANDLE
;
67 case EIO
: return ERROR_INVALID_HANDLE
;
71 case EINTR
: return ERROR_IO_PENDING
; /* best match I could find */
72 case EPIPE
: return ERROR_WRITE_FAULT
;
73 case ELOOP
: return ERROR_CANT_RESOLVE_FILENAME
;
75 case ENODEV
: return ERROR_DEV_NOT_EXIST
;
78 case ENXIO
: return ERROR_DEV_NOT_EXIST
;
81 case ENOTCONN
: return ERROR_DEV_NOT_EXIST
;
84 case EHOSTDOWN
: return ERROR_DEV_NOT_EXIST
;
87 case ENEEDAUTH
: return ERROR_ACCESS_DENIED
;
91 g_warning ("%s: unknown error (%d) \"%s\"", __FILE__
, error
, g_strerror (error
));
92 return ERROR_NOT_SUPPORTED
;