Broadway: Allow Compilation on Windows/MSVC

-Don't include unistd.h unconditionally as it's not available in Visual
 Studio, but include io.h where necessary.
-Avoid C99isms, and use _chsize_s in place of ftruncate when unistd.h is
 not available (as in the case of Visual Studio)
This commit is contained in:
Chun-wei Fan 2013-07-01 14:51:03 +02:00 committed by Alexander Larsson
parent 4b49c44b0a
commit 2268e9d6c9
4 changed files with 14 additions and 1 deletions

View File

@ -12,7 +12,11 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#elif defined (G_OS_WIN32)
#include <io.h>
#endif
#include <crypt.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@ -979,7 +983,7 @@ static gchar *
generate_handshake_response_wsietf_v7 (const gchar *key)
{
gsize digest_len = 20;
guchar digest[digest_len];
guchar digest[20];
GChecksum *checksum;
checksum = g_checksum_new (G_CHECKSUM_SHA1);

View File

@ -18,7 +18,12 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#elif defined (G_OS_WIN32)
#include <io.h>
#define ftruncate _chsize_s
#endif
#include <sys/types.h>
#ifdef G_OS_WIN32
#include <windows.h>

View File

@ -37,7 +37,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
static void gdk_broadway_display_dispose (GObject *object);

View File

@ -33,7 +33,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <limits.h>
#include <errno.h>