From 5589d2b45567a0b35e8d8f55f20b1e381c53ca04 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 4 Feb 2010 19:20:08 +0200 Subject: [PATCH] Internally use the _stati64 API explicitly on Windows Avoids warnings and confusion when compiling with MSVC. --- glib/giowin32.c | 24 ++++++++++-------------- glib/gkeyfile.c | 5 ++--- glib/gmappedfile.c | 5 ++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/glib/giowin32.c b/glib/giowin32.c index 07c9c5f..ae2dcde 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -81,10 +81,6 @@ #include #include -#ifdef _MSC_VER -#define fstat(a,b) _fstat(a,b) -#endif - #include "gstdio.h" #include "glibintl.h" @@ -1795,8 +1791,8 @@ g_io_win32_unimpl_set_flags (GIOChannel *channel, } static GIOFlags -g_io_win32_fd_get_flags_internal (GIOChannel *channel, - struct stat *st) +g_io_win32_fd_get_flags_internal (GIOChannel *channel, + struct _stati64 *st) { GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel; gchar c; @@ -1828,13 +1824,13 @@ g_io_win32_fd_get_flags_internal (GIOChannel *channel, static GIOFlags g_io_win32_fd_get_flags (GIOChannel *channel) { - struct stat st; + struct _stati64 st; GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel; g_return_val_if_fail (win32_channel != NULL, 0); g_return_val_if_fail (win32_channel->type == G_IO_WIN32_FILE_DESC, 0); - if (0 == fstat (win32_channel->fd, &st)) + if (0 == _fstati64 (win32_channel->fd, &st)) return g_io_win32_fd_get_flags_internal (channel, &st); else return 0; @@ -2012,8 +2008,8 @@ g_io_channel_win32_new_messages (guint hwnd) } static GIOChannel * -g_io_channel_win32_new_fd_internal (gint fd, - struct stat *st) +g_io_channel_win32_new_fd_internal (gint fd, + struct _stati64 *st) { GIOWin32Channel *win32_channel; GIOChannel *channel; @@ -2077,9 +2073,9 @@ g_io_channel_win32_new_fd_internal (gint fd, GIOChannel * g_io_channel_win32_new_fd (gint fd) { - struct stat st; + struct _stati64 st; - if (fstat (fd, &st) == -1) + if (_fstati64 (fd, &st) == -1) { g_warning ("g_io_channel_win32_new_fd: %d isn't an open file descriptor in the C library GLib uses.", fd); return NULL; @@ -2136,10 +2132,10 @@ GIOChannel * g_io_channel_unix_new (gint fd) { gboolean is_fd, is_socket; - struct stat st; + struct _stati64 st; int optval, optlen; - is_fd = (fstat (fd, &st) == 0); + is_fd = (_fstati64 (fd, &st) == 0); optlen = sizeof (optval); is_socket = (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &optval, &optlen) != SOCKET_ERROR); diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index a6a543c..2226e70 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -39,9 +39,8 @@ #ifdef G_OS_WIN32 #include -#ifdef _MSC_VER -#define fstat(a,b) _fstat(a,b) -#endif +#define fstat(a,b) _fstati64(a,b) +#define stat _stati64 #ifndef S_ISREG #define S_ISREG(mode) ((mode)&_S_IFREG) diff --git a/glib/gmappedfile.c b/glib/gmappedfile.c index 347f964..59a1a3e 100644 --- a/glib/gmappedfile.c +++ b/glib/gmappedfile.c @@ -38,9 +38,8 @@ #include #include -#ifdef _MSC_VER -#define fstat(a,b) _fstat(a,b) -#endif +#define fstat(a,b) _fstati64(a,b) +#define stat _stati64 #endif -- 2.7.4