未验证 提交 58fa90be 编写于 作者: A Alexander Köplinger 提交者: GitHub

[mono] Remove w32error code (#66846)

The remaining usages can be removed.
上级 6ac764b3
......@@ -32,12 +32,10 @@ else()
endif()
set(metadata_win32_sources
w32event-win32.c
w32error-win32.c)
w32event-win32.c)
set(metadata_unix_sources
w32event-unix.c
w32error-unix.c)
w32event-unix.c)
if(HOST_WIN32)
set(metadata_platform_sources ${metadata_win32_sources})
......@@ -155,7 +153,6 @@ set(metadata_common_sources
w32event.h
w32handle.h
w32handle.c
w32error.h
reflection.c
dynamic-image.c
sre.c
......
......@@ -51,7 +51,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <mono/metadata/w32error.h>
#define INVALID_ADDRESS 0xffffffff
......@@ -1809,7 +1808,7 @@ mono_image_open_a_lot_parameterized (MonoLoadedImages *li, MonoAssemblyLoadConte
fname_utf16 = g_utf8_to_utf16 (absfname, -1, NULL, NULL, NULL);
module_handle = MonoLoadImage (fname_utf16);
if (status && module_handle == NULL)
last_error = mono_w32error_get_last ();
last_error = GetLastError ();
/* mono_image_open_from_module_handle is called by _CorDllMain. */
image = (MonoImage*)g_hash_table_lookup (loaded_images, absfname);
......
......@@ -53,7 +53,6 @@
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/w32error.h>
#include <mono/utils/w32api.h>
#include <mono/utils/mono-os-wait.h>
#include <mono/metadata/exception-internals.h>
......@@ -1270,7 +1269,7 @@ start_wrapper (gpointer data)
}
static void
throw_thread_start_exception (guint32 error_code, MonoError *error)
throw_thread_start_exception (const char *msg, MonoError *error)
{
ERROR_DECL (method_error);
......@@ -1282,9 +1281,7 @@ throw_thread_start_exception (guint32 error_code, MonoError *error)
MONO_STATIC_POINTER_INIT_END (MonoMethod, throw_method)
g_assert (throw_method);
char *msg = g_strdup_printf ("0x%x", error_code);
MonoException *ex = mono_get_exception_execution_engine (msg);
g_free (msg);
gpointer args [1];
args [0] = ex;
......@@ -1365,7 +1362,13 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoThreadStart
mono_g_hash_table_remove (threads_starting_up, thread);
mono_threads_unlock ();
throw_thread_start_exception (mono_w32error_get_last(), error);
#if HOST_WIN32
char *err_msg = g_strdup_printf ("0x%x", GetLastError ());
throw_thread_start_exception (err_msg, error);
g_free (err_msg);
#else
throw_thread_start_exception ("mono_thread_platform_create_thread() failed", error);
#endif
/* ref is not going to be decremented in start_wrapper_internal */
mono_atomic_dec_i32 (&start_info->ref);
......
/**
* \file
*/
#include "w32error.h"
#include "utils/mono-lazy-init.h"
static mono_lazy_init_t error_key_once = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
static pthread_key_t error_key;
static void
error_key_init (void)
{
gint ret;
ret = pthread_key_create (&error_key, NULL);
g_assert (ret == 0);
}
guint32
mono_w32error_get_last (void)
{
mono_lazy_initialize (&error_key_once, error_key_init);
return GPOINTER_TO_UINT (pthread_getspecific (error_key));
}
void
mono_w32error_set_last (guint32 error)
{
gint ret;
mono_lazy_initialize (&error_key_once, error_key_init);
ret = pthread_setspecific (error_key, GUINT_TO_POINTER (error));
g_assert (ret == 0);
}
guint32
mono_w32error_unix_to_win32 (guint32 error)
{
/* mapping ideas borrowed from wine. they may need some work */
switch (error) {
case EACCES:
case EPERM:
case EROFS: return ERROR_ACCESS_DENIED;
case EAGAIN: return ERROR_SHARING_VIOLATION;
case EBUSY: return ERROR_LOCK_VIOLATION;
case EEXIST: return ERROR_FILE_EXISTS;
case EINVAL:
case ESPIPE: return ERROR_SEEK;
case EISDIR: return ERROR_CANNOT_MAKE;
case ENFILE:
case EMFILE: return ERROR_TOO_MANY_OPEN_FILES;
case ENOENT:
case ENOTDIR: return ERROR_FILE_NOT_FOUND;
case ENOSPC: return ERROR_HANDLE_DISK_FULL;
#if !defined(_AIX) || (defined(_AIX) && defined(_LINUX_SOURCE_COMPAT))
case ENOTEMPTY: return ERROR_DIR_NOT_EMPTY;
#endif
case ENOEXEC: return ERROR_BAD_FORMAT;
case ENAMETOOLONG: return ERROR_FILENAME_EXCED_RANGE;
#ifdef EINPROGRESS
case EINPROGRESS: return ERROR_IO_PENDING;
#endif
case ENOSYS: return ERROR_NOT_SUPPORTED;
case EBADF: return ERROR_INVALID_HANDLE;
case EIO: return ERROR_INVALID_HANDLE;
#ifdef ERESTART
case ERESTART:
#endif
case EINTR: return ERROR_IO_PENDING; /* best match I could find */
case EPIPE: return ERROR_WRITE_FAULT;
case ELOOP: return ERROR_CANT_RESOLVE_FILENAME;
#ifdef ENODEV
case ENODEV: return ERROR_DEV_NOT_EXIST;
#endif
#ifdef ENXIO
case ENXIO: return ERROR_DEV_NOT_EXIST;
#endif
#ifdef ENOTCONN
case ENOTCONN: return ERROR_DEV_NOT_EXIST;
#endif
#ifdef EHOSTDOWN
case EHOSTDOWN: return ERROR_DEV_NOT_EXIST;
#endif
#ifdef ENEEDAUTH
case ENEEDAUTH: return ERROR_ACCESS_DENIED;
#endif
default:
g_warning ("%s: unknown error (%d) \"%s\"", __FILE__, error, g_strerror (error));
return ERROR_NOT_SUPPORTED;
}
}
/**
* \file
*/
#include <windows.h>
#include "w32error.h"
guint32
mono_w32error_get_last (void)
{
return GetLastError ();
}
void
mono_w32error_set_last (guint32 error)
{
SetLastError (error);
}
guint32
mono_w32error_unix_to_win32 (guint32 error)
{
g_assert_not_reached ();
}
/**
* \file
*/
#ifndef _MONO_METADATA_W32ERROR_H_
#define _MONO_METADATA_W32ERROR_H_
#include <config.h>
#include <glib.h>
#if !defined(HOST_WIN32)
#define ERROR_SUCCESS 0
#define ERROR_FILE_NOT_FOUND 2
#define ERROR_PATH_NOT_FOUND 3
#define ERROR_TOO_MANY_OPEN_FILES 4
#define ERROR_ACCESS_DENIED 5
#define ERROR_INVALID_HANDLE 6
#define ERROR_NOT_ENOUGH_MEMORY 8
#define ERROR_BAD_FORMAT 11
#define ERROR_INVALID_ACCESS 12
#define ERROR_INVALID_DATA 13
#define ERROR_OUTOFMEMORY 14
#define ERROR_NOT_SAME_DEVICE 17
#define ERROR_NO_MORE_FILES 18
#define ERROR_BAD_LENGTH 24
#define ERROR_SEEK 25
#define ERROR_WRITE_FAULT 29
#define ERROR_GEN_FAILURE 31
#define ERROR_SHARING_VIOLATION 32
#define ERROR_LOCK_VIOLATION 33
#define ERROR_HANDLE_DISK_FULL 39
#define ERROR_NOT_SUPPORTED 50
#define ERROR_DEV_NOT_EXIST 55
#define ERROR_FILE_EXISTS 80
#define ERROR_CANNOT_MAKE 82
#define ERROR_INVALID_PARAMETER 87
#define ERROR_INVALID_NAME 123
#define ERROR_PROC_NOT_FOUND 127
#define ERROR_DIR_NOT_EMPTY 145
#define ERROR_ALREADY_EXISTS 183
#define ERROR_BAD_EXE_FORMAT 193
#define ERROR_FILENAME_EXCED_RANGE 206
#define ERROR_DIRECTORY 267
#define ERROR_IO_PENDING 997
#define ERROR_CANT_RESOLVE_FILENAME 1921
#define ERROR_ENCRYPTION_FAILED 6000
#define WSA_INVALID_PARAMETER ERROR_INVALID_PARAMETER
#define WSA_INVALID_HANDLE ERROR_INVALID_HANDLE
#define WSAEINTR 10004
#define WSAEBADF 10009
#define WSAEACCES 10013
#define WSAEFAULT 10014
#define WSAEINVAL 10022
#define WSAEMFILE 10024
#define WSAEWOULDBLOCK 10035
#define WSAEINPROGRESS 10036
#define WSAEALREADY 10037
#define WSAENOTSOCK 10038
#define WSAEDESTADDRREQ 10039
#define WSAEMSGSIZE 10040
#define WSAEPROTOTYPE 10041
#define WSAENOPROTOOPT 10042
#define WSAEPROTONOSUPPORT 10043
#define WSAESOCKTNOSUPPORT 10044
#define WSAEOPNOTSUPP 10045
#define WSAEAFNOSUPPORT 10047
#define WSAEADDRINUSE 10048
#define WSAEADDRNOTAVAIL 10049
#define WSAENETDOWN 10050
#define WSAENETUNREACH 10051
#define WSAECONNRESET 10054
#define WSAENOBUFS 10055
#define WSAEISCONN 10056
#define WSAENOTCONN 10057
#define WSAESHUTDOWN 10058
#define WSAETIMEDOUT 10060
#define WSAECONNREFUSED 10061
#define WSAELOOP 10062
#define WSAENAMETOOLONG 10063
#define WSAEHOSTDOWN 10064
#define WSAEHOSTUNREACH 10065
#define WSASYSCALLFAILURE 10107
#define WSAENXIO 100001
#endif
guint32
mono_w32error_get_last (void);
void
mono_w32error_set_last (guint32 error);
guint32
mono_w32error_unix_to_win32 (guint32 error);
#endif /* _MONO_METADATA_W32ERROR_H_ */
......@@ -10,7 +10,6 @@
#include "w32event.h"
#include "w32error.h"
#include "mono/utils/mono-error-internals.h"
#include "mono/utils/mono-logger-internals.h"
#include "mono/metadata/handle.h"
......@@ -108,17 +107,7 @@ mono_w32event_init (void)
gpointer
mono_w32event_create (gboolean manual, gboolean initial)
{
/* Need to blow away any old errors here, because code tests
* for ERROR_ALREADY_EXISTS on success (!) to see if an event
* was freshly created */
mono_w32error_set_last (ERROR_SUCCESS);
gpointer handle = event_create (manual, initial);
gint32 win32error = mono_w32error_get_last ();
g_assert ((win32error != ERROR_SUCCESS) == !handle);
return handle;
return event_create (manual, initial);
}
......@@ -140,7 +129,6 @@ static gpointer event_handle_create (MonoW32HandleEvent *event_handle, MonoW32Ty
if (handle == INVALID_HANDLE_VALUE) {
g_warning ("%s: error creating %s handle",
__func__, mono_w32handle_get_typename (type));
mono_w32error_set_last (ERROR_GEN_FAILURE);
return NULL;
}
......@@ -181,13 +169,11 @@ mono_w32event_set (gpointer handle)
if (!mono_w32handle_lookup_and_ref (handle, &handle_data)) {
g_warning ("%s: unkown handle %p", __func__, handle);
mono_w32error_set_last (ERROR_INVALID_HANDLE);
return;
}
if (handle_data->type != MONO_W32TYPE_EVENT) {
g_warning ("%s: unkown event handle %p", __func__, handle);
mono_w32error_set_last (ERROR_INVALID_HANDLE);
mono_w32handle_unref (handle_data);
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册