/* Following fields used by socket channels */
int event_mask;
int last_events;
- int event;
+ HANDLE event;
gboolean write_would_have_blocked;
};
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);
}
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);
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);
static GIOStatus
buffer_read (GIOWin32Channel *channel,
- guchar *dest,
+ gchar *dest,
gsize count,
gsize *bytes_read,
GError **err)
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)
static GIOStatus
buffer_write (GIOWin32Channel *channel,
- const guchar *dest,
+ const gchar *dest,
gsize count,
gsize *bytes_written,
GError **err)
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)
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)
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);
}
}
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
{
{
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;
}
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;
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);
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)
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)
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)
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);
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);
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);
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);
};
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;
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;
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))
{
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:
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)
GError **error)
{
GIOStatus giostatus;
- gssize bytes;
+ gsize bytes;
gchar buf[4096];
again:
*/
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);
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)
{
{
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;
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 };
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;
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)
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. */
/* 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;