mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 21:46:14 +01:00
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:
commit
481839c190
@ -2026,10 +2026,10 @@ _g_dbus_compute_complete_signature (GDBusArgInfo **args)
|
|||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
|
||||||
#define DBUS_DAEMON_ADDRESS_INFO "DBusDaemonAddressInfo"
|
#define DBUS_DAEMON_ADDRESS_INFO L"DBusDaemonAddressInfo"
|
||||||
#define DBUS_DAEMON_MUTEX "DBusDaemonMutex"
|
#define DBUS_DAEMON_MUTEX L"DBusDaemonMutex"
|
||||||
#define UNIQUE_DBUS_INIT_MUTEX "UniqueDBusInitMutex"
|
#define UNIQUE_DBUS_INIT_MUTEX L"UniqueDBusInitMutex"
|
||||||
#define DBUS_AUTOLAUNCH_MUTEX "DBusAutolaunchMutex"
|
#define DBUS_AUTOLAUNCH_MUTEX L"DBusAutolaunchMutex"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_mutex (HANDLE mutex)
|
release_mutex (HANDLE mutex)
|
||||||
@ -2039,12 +2039,12 @@ release_mutex (HANDLE mutex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE
|
static HANDLE
|
||||||
acquire_mutex (const char *mutexname)
|
acquire_mutex (const wchar_t *mutexname)
|
||||||
{
|
{
|
||||||
HANDLE mutex;
|
HANDLE mutex;
|
||||||
DWORD res;
|
DWORD res;
|
||||||
|
|
||||||
mutex = CreateMutexA (NULL, FALSE, mutexname);
|
mutex = CreateMutex (NULL, FALSE, mutexname);
|
||||||
if (!mutex)
|
if (!mutex)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2063,12 +2063,12 @@ acquire_mutex (const char *mutexname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_mutex_owned (const char *mutexname)
|
is_mutex_owned (const wchar_t *mutexname)
|
||||||
{
|
{
|
||||||
HANDLE mutex;
|
HANDLE mutex;
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
mutex = CreateMutexA (NULL, FALSE, mutexname);
|
mutex = CreateMutex (NULL, FALSE, mutexname);
|
||||||
if (WaitForSingleObject (mutex, 10) == WAIT_TIMEOUT)
|
if (WaitForSingleObject (mutex, 10) == WAIT_TIMEOUT)
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
else
|
else
|
||||||
@ -2079,7 +2079,7 @@ is_mutex_owned (const char *mutexname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
read_shm (const char *shm_name)
|
read_shm (const wchar_t *shm_name)
|
||||||
{
|
{
|
||||||
HANDLE shared_mem;
|
HANDLE shared_mem;
|
||||||
char *shared_data;
|
char *shared_data;
|
||||||
@ -2090,7 +2090,7 @@ read_shm (const char *shm_name)
|
|||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
shared_mem = OpenFileMappingA (FILE_MAP_READ, FALSE, shm_name);
|
shared_mem = OpenFileMapping (FILE_MAP_READ, FALSE, shm_name);
|
||||||
if (shared_mem != 0)
|
if (shared_mem != 0)
|
||||||
break;
|
break;
|
||||||
Sleep (100);
|
Sleep (100);
|
||||||
@ -2120,13 +2120,13 @@ read_shm (const char *shm_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE
|
static HANDLE
|
||||||
set_shm (const char *shm_name, const char *value)
|
set_shm (const wchar_t *shm_name, const char *value)
|
||||||
{
|
{
|
||||||
HANDLE shared_mem;
|
HANDLE shared_mem;
|
||||||
char *shared_data;
|
char *shared_data;
|
||||||
|
|
||||||
shared_mem = CreateFileMappingA (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
|
shared_mem = CreateFileMapping (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
|
||||||
0, strlen (value) + 1, shm_name);
|
0, strlen (value) + 1, shm_name);
|
||||||
if (shared_mem == 0)
|
if (shared_mem == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2152,7 +2152,7 @@ publish_session_bus (const char *address)
|
|||||||
|
|
||||||
init_mutex = acquire_mutex (UNIQUE_DBUS_INIT_MUTEX);
|
init_mutex = acquire_mutex (UNIQUE_DBUS_INIT_MUTEX);
|
||||||
|
|
||||||
published_daemon_mutex = CreateMutexA (NULL, FALSE, DBUS_DAEMON_MUTEX);
|
published_daemon_mutex = CreateMutex (NULL, FALSE, DBUS_DAEMON_MUTEX);
|
||||||
if (WaitForSingleObject (published_daemon_mutex, 10 ) != WAIT_OBJECT_0)
|
if (WaitForSingleObject (published_daemon_mutex, 10 ) != WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
release_mutex (init_mutex);
|
release_mutex (init_mutex);
|
||||||
@ -2395,11 +2395,11 @@ gchar *
|
|||||||
_g_dbus_get_machine_id (GError **error)
|
_g_dbus_get_machine_id (GError **error)
|
||||||
{
|
{
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
HW_PROFILE_INFOA info;
|
HW_PROFILE_INFO info;
|
||||||
char *src, *dest, *res;
|
char *guid, *src, *dest, *res;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!GetCurrentHwProfileA (&info))
|
if (!GetCurrentHwProfile (&info))
|
||||||
{
|
{
|
||||||
char *message = g_win32_error_message (GetLastError ());
|
char *message = g_win32_error_message (GetLastError ());
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -2410,8 +2410,11 @@ _g_dbus_get_machine_id (GError **error)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form: {12340001-4980-1920-6788-123456789012} */
|
if (!(guid = g_utf16_to_utf8 (info.szHwProfileGuid, -1, NULL, NULL, NULL)))
|
||||||
src = &info.szHwProfileGuid[0];
|
return NULL;
|
||||||
|
|
||||||
|
/* Guid is of the form: {12340001-4980-1920-6788-123456789012} */
|
||||||
|
src = guid;
|
||||||
|
|
||||||
res = g_malloc (32+1);
|
res = g_malloc (32+1);
|
||||||
dest = res;
|
dest = res;
|
||||||
@ -2433,6 +2436,8 @@ _g_dbus_get_machine_id (GError **error)
|
|||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
|
g_free (guid);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
#else
|
#else
|
||||||
gchar *ret = NULL;
|
gchar *ret = NULL;
|
||||||
|
@ -1175,10 +1175,10 @@ void *
|
|||||||
_g_io_win32_get_module (void)
|
_g_io_win32_get_module (void)
|
||||||
{
|
{
|
||||||
if (!gio_dll)
|
if (!gio_dll)
|
||||||
GetModuleHandleExA (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
||||||
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||||
(const char *) _g_io_win32_get_module,
|
(LPCWSTR) _g_io_win32_get_module,
|
||||||
&gio_dll);
|
&gio_dll);
|
||||||
return gio_dll;
|
return gio_dll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1104,7 +1104,7 @@ g_resolver_records_from_res_query (const gchar *rrname,
|
|||||||
#elif defined(G_OS_WIN32)
|
#elif defined(G_OS_WIN32)
|
||||||
|
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_dns_srv (DNS_RECORD *rec)
|
parse_dns_srv (DNS_RECORDA *rec)
|
||||||
{
|
{
|
||||||
return g_variant_new ("(qqqs)",
|
return g_variant_new ("(qqqs)",
|
||||||
(guint16)rec->Data.SRV.wPriority,
|
(guint16)rec->Data.SRV.wPriority,
|
||||||
@ -1114,7 +1114,7 @@ parse_dns_srv (DNS_RECORD *rec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_dns_soa (DNS_RECORD *rec)
|
parse_dns_soa (DNS_RECORDA *rec)
|
||||||
{
|
{
|
||||||
return g_variant_new ("(ssuuuuu)",
|
return g_variant_new ("(ssuuuuu)",
|
||||||
rec->Data.SOA.pNamePrimaryServer,
|
rec->Data.SOA.pNamePrimaryServer,
|
||||||
@ -1127,13 +1127,13 @@ parse_dns_soa (DNS_RECORD *rec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_dns_ns (DNS_RECORD *rec)
|
parse_dns_ns (DNS_RECORDA *rec)
|
||||||
{
|
{
|
||||||
return g_variant_new ("(s)", rec->Data.NS.pNameHost);
|
return g_variant_new ("(s)", rec->Data.NS.pNameHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_dns_mx (DNS_RECORD *rec)
|
parse_dns_mx (DNS_RECORDA *rec)
|
||||||
{
|
{
|
||||||
return g_variant_new ("(qs)",
|
return g_variant_new ("(qs)",
|
||||||
(guint16)rec->Data.MX.wPreference,
|
(guint16)rec->Data.MX.wPreference,
|
||||||
@ -1141,7 +1141,7 @@ parse_dns_mx (DNS_RECORD *rec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_dns_txt (DNS_RECORD *rec)
|
parse_dns_txt (DNS_RECORDA *rec)
|
||||||
{
|
{
|
||||||
GVariant *record;
|
GVariant *record;
|
||||||
GPtrArray *array;
|
GPtrArray *array;
|
||||||
@ -1179,10 +1179,10 @@ static GList *
|
|||||||
g_resolver_records_from_DnsQuery (const gchar *rrname,
|
g_resolver_records_from_DnsQuery (const gchar *rrname,
|
||||||
WORD dnstype,
|
WORD dnstype,
|
||||||
DNS_STATUS status,
|
DNS_STATUS status,
|
||||||
DNS_RECORD *results,
|
DNS_RECORDA *results,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
DNS_RECORD *rec;
|
DNS_RECORDA *rec;
|
||||||
gpointer record;
|
gpointer record;
|
||||||
GList *records;
|
GList *records;
|
||||||
|
|
||||||
@ -1342,11 +1342,18 @@ do_lookup_records (const gchar *rrname,
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
DNS_STATUS status;
|
DNS_STATUS status;
|
||||||
DNS_RECORD *results = NULL;
|
DNS_RECORDA *results = NULL;
|
||||||
WORD dnstype;
|
WORD dnstype;
|
||||||
|
|
||||||
|
/* Work around differences in Windows SDK and mingw-w64 headers */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
typedef DNS_RECORDW * PDNS_RECORD_UTF8_;
|
||||||
|
#else
|
||||||
|
typedef DNS_RECORDA * PDNS_RECORD_UTF8_;
|
||||||
|
#endif
|
||||||
|
|
||||||
dnstype = g_resolver_record_type_to_dnstype (record_type);
|
dnstype = g_resolver_record_type_to_dnstype (record_type);
|
||||||
status = DnsQuery_A (rrname, dnstype, DNS_QUERY_STANDARD, NULL, &results, NULL);
|
status = DnsQuery_UTF8 (rrname, dnstype, DNS_QUERY_STANDARD, NULL, (PDNS_RECORD_UTF8_*)&results, NULL);
|
||||||
records = g_resolver_records_from_DnsQuery (rrname, dnstype, status, results, error);
|
records = g_resolver_records_from_DnsQuery (rrname, dnstype, status, results, error);
|
||||||
if (results != NULL)
|
if (results != NULL)
|
||||||
DnsRecordListFree (results, DnsFreeRecordList);
|
DnsRecordListFree (results, DnsFreeRecordList);
|
||||||
|
@ -4034,9 +4034,9 @@ gio_win32_appinfo_init (gboolean do_wait)
|
|||||||
/* Trigger initial tree build. Fake data pointer. */
|
/* Trigger initial tree build. Fake data pointer. */
|
||||||
g_thread_pool_push (gio_win32_appinfo_threadpool, (gpointer) keys_updated, NULL);
|
g_thread_pool_push (gio_win32_appinfo_threadpool, (gpointer) keys_updated, NULL);
|
||||||
/* Increment the DLL refcount */
|
/* Increment the DLL refcount */
|
||||||
GetModuleHandleExA (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
|
GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
|
||||||
(const char *) gio_win32_appinfo_init,
|
(LPCWSTR) gio_win32_appinfo_init,
|
||||||
&gio_dll_extra);
|
&gio_dll_extra);
|
||||||
/* gio DLL cannot be unloaded now */
|
/* gio DLL cannot be unloaded now */
|
||||||
|
|
||||||
g_once_init_leave (&initialized, TRUE);
|
g_once_init_leave (&initialized, TRUE);
|
||||||
|
@ -192,20 +192,20 @@ _g_win32_process_get_access_token_sid (DWORD process_id,
|
|||||||
gchar *
|
gchar *
|
||||||
_g_win32_sid_to_string (SID *sid, GError **error)
|
_g_win32_sid_to_string (SID *sid, GError **error)
|
||||||
{
|
{
|
||||||
gchar *tmp, *ret;
|
wchar_t *tmp = NULL;
|
||||||
|
char *ret;
|
||||||
|
|
||||||
g_return_val_if_fail (sid != NULL, NULL);
|
g_return_val_if_fail (sid != NULL, NULL);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
if (!ConvertSidToStringSidA (sid, &tmp))
|
if (!ConvertSidToStringSid (sid, &tmp))
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (GetLastError ()),
|
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (GetLastError ()),
|
||||||
"Failed to ConvertSidToString");
|
"Failed to ConvertSidToString");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = g_strdup (tmp);
|
ret = g_utf16_to_utf8 (tmp, -1, NULL, NULL, NULL);
|
||||||
LocalFree (tmp);
|
LocalFree (tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2201,6 +2201,7 @@ _g_win32_socketpair (gint domain,
|
|||||||
SOCKET client = INVALID_SOCKET;
|
SOCKET client = INVALID_SOCKET;
|
||||||
SOCKET server = INVALID_SOCKET;
|
SOCKET server = INVALID_SOCKET;
|
||||||
gchar *path = NULL;
|
gchar *path = NULL;
|
||||||
|
wchar_t *path_utf16 = NULL;
|
||||||
int tmpfd, rv = -1;
|
int tmpfd, rv = -1;
|
||||||
u_long arg, br;
|
u_long arg, br;
|
||||||
|
|
||||||
@ -2230,7 +2231,11 @@ _g_win32_socketpair (gint domain,
|
|||||||
if (listener == INVALID_SOCKET)
|
if (listener == INVALID_SOCKET)
|
||||||
goto out;
|
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)
|
if (GetLastError () != ERROR_FILE_NOT_FOUND)
|
||||||
goto out;
|
goto out;
|
||||||
@ -2285,7 +2290,10 @@ _g_win32_socketpair (gint domain,
|
|||||||
if (server != INVALID_SOCKET)
|
if (server != INVALID_SOCKET)
|
||||||
closesocket (server);
|
closesocket (server);
|
||||||
|
|
||||||
DeleteFile (path);
|
if (path_utf16)
|
||||||
|
DeleteFile (path_utf16);
|
||||||
|
|
||||||
|
g_free (path_utf16);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -340,17 +340,21 @@ test_pipe_io_overlap (void)
|
|||||||
PipeIOOverlapReader rs, rc;
|
PipeIOOverlapReader rs, rc;
|
||||||
HANDLE server, client;
|
HANDLE server, client;
|
||||||
gchar name[256];
|
gchar name[256];
|
||||||
|
wchar_t *name_utf16;
|
||||||
|
|
||||||
g_snprintf (name, sizeof (name),
|
g_snprintf (name, sizeof (name),
|
||||||
"\\\\.\\pipe\\gtest-io-overlap-%u", (guint) GetCurrentProcessId ());
|
"\\\\.\\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_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||||
PIPE_READMODE_BYTE | PIPE_WAIT,
|
PIPE_READMODE_BYTE | PIPE_WAIT,
|
||||||
1, 0, 0, 0, NULL);
|
1, 0, 0, 0, NULL);
|
||||||
g_assert (server != INVALID_HANDLE_VALUE);
|
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);
|
g_assert (client != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
out_server = g_win32_output_stream_new (server, TRUE);
|
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 (rc.in);
|
||||||
g_object_unref (out_server);
|
g_object_unref (out_server);
|
||||||
g_object_unref (out_client);
|
g_object_unref (out_client);
|
||||||
|
|
||||||
|
g_free (name_utf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@ -419,18 +425,22 @@ test_pipe_io_concurrent (void)
|
|||||||
PipeIOOverlapReader rc1, rc2;
|
PipeIOOverlapReader rc1, rc2;
|
||||||
HANDLE server, client;
|
HANDLE server, client;
|
||||||
gchar name[256], c;
|
gchar name[256], c;
|
||||||
|
wchar_t *name_utf16;
|
||||||
|
|
||||||
g_snprintf (name, sizeof (name),
|
g_snprintf (name, sizeof (name),
|
||||||
"\\\\.\\pipe\\gtest-io-concurrent-%u", (guint) GetCurrentProcessId ());
|
"\\\\.\\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_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||||
PIPE_READMODE_BYTE | PIPE_WAIT,
|
PIPE_READMODE_BYTE | PIPE_WAIT,
|
||||||
1, 0, 0, 0, NULL);
|
1, 0, 0, 0, NULL);
|
||||||
g_assert (server != INVALID_HANDLE_VALUE);
|
g_assert (server != INVALID_HANDLE_VALUE);
|
||||||
g_assert (_pipe (writer_pipe, 10, _O_BINARY) == 0);
|
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);
|
g_assert (client != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
rc1.in = g_win32_input_stream_new (client, TRUE);
|
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[0]);
|
||||||
close (writer_pipe[1]);
|
close (writer_pipe[1]);
|
||||||
|
|
||||||
|
g_free (name_utf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -491,17 +503,21 @@ test_pipe_io_cancel (void)
|
|||||||
GOutputStream *out;
|
GOutputStream *out;
|
||||||
HANDLE in_handle, out_handle;
|
HANDLE in_handle, out_handle;
|
||||||
gchar name[256];
|
gchar name[256];
|
||||||
|
wchar_t *name_utf16;
|
||||||
|
|
||||||
g_snprintf (name, sizeof (name),
|
g_snprintf (name, sizeof (name),
|
||||||
"\\\\.\\pipe\\gtest-io-cancel-%u", (guint) GetCurrentProcessId ());
|
"\\\\.\\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_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
|
||||||
PIPE_READMODE_BYTE | PIPE_WAIT,
|
PIPE_READMODE_BYTE | PIPE_WAIT,
|
||||||
1, 0, 0, 0, NULL);
|
1, 0, 0, 0, NULL);
|
||||||
g_assert (in_handle != INVALID_HANDLE_VALUE);
|
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);
|
g_assert (out_handle != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
in = g_win32_input_stream_new (in_handle, TRUE);
|
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 (reader_cancel);
|
||||||
g_object_unref (in);
|
g_object_unref (in);
|
||||||
g_object_unref (out);
|
g_object_unref (out);
|
||||||
|
|
||||||
|
g_free (name_utf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -270,12 +270,12 @@ spawn_process (int children_nb)
|
|||||||
wcl.hCursor = NULL;
|
wcl.hCursor = NULL;
|
||||||
wcl.hbrBackground = NULL;
|
wcl.hbrBackground = NULL;
|
||||||
wcl.lpszMenuName = NULL;
|
wcl.lpszMenuName = NULL;
|
||||||
wcl.lpszClassName = "io-channel-basic";
|
wcl.lpszClassName = L"io-channel-basic";
|
||||||
|
|
||||||
klass = RegisterClass (&wcl);
|
klass = RegisterClass (&wcl);
|
||||||
g_assert_cmpint (klass, !=, 0);
|
g_assert_cmpint (klass, !=, 0);
|
||||||
|
|
||||||
hwnd = CreateWindow (MAKEINTATOM(klass), "io-channel-basic", 0, 0, 0, 10, 10,
|
hwnd = CreateWindow (MAKEINTATOM (klass), L"io-channel-basic", 0, 0, 0, 10, 10,
|
||||||
NULL, NULL, wcl.hInstance, NULL);
|
NULL, NULL, wcl.hInstance, NULL);
|
||||||
g_assert_nonnull (hwnd);
|
g_assert_nonnull (hwnd);
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ get_a_child (gint ttl)
|
|||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
gchar *cmdline;
|
gchar *cmdline;
|
||||||
|
wchar_t *cmdline_utf16;
|
||||||
|
|
||||||
memset (&si, 0, sizeof (si));
|
memset (&si, 0, sizeof (si));
|
||||||
si.cb = sizeof (&si);
|
si.cb = sizeof (&si);
|
||||||
@ -70,11 +71,15 @@ get_a_child (gint ttl)
|
|||||||
|
|
||||||
cmdline = g_strdup_printf ("%s %d", sleep_prog_path, ttl);
|
cmdline = g_strdup_printf ("%s %d", sleep_prog_path, ttl);
|
||||||
|
|
||||||
if (!CreateProcess (NULL, cmdline, NULL, NULL,
|
cmdline_utf16 = g_utf8_to_utf16 (cmdline, -1, NULL, NULL, NULL);
|
||||||
|
g_assert_nonnull (cmdline_utf16);
|
||||||
|
|
||||||
|
if (!CreateProcess (NULL, cmdline_utf16, NULL, NULL,
|
||||||
FALSE, 0, NULL, NULL, &si, &pi))
|
FALSE, 0, NULL, NULL, &si, &pi))
|
||||||
g_error ("CreateProcess failed: %s",
|
g_error ("CreateProcess failed: %s",
|
||||||
g_win32_error_message (GetLastError ()));
|
g_win32_error_message (GetLastError ()));
|
||||||
|
|
||||||
|
g_free (cmdline_utf16);
|
||||||
g_free (cmdline);
|
g_free (cmdline);
|
||||||
|
|
||||||
CloseHandle (pi.hThread);
|
CloseHandle (pi.hThread);
|
||||||
|
@ -213,6 +213,10 @@ if host_system == 'qnx'
|
|||||||
add_project_arguments('-D_QNX_SOURCE', language: 'c')
|
add_project_arguments('-D_QNX_SOURCE', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if host_system == 'windows'
|
||||||
|
add_project_arguments(['-DUNICODE', '-D_UNICODE'], language: 'c')
|
||||||
|
endif
|
||||||
|
|
||||||
# Disable strict aliasing;
|
# Disable strict aliasing;
|
||||||
# see https://bugzilla.gnome.org/show_bug.cgi?id=791622
|
# see https://bugzilla.gnome.org/show_bug.cgi?id=791622
|
||||||
if cc.has_argument('-fno-strict-aliasing')
|
if cc.has_argument('-fno-strict-aliasing')
|
||||||
|
Loading…
Reference in New Issue
Block a user