Merge branch 'win32-unicode-api' into 'main'

Windows: Compile with the UNICODE / _UNICODE macros

See merge request GNOME/glib!3623
This commit is contained in:
Philip Withnall
2023-10-16 08:58:41 +00:00
10 changed files with 97 additions and 50 deletions

View File

@@ -2201,6 +2201,7 @@ _g_win32_socketpair (gint domain,
SOCKET client = INVALID_SOCKET;
SOCKET server = INVALID_SOCKET;
gchar *path = NULL;
wchar_t *path_utf16 = NULL;
int tmpfd, rv = -1;
u_long arg, br;
@@ -2230,7 +2231,11 @@ _g_win32_socketpair (gint domain,
if (listener == INVALID_SOCKET)
goto out;
if (DeleteFile (path) == 0)
path_utf16 = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
if (!path_utf16)
goto out;
if (DeleteFile (path_utf16) == 0)
{
if (GetLastError () != ERROR_FILE_NOT_FOUND)
goto out;
@@ -2285,7 +2290,10 @@ _g_win32_socketpair (gint domain,
if (server != INVALID_SOCKET)
closesocket (server);
DeleteFile (path);
if (path_utf16)
DeleteFile (path_utf16);
g_free (path_utf16);
g_free (path);
return rv;
}

View File

@@ -340,17 +340,21 @@ test_pipe_io_overlap (void)
PipeIOOverlapReader rs, rc;
HANDLE server, client;
gchar name[256];
wchar_t *name_utf16;
g_snprintf (name, sizeof (name),
"\\\\.\\pipe\\gtest-io-overlap-%u", (guint) GetCurrentProcessId ());
server = CreateNamedPipe (name,
name_utf16 = g_utf8_to_utf16 (name, -1, NULL, NULL, NULL);
g_assert_nonnull (name_utf16);
server = CreateNamedPipe (name_utf16,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_READMODE_BYTE | PIPE_WAIT,
1, 0, 0, 0, NULL);
g_assert (server != INVALID_HANDLE_VALUE);
client = CreateFile (name, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
client = CreateFile (name_utf16, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
g_assert (client != INVALID_HANDLE_VALUE);
out_server = g_win32_output_stream_new (server, TRUE);
@@ -372,6 +376,8 @@ test_pipe_io_overlap (void)
g_object_unref (rc.in);
g_object_unref (out_server);
g_object_unref (out_client);
g_free (name_utf16);
}
static gpointer
@@ -419,18 +425,22 @@ test_pipe_io_concurrent (void)
PipeIOOverlapReader rc1, rc2;
HANDLE server, client;
gchar name[256], c;
wchar_t *name_utf16;
g_snprintf (name, sizeof (name),
"\\\\.\\pipe\\gtest-io-concurrent-%u", (guint) GetCurrentProcessId ());
server = CreateNamedPipe (name,
name_utf16 = g_utf8_to_utf16 (name, -1, NULL, NULL, NULL);
g_assert_nonnull (name_utf16);
server = CreateNamedPipe (name_utf16,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_READMODE_BYTE | PIPE_WAIT,
1, 0, 0, 0, NULL);
g_assert (server != INVALID_HANDLE_VALUE);
g_assert (_pipe (writer_pipe, 10, _O_BINARY) == 0);
client = CreateFile (name, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
client = CreateFile (name_utf16, GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
g_assert (client != INVALID_HANDLE_VALUE);
rc1.in = g_win32_input_stream_new (client, TRUE);
@@ -467,6 +477,8 @@ test_pipe_io_concurrent (void)
close (writer_pipe[0]);
close (writer_pipe[1]);
g_free (name_utf16);
}
static void
@@ -491,17 +503,21 @@ test_pipe_io_cancel (void)
GOutputStream *out;
HANDLE in_handle, out_handle;
gchar name[256];
wchar_t *name_utf16;
g_snprintf (name, sizeof (name),
"\\\\.\\pipe\\gtest-io-cancel-%u", (guint) GetCurrentProcessId ());
in_handle = CreateNamedPipe (name,
name_utf16 = g_utf8_to_utf16 (name, -1, NULL, NULL, NULL);
g_assert_nonnull (name_utf16);
in_handle = CreateNamedPipe (name_utf16,
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
PIPE_READMODE_BYTE | PIPE_WAIT,
1, 0, 0, 0, NULL);
g_assert (in_handle != INVALID_HANDLE_VALUE);
out_handle = CreateFile (name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
out_handle = CreateFile (name_utf16, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
g_assert (out_handle != INVALID_HANDLE_VALUE);
in = g_win32_input_stream_new (in_handle, TRUE);
@@ -521,6 +537,8 @@ test_pipe_io_cancel (void)
g_object_unref (reader_cancel);
g_object_unref (in);
g_object_unref (out);
g_free (name_utf16);
}
int