glib/giowin32.c glib/gmain.c glib/gspawn-win32.c Change gssize casts

2008-08-04  Tor Lillqvist  <tml@novell.com>

	* glib/giowin32.c
	* glib/gmain.c
	* glib/gspawn-win32.c
	* glib/gspawn-win32-helper.c: Change gssize casts introduced on
	2008-07-28 to gintptr casts now that we have that. gssize is as
	such the same as gintptr on both 32- and 64-bit Windows, but the
	gintptr name indicates that it is used to hold pointers, i.e. also
	HANDLEs.


svn path=/trunk/; revision=7306
This commit is contained in:
Tor Lillqvist 2008-08-04 18:46:59 +00:00 committed by Tor Lillqvist
parent 722379caa9
commit 0e2384faa8
5 changed files with 37 additions and 28 deletions

View File

@ -1,5 +1,14 @@
2008-08-04 Tor Lillqvist <tml@novell.com> 2008-08-04 Tor Lillqvist <tml@novell.com>
* glib/giowin32.c
* glib/gmain.c
* glib/gspawn-win32.c
* glib/gspawn-win32-helper.c: Change gssize casts introduced on
2008-07-28 to gintptr casts now that we have that. gssize is as
such the same as gintptr on both 32- and 64-bit Windows, but the
gintptr name indicates that it is used to hold pointers, i.e. also
HANDLEs.
* tests/testglib.c: Avoid warning on Win64 by using gintptr cast * tests/testglib.c: Avoid warning on Win64 by using gintptr cast
instead if long cast. instead if long cast.

View File

