mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Fix problems on 64-bit Windows. Avoid warnings, some of which indicated
2008-07-28 Tor Lillqvist <tml@novell.com> Fix problems on 64-bit Windows. Avoid warnings, some of which indicated actual problems, some which were just annoyances. Where casts to an integer type are needed for pointers, use gssize. Technically intptr_t would be the more proper type, but we still want to be compilable with MSVS6 and 7 which don't have intptr_t. MSVS8 and 9 do have intptr_t, but in <crtdefs.h>, not <stdint.h>. Use %p to print out handles. Use gssize casts when assigning GPollFD::fd fields. Use G_GSIZE_FORMAT when printing size_t values. * configure.in: Define automake conditional G_OS_WIN32_X64 which is true on Win64. * glib/giochannel.h: Use slightly different prototype for g_io_channel_win32_new_messages() on Win64 with gsize instead of guint. * glib/giowin32.c * glib/gmain.c * glib/gspawn-win32.c * tests/testglib.c: Generic changes as described above. * glib/gmain.h: Don't bother mentioning GIMP in comment. * glib/grel.c (tuple_hash_2): Use all bits of pointer. * glib/gspawn-win32.c * glib/gspawn-win32-helper.c: Use gssize types in the communication between parent and helper process, so that we can pass process handles, which are pointers, also on Win64. * glib/gtimer.c (g_time_val_to_iso8601): time_t is 64 bits on Win64 so we can't pass the address of a GTimeVal::tv_sec which is a long directly to gmtime(). On the other hand, changing GTimeVal::tv_sec to be a gint64 on Win64 is not really feasible either, as that would then require changes in much code that uses GTimeVals. * glib/gspawn-win32.c * glib/Makefile.am: Call the helper programs gspawn-win64-helper.exe and gspawn-win64-helper-console.exe on Win64, to avoid potential risk of running a 32-bit version of the helper. svn path=/trunk/; revision=7260
This commit is contained in:
parent
168c4d4708
commit
a3fa74853a
50
ChangeLog
50
ChangeLog
@ -1,3 +1,53 @@
|
||||
2008-07-28 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
Fix problems on 64-bit Windows. Avoid warnings, some of which
|
||||
indicated actual problems, some which were just annoyances.
|
||||
|
||||
Where casts to an integer type are needed for pointers, use
|
||||
gssize. Technically intptr_t would be the more proper type, but we
|
||||
still want to be compilable with MSVS6 and 7 which don't have
|
||||
intptr_t. MSVS8 and 9 do have intptr_t, but in <crtdefs.h>, not
|
||||
<stdint.h>.
|
||||
|
||||
Use %p to print out handles. Use gssize casts when assigning
|
||||
GPollFD::fd fields.
|
||||
|
||||
Use G_GSIZE_FORMAT when printing size_t values.
|
||||
|
||||
* configure.in: Define automake conditional G_OS_WIN32_X64 which
|
||||
is true on Win64.
|
||||
|
||||
* glib/giochannel.h: Use slightly different prototype for
|
||||
g_io_channel_win32_new_messages() on Win64 with gsize instead of
|
||||
guint.
|
||||
|
||||
* glib/giowin32.c
|
||||
* glib/gmain.c
|
||||
* glib/gspawn-win32.c
|
||||
* tests/testglib.c: Generic changes as described above.
|
||||
|
||||
* glib/gmain.h: Don't bother mentioning GIMP in comment.
|
||||
|
||||
* glib/grel.c (tuple_hash_2): Use all bits of pointer.
|
||||
|
||||
* glib/gspawn-win32.c
|
||||
* glib/gspawn-win32-helper.c: Use gssize types in the
|
||||
communication between parent and helper process, so that we can
|
||||
pass process handles, which are pointers, also on Win64.
|
||||
|
||||
* glib/gtimer.c (g_time_val_to_iso8601): time_t is 64 bits on
|
||||
Win64 so we can't pass the address of a GTimeVal::tv_sec which is
|
||||
a long directly to gmtime(). On the other hand, changing
|
||||
GTimeVal::tv_sec to be a gint64 on Win64 is not really feasible
|
||||
either, as that would then require changes in much code that uses
|
||||
GTimeVals.
|
||||
|
||||
* glib/gspawn-win32.c
|
||||
* glib/Makefile.am: Call the helper programs
|
||||
gspawn-win64-helper.exe and gspawn-win64-helper-console.exe on
|
||||
Win64, to avoid potential risk of running a 32-bit version of the
|
||||
helper.
|
||||
|
||||
2008-07-27 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* glib/glib.symbols
|
||||
|
@ -161,6 +161,7 @@ AC_TRY_CPP([
|
||||
AC_MSG_RESULT([$glib_have_carbon])
|
||||
|
||||
AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
|
||||
AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"])
|
||||
AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
|
||||
AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"])
|
||||
AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"])
|
||||
|
@ -300,12 +300,26 @@ gspawn-win32-helper-console.c:
|
||||
echo '#define HELPER_CONSOLE' >$@
|
||||
echo '#include "gspawn-win32-helper.c"' >>$@
|
||||
|
||||
gspawn-win64-helper.c:
|
||||
echo '#include "gspawn-win32-helper.c"' >$@
|
||||
|
||||
gspawn-win64-helper-console.c:
|
||||
echo '#define HELPER_CONSOLE' >$@
|
||||
echo '#include "gspawn-win32-helper.c"' >>$@
|
||||
|
||||
if OS_WIN32
|
||||
if OS_WIN32_X64
|
||||
INSTALL_PROGS += gspawn-win64-helper gspawn-win64-helper-console
|
||||
gspawn_win64_helper_LDADD = libglib-2.0.la
|
||||
gspawn_win64_helper_LDFLAGS = -mwindows
|
||||
gspawn_win64_helper_console_LDADD = libglib-2.0.la
|
||||
else
|
||||
INSTALL_PROGS += gspawn-win32-helper gspawn-win32-helper-console
|
||||
gspawn_win32_helper_LDADD = libglib-2.0.la
|
||||
gspawn_win32_helper_LDFLAGS = -mwindows
|
||||
gspawn_win32_helper_console_LDADD = libglib-2.0.la
|
||||
endif
|
||||
endif
|
||||
|
||||
glib-win32-res.o: glib.rc
|
||||
$(WINDRES) glib.rc $@
|
||||
|
@ -328,7 +328,15 @@ gint g_io_channel_win32_poll (GPollFD *fds,
|
||||
gint timeout_);
|
||||
|
||||
/* Create an IO channel for Windows messages for window handle hwnd. */
|
||||
#if GLIB_SIZEOF_VOID_P == 8
|
||||
/* We use gsize here so that it is still an integer type and not a
|
||||
* pointer, like the guint in the traditional prototype. We can't use
|
||||
* intptr_t as that is not portable enough.
|
||||
*/
|
||||
GIOChannel *g_io_channel_win32_new_messages (gsize hwnd);
|
||||
#else
|
||||
GIOChannel *g_io_channel_win32_new_messages (guint hwnd);
|
||||
#endif
|
||||
|
||||
/* Create an IO channel for C runtime (emulated Unix-like) file
|
||||
* descriptors. After calling g_io_add_watch() on a IO channel
|
||||
|
@ -114,7 +114,7 @@ struct _GIOWin32Channel {
|
||||
/* Following fields used by socket channels */
|
||||
int event_mask;
|
||||
int last_events;
|
||||
int event;
|
||||
HANDLE event;
|
||||
gboolean write_would_have_blocked;
|
||||
};
|
||||
|
||||
@ -240,7 +240,7 @@ g_io_channel_win32_init (GIOWin32Channel *channel)
|
||||
channel->space_avail_event = NULL;
|
||||
channel->event_mask = 0;
|
||||
channel->last_events = 0;
|
||||
channel->event = 0;
|
||||
channel->event = NULL;
|
||||
channel->write_would_have_blocked = FALSE;
|
||||
InitializeCriticalSection (&channel->mutex);
|
||||
}
|
||||
@ -276,11 +276,11 @@ read_thread (void *parameter)
|
||||
g_io_channel_ref ((GIOChannel *)channel);
|
||||
|
||||
if (channel->debug)
|
||||
g_print ("read_thread %#x: start fd=%d, data_avail=%#x space_avail=%#x\n",
|
||||
g_print ("read_thread %#x: start fd=%d, data_avail=%p space_avail=%p\n",
|
||||
channel->thread_id,
|
||||
channel->fd,
|
||||
(guint) channel->data_avail_event,
|
||||
(guint) channel->space_avail_event);
|
||||
channel->data_avail_event,
|
||||
channel->space_avail_event);
|
||||
|
||||
channel->direction = 0;
|
||||
channel->buffer = g_malloc (BUFFER_SIZE);
|
||||
@ -387,11 +387,11 @@ write_thread (void *parameter)
|
||||
g_io_channel_ref ((GIOChannel *)channel);
|
||||
|
||||
if (channel->debug)
|
||||
g_print ("write_thread %#x: start fd=%d, data_avail=%#x space_avail=%#x\n",
|
||||
g_print ("write_thread %#x: start fd=%d, data_avail=%p space_avail=%p\n",
|
||||
channel->thread_id,
|
||||
channel->fd,
|
||||
(guint) channel->data_avail_event,
|
||||
(guint) channel->space_avail_event);
|
||||
channel->data_avail_event,
|
||||
channel->space_avail_event);
|
||||
|
||||
channel->direction = 1;
|
||||
channel->buffer = g_malloc (BUFFER_SIZE);
|
||||
@ -509,7 +509,7 @@ create_thread (GIOWin32Channel *channel,
|
||||
|
||||
static GIOStatus
|
||||
buffer_read (GIOWin32Channel *channel,
|
||||
guchar *dest,
|
||||
gchar *dest,
|
||||
gsize count,
|
||||
gsize *bytes_read,
|
||||
GError **err)
|
||||
@ -519,7 +519,7 @@ buffer_read (GIOWin32Channel *channel,
|
||||
|
||||
LOCK (channel->mutex);
|
||||
if (channel->debug)
|
||||
g_print ("reading from thread %#x %d bytes, rdp=%d, wrp=%d\n",
|
||||
g_print ("reading from thread %#x %" G_GSIZE_FORMAT " bytes, rdp=%d, wrp=%d\n",
|
||||
channel->thread_id, count, channel->rdp, channel->wrp);
|
||||
|
||||
if (channel->wrp == channel->rdp)
|
||||
@ -580,7 +580,7 @@ buffer_read (GIOWin32Channel *channel,
|
||||
|
||||
static GIOStatus
|
||||
buffer_write (GIOWin32Channel *channel,
|
||||
const guchar *dest,
|
||||
const gchar *dest,
|
||||
gsize count,
|
||||
gsize *bytes_written,
|
||||
GError **err)
|
||||
@ -590,7 +590,7 @@ buffer_write (GIOWin32Channel *channel,
|
||||
|
||||
LOCK (channel->mutex);
|
||||
if (channel->debug)
|
||||
g_print ("buffer_write: writing to thread %#x %d bytes, rdp=%d, wrp=%d\n",
|
||||
g_print ("buffer_write: writing to thread %#x %" G_GSIZE_FORMAT " bytes, rdp=%d, wrp=%d\n",
|
||||
channel->thread_id, count, channel->rdp, channel->wrp);
|
||||
|
||||
if ((channel->wrp + 1) % BUFFER_SIZE == channel->rdp)
|
||||
@ -720,8 +720,8 @@ g_io_win32_prepare (GSource *source,
|
||||
if (channel->event_mask != event_mask /* || channel->event != watch->pollfd.fd*/)
|
||||
{
|
||||
if (channel->debug)
|
||||
g_print ("\n WSAEventSelect(%d,%#x,{%s})",
|
||||
channel->fd, watch->pollfd.fd,
|
||||
g_print ("\n WSAEventSelect(%d,%p,{%s})",
|
||||
channel->fd, (HANDLE) watch->pollfd.fd,
|
||||
event_mask_to_string (event_mask));
|
||||
if (WSAEventSelect (channel->fd, (HANDLE) watch->pollfd.fd,
|
||||
event_mask) == SOCKET_ERROR)
|
||||
@ -737,7 +737,7 @@ g_io_win32_prepare (GSource *source,
|
||||
if ((event_mask & FD_WRITE) && !channel->write_would_have_blocked)
|
||||
{
|
||||
if (channel->debug)
|
||||
g_print (" WSASetEvent(%#x)", watch->pollfd.fd);
|
||||
g_print (" WSASetEvent(%p)", (WSAEVENT) watch->pollfd.fd);
|
||||
WSASetEvent ((WSAEVENT) watch->pollfd.fd);
|
||||
}
|
||||
}
|
||||
@ -816,8 +816,8 @@ g_io_win32_check (GSource *source)
|
||||
if (channel->last_events & FD_WRITE)
|
||||
{
|
||||
if (channel->debug)
|
||||
g_print (" sock=%d event=%#x last_events has FD_WRITE",
|
||||
channel->fd, watch->pollfd.fd);
|
||||
g_print (" sock=%d event=%p last_events has FD_WRITE",
|
||||
channel->fd, (HANDLE) watch->pollfd.fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -837,12 +837,12 @@ g_io_win32_check (GSource *source)
|
||||
{
|
||||
channel->event_mask = 0;
|
||||
if (channel->debug)
|
||||
g_print ("\n WSAEventSelect(%d,%#x,{})",
|
||||
channel->fd, watch->pollfd.fd);
|
||||
g_print ("\n WSAEventSelect(%d,%p,{})",
|
||||
channel->fd, (HANDLE) watch->pollfd.fd);
|
||||
WSAEventSelect (channel->fd, (HANDLE) watch->pollfd.fd, 0);
|
||||
if (channel->debug)
|
||||
g_print (" ResetEvent(%#x)",
|
||||
watch->pollfd.fd);
|
||||
g_print (" ResetEvent(%p)",
|
||||
(HANDLE) watch->pollfd.fd);
|
||||
ResetEvent ((HANDLE) watch->pollfd.fd);
|
||||
}
|
||||
channel->last_events = events.lNetworkEvents;
|
||||
@ -988,8 +988,8 @@ g_io_win32_msg_read (GIOChannel *channel,
|
||||
}
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_msg_read: channel=%p hwnd=%#x\n",
|
||||
channel, (guint) win32_channel->hwnd);
|
||||
g_print ("g_io_win32_msg_read: channel=%p hwnd=%p\n",
|
||||
channel, win32_channel->hwnd);
|
||||
if (!PeekMessage (&msg, win32_channel->hwnd, 0, 0, PM_REMOVE))
|
||||
return G_IO_STATUS_AGAIN;
|
||||
|
||||
@ -1075,7 +1075,7 @@ g_io_win32_msg_create_watch (GIOChannel *channel,
|
||||
|
||||
watch->condition = condition;
|
||||
|
||||
watch->pollfd.fd = G_WIN32_MSG_HANDLE;
|
||||
watch->pollfd.fd = (gssize) G_WIN32_MSG_HANDLE;
|
||||
watch->pollfd.events = condition;
|
||||
|
||||
g_source_add_poll (source, &watch->pollfd);
|
||||
@ -1094,7 +1094,7 @@ g_io_win32_fd_and_console_read (GIOChannel *channel,
|
||||
gint result;
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_fd_read: fd=%d count=%d\n",
|
||||
g_print ("g_io_win32_fd_read: fd=%d count=%" G_GSIZE_FORMAT "\n",
|
||||
win32_channel->fd, count);
|
||||
|
||||
if (win32_channel->thread_id)
|
||||
@ -1147,7 +1147,7 @@ g_io_win32_fd_and_console_write (GIOChannel *channel,
|
||||
|
||||
result = write (win32_channel->fd, buf, count);
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_fd_write: fd=%d count=%d => %d\n",
|
||||
g_print ("g_io_win32_fd_write: fd=%d count=%" G_GSIZE_FORMAT " => %d\n",
|
||||
win32_channel->fd, count, result);
|
||||
|
||||
if (result < 0)
|
||||
@ -1279,13 +1279,13 @@ g_io_win32_fd_create_watch (GIOChannel *channel,
|
||||
if (win32_channel->data_avail_event == NULL)
|
||||
create_events (win32_channel);
|
||||
|
||||
watch->pollfd.fd = (gint) win32_channel->data_avail_event;
|
||||
watch->pollfd.fd = (gssize) win32_channel->data_avail_event;
|
||||
watch->pollfd.events = condition;
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_fd_create_watch: channel=%p fd=%d condition={%s} event=%#x\n",
|
||||
g_print ("g_io_win32_fd_create_watch: channel=%p fd=%d condition={%s} event=%p\n",
|
||||
channel, win32_channel->fd,
|
||||
condition_to_string (condition), watch->pollfd.fd);
|
||||
condition_to_string (condition), (HANDLE) watch->pollfd.fd);
|
||||
|
||||
LOCK (win32_channel->mutex);
|
||||
if (win32_channel->thread_id == 0)
|
||||
@ -1332,7 +1332,7 @@ g_io_win32_console_create_watch (GIOChannel *channel,
|
||||
|
||||
watch->condition = condition;
|
||||
|
||||
watch->pollfd.fd = (gint) _get_osfhandle (win32_channel->fd);
|
||||
watch->pollfd.fd = (gssize) _get_osfhandle (win32_channel->fd);
|
||||
watch->pollfd.events = condition;
|
||||
|
||||
g_source_add_poll (source, &watch->pollfd);
|
||||
@ -1353,7 +1353,7 @@ g_io_win32_sock_read (GIOChannel *channel,
|
||||
int winsock_error;
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_sock_read: channel=%p sock=%d count=%d",
|
||||
g_print ("g_io_win32_sock_read: channel=%p sock=%d count=%" G_GSIZE_FORMAT,
|
||||
channel, win32_channel->fd, count);
|
||||
|
||||
result = recv (win32_channel->fd, buf, count, 0);
|
||||
@ -1414,7 +1414,7 @@ g_io_win32_sock_write (GIOChannel *channel,
|
||||
int winsock_error;
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_sock_write: channel=%p sock=%d count=%d",
|
||||
g_print ("g_io_win32_sock_write: channel=%p sock=%d count=%" G_GSIZE_FORMAT,
|
||||
channel, win32_channel->fd, count);
|
||||
|
||||
result = send (win32_channel->fd, buf, count, 0);
|
||||
@ -1498,14 +1498,14 @@ g_io_win32_sock_create_watch (GIOChannel *channel,
|
||||
watch->condition = condition;
|
||||
|
||||
if (win32_channel->event == 0)
|
||||
win32_channel->event = (int) WSACreateEvent ();
|
||||
win32_channel->event = WSACreateEvent ();
|
||||
|
||||
watch->pollfd.fd = win32_channel->event;
|
||||
watch->pollfd.fd = (gssize) win32_channel->event;
|
||||
watch->pollfd.events = condition;
|
||||
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_win32_sock_create_watch: channel=%p sock=%d event=%#x condition={%s}\n",
|
||||
channel, win32_channel->fd, watch->pollfd.fd,
|
||||
g_print ("g_io_win32_sock_create_watch: channel=%p sock=%d event=%p condition={%s}\n",
|
||||
channel, win32_channel->fd, (HANDLE) watch->pollfd.fd,
|
||||
condition_to_string (watch->condition));
|
||||
|
||||
g_source_add_poll (source, &watch->pollfd);
|
||||
@ -1871,7 +1871,11 @@ static GIOFuncs win32_channel_sock_funcs = {
|
||||
};
|
||||
|
||||
GIOChannel *
|
||||
#if GLIB_SIZEOF_VOID_P == 8
|
||||
g_io_channel_win32_new_messages (gsize hwnd)
|
||||
#else
|
||||
g_io_channel_win32_new_messages (guint hwnd)
|
||||
#endif
|
||||
{
|
||||
GIOWin32Channel *win32_channel = g_new (GIOWin32Channel, 1);
|
||||
GIOChannel *channel = (GIOChannel *)win32_channel;
|
||||
@ -1879,8 +1883,8 @@ g_io_channel_win32_new_messages (guint hwnd)
|
||||
g_io_channel_init (channel);
|
||||
g_io_channel_win32_init (win32_channel);
|
||||
if (win32_channel->debug)
|
||||
g_print ("g_io_channel_win32_new_messages: channel=%p hwnd=%#x\n",
|
||||
channel, hwnd);
|
||||
g_print ("g_io_channel_win32_new_messages: channel=%p hwnd=%p\n",
|
||||
channel, (HWND) hwnd);
|
||||
channel->funcs = &win32_channel_msg_funcs;
|
||||
win32_channel->type = G_IO_WIN32_WINDOWS_MESSAGES;
|
||||
win32_channel->hwnd = (HWND) hwnd;
|
||||
@ -2041,7 +2045,7 @@ g_io_channel_win32_make_pollfd (GIOChannel *channel,
|
||||
if (win32_channel->data_avail_event == NULL)
|
||||
create_events (win32_channel);
|
||||
|
||||
fd->fd = (gint) win32_channel->data_avail_event;
|
||||
fd->fd = (gssize) win32_channel->data_avail_event;
|
||||
|
||||
if (win32_channel->thread_id == 0 && (condition & G_IO_IN))
|
||||
{
|
||||
@ -2053,15 +2057,15 @@ g_io_channel_win32_make_pollfd (GIOChannel *channel,
|
||||
break;
|
||||
|
||||
case G_IO_WIN32_CONSOLE:
|
||||
fd->fd = (gint) _get_osfhandle (win32_channel->fd);
|
||||
fd->fd = (gssize) _get_osfhandle (win32_channel->fd);
|
||||
break;
|
||||
|
||||
case G_IO_WIN32_SOCKET:
|
||||
fd->fd = (int) WSACreateEvent ();
|
||||
fd->fd = (gssize) WSACreateEvent ();
|
||||
break;
|
||||
|
||||
case G_IO_WIN32_WINDOWS_MESSAGES:
|
||||
fd->fd = G_WIN32_MSG_HANDLE;
|
||||
fd->fd = (gssize) G_WIN32_MSG_HANDLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
16
glib/gmain.c
16
glib/gmain.c
@ -91,7 +91,11 @@
|
||||
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef _WIN64
|
||||
#define GPOLLFD_FORMAT "%#I64x"
|
||||
#else
|
||||
#define GPOLLFD_FORMAT "%#x"
|
||||
#endif
|
||||
#else
|
||||
#define GPOLLFD_FORMAT "%d"
|
||||
#endif
|
||||
@ -375,7 +379,7 @@ g_poll (GPollFD *fds,
|
||||
{
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
if (g_main_poll_debug)
|
||||
g_print (" %#x", f->fd);
|
||||
g_print (" %p", (HANDLE) f->fd);
|
||||
#endif
|
||||
handles[nhandles++] = (HANDLE) f->fd;
|
||||
}
|
||||
@ -477,12 +481,12 @@ g_poll (GPollFD *fds,
|
||||
else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles)
|
||||
for (f = fds; f < &fds[nfds]; ++f)
|
||||
{
|
||||
if (f->fd == (gint) handles[ready - WAIT_OBJECT_0])
|
||||
if ((HANDLE) f->fd == handles[ready - WAIT_OBJECT_0])
|
||||
{
|
||||
f->revents = f->events;
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
if (g_main_poll_debug)
|
||||
g_print ("g_poll: got event %#x\n", f->fd);
|
||||
g_print ("g_poll: got event %p\n", (HANDLE) f->fd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -682,11 +686,11 @@ g_main_context_init_pipe (GMainContext *context)
|
||||
if (context->wake_up_semaphore == NULL)
|
||||
g_error ("Cannot create wake-up semaphore: %s",
|
||||
g_win32_error_message (GetLastError ()));
|
||||
context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
|
||||
context->wake_up_rec.fd = (gssize) context->wake_up_semaphore;
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
# ifdef G_MAIN_POLL_DEBUG
|
||||
if (g_main_poll_debug)
|
||||
g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
|
||||
g_print ("wake-up semaphore: %p\n", context->wake_up_semaphore);
|
||||
# endif
|
||||
# endif
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
@ -4042,7 +4046,7 @@ g_child_watch_source_new (GPid pid)
|
||||
GChildWatchSource *child_watch_source = (GChildWatchSource *)source;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
child_watch_source->poll.fd = (int)pid;
|
||||
child_watch_source->poll.fd = (gssize) pid;
|
||||
child_watch_source->poll.events = G_IO_IN;
|
||||
|
||||
g_source_add_poll (source, &child_watch_source->poll);
|
||||
|
@ -114,8 +114,7 @@ struct _GSourceFuncs
|
||||
*
|
||||
* So, unless you really know what you are doing, it's best not to try
|
||||
* to use the main loop polling stuff for your own needs on
|
||||
* Win32. It's really only written for the GIMP's needs so
|
||||
* far.
|
||||
* Windows.
|
||||
*/
|
||||
typedef struct _GPollFD GPollFD;
|
||||
typedef gint (*GPollFunc) (GPollFD *ufds,
|
||||
|
10
glib/grel.c
10
glib/grel.c
@ -69,9 +69,19 @@ tuple_equal_2 (gconstpointer v_a,
|
||||
static guint
|
||||
tuple_hash_2 (gconstpointer v_a)
|
||||
{
|
||||
#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
|
||||
/* In practise this snippet has been written for 64-bit Windows
|
||||
* where ints are 32 bits, pointers 64 bits. More exotic platforms
|
||||
* need more tweaks.
|
||||
*/
|
||||
guint* a = (guint*) v_a;
|
||||
|
||||
return (a[0] ^ a[1] ^ a[2] ^ a[3]);
|
||||
#else
|
||||
gpointer* a = (gpointer*) v_a;
|
||||
|
||||
return (gulong)a[0] ^ (gulong)a[1];
|
||||
#endif
|
||||
}
|
||||
|
||||
static GHashFunc
|
||||
|
@ -30,13 +30,13 @@
|
||||
|
||||
|
||||
static void
|
||||
write_err_and_exit (gint fd,
|
||||
gint msg)
|
||||
write_err_and_exit (gint fd,
|
||||
gssize msg)
|
||||
{
|
||||
gint en = errno;
|
||||
gssize en = errno;
|
||||
|
||||
write (fd, &msg, sizeof(msg));
|
||||
write (fd, &en, sizeof(en));
|
||||
write (fd, &msg, sizeof(gssize));
|
||||
write (fd, &en, sizeof(gssize));
|
||||
|
||||
_exit (1);
|
||||
}
|
||||
@ -163,9 +163,9 @@ main (int ignored_argc, char **ignored_argv)
|
||||
int i;
|
||||
int fd;
|
||||
int mode;
|
||||
int handle;
|
||||
gssize handle;
|
||||
int saved_errno;
|
||||
int no_error = CHILD_NO_ERROR;
|
||||
gssize no_error = CHILD_NO_ERROR;
|
||||
gint argv_zero_offset = ARG_PROGRAM;
|
||||
wchar_t **new_wargv;
|
||||
int argc;
|
||||
|
@ -111,12 +111,16 @@ dup_noninherited (int fd,
|
||||
GetCurrentProcess (), &filehandle,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS);
|
||||
close (fd);
|
||||
return _open_osfhandle ((long) filehandle, mode | _O_NOINHERIT);
|
||||
return _open_osfhandle ((gssize) filehandle, mode | _O_NOINHERIT);
|
||||
}
|
||||
|
||||
#ifndef GSPAWN_HELPER
|
||||
|
||||
#ifdef _WIN64
|
||||
#define HELPER_PROCESS "gspawn-win64-helper"
|
||||
#else
|
||||
#define HELPER_PROCESS "gspawn-win32-helper"
|
||||
#endif
|
||||
|
||||
static gchar *
|
||||
protect_argv_string (const gchar *string)
|
||||
@ -257,7 +261,7 @@ read_data (GString *str,
|
||||
GError **error)
|
||||
{
|
||||
GIOStatus giostatus;
|
||||
gssize bytes;
|
||||
gsize bytes;
|
||||
gchar buf[4096];
|
||||
|
||||
again:
|
||||
@ -304,22 +308,22 @@ make_pipe (gint p[2],
|
||||
*/
|
||||
static gboolean
|
||||
read_helper_report (int fd,
|
||||
gint report[2],
|
||||
gssize report[2],
|
||||
GError **error)
|
||||
{
|
||||
gint bytes = 0;
|
||||
|
||||
while (bytes < sizeof(gint)*2)
|
||||
while (bytes < sizeof(gssize)*2)
|
||||
{
|
||||
gint chunk;
|
||||
|
||||
if (debug)
|
||||
g_print ("%s:read_helper_report: read %d...\n",
|
||||
g_print ("%s:read_helper_report: read %" G_GSIZE_FORMAT "...\n",
|
||||
__FILE__,
|
||||
sizeof(gint)*2 - bytes);
|
||||
sizeof(gssize)*2 - bytes);
|
||||
|
||||
chunk = read (fd, ((gchar*)report) + bytes,
|
||||
sizeof(gint)*2 - bytes);
|
||||
sizeof(gssize)*2 - bytes);
|
||||
|
||||
if (debug)
|
||||
g_print ("...got %d bytes\n", chunk);
|
||||
@ -345,14 +349,14 @@ read_helper_report (int fd,
|
||||
bytes += chunk;
|
||||
}
|
||||
|
||||
if (bytes < sizeof(gint)*2)
|
||||
if (bytes < sizeof(gssize)*2)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_child_error (gint report[2],
|
||||
set_child_error (gssize report[2],
|
||||
const gchar *working_directory,
|
||||
GError **error)
|
||||
{
|
||||
@ -425,7 +429,7 @@ do_spawn_directly (gint *exit_status,
|
||||
{
|
||||
const int mode = (exit_status == NULL) ? P_NOWAIT : P_WAIT;
|
||||
char **new_argv;
|
||||
int rc = -1;
|
||||
gssize rc = -1;
|
||||
int saved_errno;
|
||||
GError *conv_error = NULL;
|
||||
gint conv_error_index;
|
||||
@ -532,7 +536,7 @@ do_spawn_with_pipes (gint *exit_status,
|
||||
char args[ARG_COUNT][10];
|
||||
char **new_argv;
|
||||
int i;
|
||||
int rc = -1;
|
||||
gssize rc = -1;
|
||||
int saved_errno;
|
||||
int argc;
|
||||
int stdin_pipe[2] = { -1, -1 };
|
||||
@ -540,7 +544,7 @@ do_spawn_with_pipes (gint *exit_status,
|
||||
int stderr_pipe[2] = { -1, -1 };
|
||||
int child_err_report_pipe[2] = { -1, -1 };
|
||||
int helper_sync_pipe[2] = { -1, -1 };
|
||||
int helper_report[2];
|
||||
gssize helper_report[2];
|
||||
static gboolean warned_about_child_setup = FALSE;
|
||||
GError *conv_error = NULL;
|
||||
gint conv_error_index;
|
||||
@ -955,7 +959,7 @@ g_spawn_sync_utf8 (const gchar *working_directory,
|
||||
G_IO_IN | G_IO_ERR | G_IO_HUP,
|
||||
&outfd);
|
||||
if (debug)
|
||||
g_print ("outfd=%x\n", outfd.fd);
|
||||
g_print ("outfd=%p\n", (HANDLE) outfd.fd);
|
||||
}
|
||||
|
||||
if (errpipe >= 0)
|
||||
@ -968,7 +972,7 @@ g_spawn_sync_utf8 (const gchar *working_directory,
|
||||
G_IO_IN | G_IO_ERR | G_IO_HUP,
|
||||
&errfd);
|
||||
if (debug)
|
||||
g_print ("errfd=%x\n", errfd.fd);
|
||||
g_print ("errfd=%p\n", (HANDLE) errfd.fd);
|
||||
}
|
||||
|
||||
/* Read data until we get EOF on all pipes. */
|
||||
@ -1070,7 +1074,7 @@ g_spawn_sync_utf8 (const gchar *working_directory,
|
||||
/* Helper process was involved. Read its report now after the
|
||||
* grandchild has finished.
|
||||
*/
|
||||
gint helper_report[2];
|
||||
gssize helper_report[2];
|
||||
|
||||
if (!read_helper_report (reportpipe, helper_report, error))
|
||||
failed = TRUE;
|
||||
|
@ -422,10 +422,17 @@ g_time_val_to_iso8601 (GTimeVal *time_)
|
||||
|
||||
g_return_val_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC, NULL);
|
||||
|
||||
#ifdef _WIN64
|
||||
{
|
||||
time_t secs = time_->tv_sec;
|
||||
tm = gmtime (&secs);
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_GMTIME_R
|
||||
tm = gmtime_r (&time_->tv_sec, &tm_);
|
||||
#else
|
||||
tm = gmtime (&time_->tv_sec);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (time_->tv_usec != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user