Skip to content

Commit

Permalink
[mono] Remove w32error code (dotnet#66846)
Browse files Browse the repository at this point in the history
The remaining usages can be removed.
  • Loading branch information
akoeplinger authored and radekdoulik committed Mar 30, 2022
1 parent b6b87b7 commit 0262b86
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 243 deletions.
7 changes: 2 additions & 5 deletions src/mono/mono/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -155,7 +153,6 @@ set(metadata_common_sources
w32event.h
w32handle.h
w32handle.c
w32error.h
reflection.c
dynamic-image.c
sre.c
Expand Down
3 changes: 1 addition & 2 deletions src/mono/mono/metadata/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <mono/metadata/w32error.h>

#define INVALID_ADDRESS 0xffffffff

Expand Down Expand Up @@ -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);
Expand Down
13 changes: 8 additions & 5 deletions src/mono/mono/metadata/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
94 changes: 0 additions & 94 deletions src/mono/mono/metadata/w32error-unix.c

This file was deleted.

25 changes: 0 additions & 25 deletions src/mono/mono/metadata/w32error-win32.c

This file was deleted.

97 changes: 0 additions & 97 deletions src/mono/mono/metadata/w32error.h

This file was deleted.

16 changes: 1 addition & 15 deletions src/mono/mono/metadata/w32event-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0262b86

Please sign in to comment.