@ -1075,7 +1075,7 @@ g_io_win32_msg_create_watch (GIOChannel *channel,
watch->condition = condition; watch->condition = condition;
watch->pollfd.fd = (gssize) G_WIN32_MSG_HANDLE; watch->pollfd.fd = (gintptr) G_WIN32_MSG_HANDLE;
watch->pollfd.events = condition; watch->pollfd.events = condition;
g_source_add_poll (source, &watch->pollfd); g_source_add_poll (source, &watch->pollfd);
@ -1279,7 +1279,7 @@ g_io_win32_fd_create_watch (GIOChannel *channel,
if (win32_channel->data_avail_event == NULL) if (win32_channel->data_avail_event == NULL)
create_events (win32_channel); create_events (win32_channel);
watch->pollfd.fd = (gssize) win32_channel->data_avail_event; watch->pollfd.fd = (gintptr) win32_channel->data_avail_event;
watch->pollfd.events = condition; watch->pollfd.events = condition;
if (win32_channel->debug) if (win32_channel->debug)
@ -1332,7 +1332,7 @@ g_io_win32_console_create_watch (GIOChannel *channel,
watch->condition = condition; watch->condition = condition;
watch->pollfd.fd = (gssize) _get_osfhandle (win32_channel->fd); watch->pollfd.fd = _get_osfhandle (win32_channel->fd);
watch->pollfd.events = condition; watch->pollfd.events = condition;
g_source_add_poll (source, &watch->pollfd); g_source_add_poll (source, &watch->pollfd);
@ -1500,7 +1500,7 @@ g_io_win32_sock_create_watch (GIOChannel *channel,
if (win32_channel->event == 0) if (win32_channel->event == 0)
win32_channel->event = WSACreateEvent (); win32_channel->event = WSACreateEvent ();
watch->pollfd.fd = (gssize) win32_channel->event; watch->pollfd.fd = (gintptr) win32_channel->event;
watch->pollfd.events = condition; watch->pollfd.events = condition;
if (win32_channel->debug) if (win32_channel->debug)
@ -2045,7 +2045,7 @@ g_io_channel_win32_make_pollfd (GIOChannel *channel,
if (win32_channel->data_avail_event == NULL) if (win32_channel->data_avail_event == NULL)
create_events (win32_channel); create_events (win32_channel);
fd->fd = (gssize) win32_channel->data_avail_event; fd->fd = (gintptr) win32_channel->data_avail_event;
if (win32_channel->thread_id == 0 && (condition & G_IO_IN)) if (win32_channel->thread_id == 0 && (condition & G_IO_IN))
{ {
@ -2057,15 +2057,15 @@ g_io_channel_win32_make_pollfd (GIOChannel *channel,
break; break;
case G_IO_WIN32_CONSOLE: case G_IO_WIN32_CONSOLE:
fd->fd = (gssize) _get_osfhandle (win32_channel->fd); fd->fd = _get_osfhandle (win32_channel->fd);
break; break;
case G_IO_WIN32_SOCKET: case G_IO_WIN32_SOCKET:
fd->fd = (gssize) WSACreateEvent (); fd->fd = (gintptr) WSACreateEvent ();
break; break;
case G_IO_WIN32_WINDOWS_MESSAGES: case G_IO_WIN32_WINDOWS_MESSAGES:
fd->fd = (gssize) G_WIN32_MSG_HANDLE; fd->fd = G_WIN32_MSG_HANDLE;
break; break;
default: default:

View File

@ -686,7 +686,7 @@ g_main_context_init_pipe (GMainContext *context)
if (context->wake_up_semaphore == NULL) if (context->wake_up_semaphore == NULL)
g_error ("Cannot create wake-up semaphore: %s", g_error ("Cannot create wake-up semaphore: %s",
g_win32_error_message (GetLastError ())); g_win32_error_message (GetLastError ()));
context->wake_up_rec.fd = (gssize) context->wake_up_semaphore; context->wake_up_rec.fd = (gintptr) context->wake_up_semaphore;
context->wake_up_rec.events = G_IO_IN; context->wake_up_rec.events = G_IO_IN;
# ifdef G_MAIN_POLL_DEBUG # ifdef G_MAIN_POLL_DEBUG
if (g_main_poll_debug) if (g_main_poll_debug)
@ -4046,7 +4046,7 @@ g_child_watch_source_new (GPid pid)
GChildWatchSource *child_watch_source = (GChildWatchSource *)source; GChildWatchSource *child_watch_source = (GChildWatchSource *)source;
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
child_watch_source->poll.fd = (gssize) pid; child_watch_source->poll.fd = (gintptr) pid;
child_watch_source->poll.events = G_IO_IN; child_watch_source->poll.events = G_IO_IN;
g_source_add_poll (source, &child_watch_source->poll); g_source_add_poll (source, &child_watch_source->poll);

View File

@ -30,13 +30,13 @@
static void static void
write_err_and_exit (gint fd, write_err_and_exit (gint fd,
gssize msg) gintptr msg)
{ {
gssize en = errno; gintptr en = errno;
write (fd, &msg, sizeof(gssize)); write (fd, &msg, sizeof(gintptr));
write (fd, &en, sizeof(gssize)); write (fd, &en, sizeof(gintptr));
_exit (1); _exit (1);
} }
@ -163,9 +163,9 @@ main (int ignored_argc, char **ignored_argv)
int i; int i;
int fd; int fd;
int mode; int mode;
gssize handle; gintptr handle;
int saved_errno; int saved_errno;
gssize no_error = CHILD_NO_ERROR; gintptr no_error = CHILD_NO_ERROR;
gint argv_zero_offset = ARG_PROGRAM; gint argv_zero_offset = ARG_PROGRAM;
wchar_t **new_wargv; wchar_t **new_wargv;
int argc; int argc;

View File

@ -111,7 +111,7 @@ dup_noninherited (int fd,
GetCurrentProcess (), &filehandle, GetCurrentProcess (), &filehandle,
0, FALSE, DUPLICATE_SAME_ACCESS); 0, FALSE, DUPLICATE_SAME_ACCESS);
close (fd); close (fd);
return _open_osfhandle ((gssize) filehandle, mode | _O_NOINHERIT); return _open_osfhandle ((gintptr) filehandle, mode | _O_NOINHERIT);
} }
#ifndef GSPAWN_HELPER #ifndef GSPAWN_HELPER
@ -308,22 +308,22 @@ make_pipe (gint p[2],
*/ */
static gboolean static gboolean
read_helper_report (int fd, read_helper_report (int fd,
gssize report[2], gintptr report[2],
GError **error) GError **error)
{ {
gint bytes = 0; gint bytes = 0;
while (bytes < sizeof(gssize)*2) while (bytes < sizeof(gintptr)*2)
{ {
gint chunk; gint chunk;
if (debug) if (debug)
g_print ("%s:read_helper_report: read %" G_GSIZE_FORMAT "...\n", g_print ("%s:read_helper_report: read %" G_GSIZE_FORMAT "...\n",
__FILE__, __FILE__,
sizeof(gssize)*2 - bytes); sizeof(gintptr)*2 - bytes);
chunk = read (fd, ((gchar*)report) + bytes, chunk = read (fd, ((gchar*)report) + bytes,
sizeof(gssize)*2 - bytes); sizeof(gintptr)*2 - bytes);
if (debug) if (debug)
g_print ("...got %d bytes\n", chunk); g_print ("...got %d bytes\n", chunk);
@ -349,14 +349,14 @@ read_helper_report (int fd,
bytes += chunk; bytes += chunk;
} }
if (bytes < sizeof(gssize)*2) if (bytes < sizeof(gintptr)*2)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static void static void
set_child_error (gssize report[2], set_child_error (gintptr report[2],
const gchar *working_directory, const gchar *working_directory,
GError **error) GError **error)
{ {
@ -429,7 +429,7 @@ do_spawn_directly (gint *exit_status,
{ {
const int mode = (exit_status == NULL) ? P_NOWAIT : P_WAIT; const int mode = (exit_status == NULL) ? P_NOWAIT : P_WAIT;
char **new_argv; char **new_argv;
gssize rc = -1; gintptr rc = -1;
int saved_errno; int saved_errno;
GError *conv_error = NULL; GError *conv_error = NULL;
gint conv_error_index; gint conv_error_index;
@ -536,7 +536,7 @@ do_spawn_with_pipes (gint *exit_status,
char args[ARG_COUNT][10]; char args[ARG_COUNT][10];
char **new_argv; char **new_argv;
int i; int i;
gssize rc = -1; gintptr rc = -1;
int saved_errno; int saved_errno;
int argc; int argc;
int stdin_pipe[2] = { -1, -1 }; int stdin_pipe[2] = { -1, -1 };
@ -544,7 +544,7 @@ do_spawn_with_pipes (gint *exit_status,
int stderr_pipe[2] = { -1, -1 }; int stderr_pipe[2] = { -1, -1 };
int child_err_report_pipe[2] = { -1, -1 }; int child_err_report_pipe[2] = { -1, -1 };
int helper_sync_pipe[2] = { -1, -1 }; int helper_sync_pipe[2] = { -1, -1 };
gssize helper_report[2]; gintptr helper_report[2];
static gboolean warned_about_child_setup = FALSE; static gboolean warned_about_child_setup = FALSE;
GError *conv_error = NULL; GError *conv_error = NULL;
gint conv_error_index; gint conv_error_index;
@ -1074,7 +1074,7 @@ g_spawn_sync_utf8 (const gchar *working_directory,
/* Helper process was involved. Read its report now after the /* Helper process was involved. Read its report now after the
* grandchild has finished. * grandchild has finished.
*/ */
gssize helper_report[2]; gintptr helper_report[2];
if (!read_helper_report (reportpipe, helper_report, error)) if (!read_helper_report (reportpipe, helper_report, error))
failed = TRUE; failed = TRUE;