summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2001-03-09 21:31:21 +0000
committerTor Lillqvist <tml@src.gnome.org>2001-03-09 21:31:21 +0000
commit754d8ddad85ef7054bf262bbc57ee67a0278f493 (patch)
treeb582eb1be9315427e894cf6f75f83c5d1adf7114
parent31c5b1899ddd9eecea5065f5b9004413b72a0f2c (diff)
downloadglib-754d8ddad85ef7054bf262bbc57ee67a0278f493.tar.gz
Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>.
2001-02-21 Tor Lillqvist <tml@iki.fi> Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>. Hopefully I got it all in while simultaneously adding support for auto*/libtool for mingw. * Makefile.am: Changes for auto* support on Cygwin and Win32. Do still distribute the hand-written makefiles and *.win32.in files, though. Use GIO, GSPAWN and PLATFORMDEP macros set by configure. Use -no-undefined. Pass -export-symbols glib.def to libtool. * configure.in: Define G_PLATFORM_WIN32 on both pure Win32 (mingw) and Cygwin. Add AC_CYGWIN, AC_EXEEXT and AC_LIBTOOL_WIN32_DLL calls for Cygwin and mingw support. Check for %I64u guint64 format (in MS C library). Set G_MODULE_IMPL on mingw and Cygwin. Use ac_object and ac_exeext. Set GIO, GSPAWN, PLATFORMDEP and G_LIBS_EXTRA. Compile timeloop only on Unix. Define OS_WIN32 automake conditional on Win32. * glib.h: Include gwin32.h also on Cygwin. * gfileutils.c (get_contents_posix): Use O_BINARY (defined as 0 on Unix) for Cygwin's sake. * gtimer.c (GETTIME): Reduce #ifdefs, use a macro GETTIME(). * gconvert.c * gthread.c * gutf8.c * gutils.c: For code needed both on Cygwin and native Win32, test for G_PLATFORM_WIN32. * gmarkup.h: Use G_BEGIN_DECLS and G_END_DECLS. * gtypes.h: Refine GLIB_VAR definition. Also check for DLL_EXPORT in case compiling a static library on Win32 or Cygwin. * gwin32.c: No <direct.h> on Cygwin. No need for ftruncate() or dirent emulation on Cygwin. (get_package_directory_from_module) Convert return value from GetModuleFileName() to POSIX path on Cygwin. * tests/Makefile.am (progs_LDADD): Link with libglib, libgthread and libgmodule as appropriate. Use -no-undefined. * gbacktrace.c: Move #ifdefs around a bit on Win32. * gshell.c (unquote_string_inplace): Make static. * testglib.c: Make some vars static. Add Cygwin path tests.
-rw-r--r--glib/gtimer.c37
-rw-r--r--glib/gtypes.h28
-rw-r--r--glib/gunicode.h2
-rw-r--r--glib/gutf8.c5
-rw-r--r--glib/gutils.c28
-rw-r--r--glib/gwin32.c33
-rw-r--r--glib/gwin32.h12
-rw-r--r--glib/makefile.mingw.in2
-rw-r--r--gtimer.c37
-rw-r--r--gtypes.h28
-rw-r--r--gunicode.h2
-rw-r--r--gutf8.c5
-rw-r--r--gutils.c28
-rw-r--r--gwin32.c33
-rw-r--r--gwin32.h12
-rw-r--r--makefile.mingw.in2
-rw-r--r--testglib.c17
-rw-r--r--tests/testglib.c17
18 files changed, 208 insertions, 120 deletions
diff --git a/glib/gtimer.c b/glib/gtimer.c
index 299d638c8..d5e06b011 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -59,6 +59,14 @@ struct _GRealTimer
guint active : 1;
};
+#ifdef G_OS_WIN32
+# define GETTIME(v) \
+ v = GetTickCount ()
+#else /* !G_OS_WIN32 */
+# define GETTIME(v) \
+ gettimeofday (&v, NULL)
+#endif /* !G_OS_WIN32 */
+
GTimer*
g_timer_new (void)
{
@@ -67,11 +75,7 @@ g_timer_new (void)
timer = g_new (GRealTimer, 1);
timer->active = TRUE;
-#ifdef G_OS_WIN32
- timer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&timer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (timer->start);
return ((GTimer*) timer);
}
@@ -94,11 +98,7 @@ g_timer_start (GTimer *timer)
rtimer = (GRealTimer*) timer;
rtimer->active = TRUE;
-#ifdef G_OS_WIN32
- rtimer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (rtimer->start);
}
void
@@ -111,11 +111,7 @@ g_timer_stop (GTimer *timer)
rtimer = (GRealTimer*) timer;
rtimer->active = FALSE;
-#ifdef G_OS_WIN32
- rtimer->end = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->end, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME(rtimer->end);
}
void
@@ -127,11 +123,7 @@ g_timer_reset (GTimer *timer)
rtimer = (GRealTimer*) timer;
-#ifdef G_OS_WIN32
- rtimer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (rtimer->start);
}
gdouble
@@ -152,10 +144,7 @@ g_timer_elapsed (GTimer *timer,
if (rtimer->active)
rtimer->end = GetTickCount ();
- /* Check for wraparound, which happens every 49.7 days.
- * No, Win95 machines probably are never running for that long,
- * but NT machines are.
- */
+ /* Check for wraparound, which happens every 49.7 days. */
if (rtimer->end < rtimer->start)
total = (UINT_MAX - (rtimer->start - rtimer->end)) / 1000.0;
else
diff --git a/glib/gtypes.h b/glib/gtypes.h
index 487ecdc77..29c4de81c 100644
--- a/glib/gtypes.h
+++ b/glib/gtypes.h
@@ -327,15 +327,25 @@ G_END_DECLS
/* We prefix variable declarations so they can
* properly get exported in windows dlls.
*/
-#ifdef G_OS_WIN32
-# ifdef GLIB_COMPILATION
-# define GLIB_VAR __declspec(dllexport)
-# else /* !GLIB_COMPILATION */
-# define GLIB_VAR extern __declspec(dllimport)
-# endif /* !GLIB_COMPILATION */
-#else /* !G_OS_WIN32 */
-# define GLIB_VAR extern
-#endif /* !G_OS_WIN32 */
+#ifndef GLIB_VAR
+# ifdef G_PLATFORM_WIN32
+# ifdef GLIB_STATIC_COMPILATION
+# define GLIB_VAR extern
+# else /* !GLIB_STATIC_COMPILATION */
+# ifdef GLIB_COMPILATION
+# ifdef DLL_EXPORT
+# define GLIB_VAR __declspec(dllexport)
+# else /* !DLL_EXPORT */
+# define GLIB_VAR extern
+# endif /* !DLL_EXPORT */
+# else /* !GLIB_COMPILATION */
+# define GLIB_VAR extern __declspec(dllimport)
+# endif /* !GLIB_COMPILATION */
+# endif /* !GLIB_STATIC_COMPILATION */
+# else /* !G_PLATFORM_WIN32 */
+# define GLIB_VAR extern
+# endif /* !G_PLATFORM_WIN32 */
+#endif /* GLIB_VAR */
#endif /* __G_TYPES_H__ */
diff --git a/glib/gunicode.h b/glib/gunicode.h
index 1abeced3d..8a7cc633f 100644
--- a/glib/gunicode.h
+++ b/glib/gunicode.h
@@ -161,7 +161,7 @@ gunichar *g_unicode_canonical_decomposition (gunichar ch,
/* Array of skip-bytes-per-initial character.
* We prefix variable declarations so they can
- * properly get exported in windows dlls.
+ * properly get exported in Windows DLLs.
*/
GLIB_VAR char g_utf8_skip[256];
diff --git a/glib/gutf8.c b/glib/gutf8.c
index 4ff956bbe..60efce27c 100644
--- a/glib/gutf8.c
+++ b/glib/gutf8.c
@@ -29,10 +29,11 @@
#include "glib.h"
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
#include <stdio.h>
#define STRICT
#include <windows.h>
+#undef STRICT
#endif
#include "glibintl.h"
@@ -341,7 +342,7 @@ g_utf8_get_charset_internal (char **a)
}
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
if (a && ! *a)
{
static char codepage[10];
diff --git a/glib/gutils.c b/glib/gutils.c
index 48ac588ac..c784a58f1 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -64,13 +64,16 @@
#define G_PATH_LENGTH 2048
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
# define STRICT /* Strict typing, please */
# include <windows.h>
# undef STRICT
# include <ctype.h>
+#endif /* G_PLATFORM_WIN32 */
+
+#ifdef G_OS_WIN32
# include <direct.h>
-#endif /* G_OS_WIN32 */
+#endif
#ifdef HAVE_CODESET
#include <langinfo.h>
@@ -548,9 +551,10 @@ g_path_is_absolute (const gchar *file_name)
return TRUE;
#ifdef G_OS_WIN32
+ /* Recognize drive letter on native Windows */
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE;
-#endif
+#endif /* G_OS_WIN32 */
return FALSE;
}
@@ -560,13 +564,13 @@ g_path_skip_root (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, NULL);
-#ifdef G_OS_WIN32
- /* Skip \\server\share */
+#ifdef G_PLATFORM_WIN32
+ /* Skip \\server\share (Win32) or //server/share (Cygwin) */
if (file_name[0] == G_DIR_SEPARATOR &&
file_name[1] == G_DIR_SEPARATOR &&
file_name[2])
{
- gchar *p, *q;
+ gchar *p;
if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
p[1])
@@ -1087,12 +1091,12 @@ g_get_codeset (void)
char *result = nl_langinfo (CODESET);
return g_strdup (result);
#else
-#ifndef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
+ return g_strdup_printf ("CP%d", GetACP ());
+#else
/* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
*/
return g_strdup ("ISO-8859-1");
-#else
- return g_strdup_printf ("CP%d", GetACP ());
#endif
#endif
}
@@ -1102,7 +1106,8 @@ g_get_codeset (void)
#include <libintl.h>
-#ifdef G_OS_WIN32
+#ifndef GLIB_LOCALE_DIR
+#ifdef G_PLATFORM_WIN32
#define GLIB_LOCALE_DIR \
g_win32_get_package_installation_subdirectory \
@@ -1111,7 +1116,8 @@ g_get_codeset (void)
GLIB_MINOR_VERSION), \
"locale")
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
+#endif /* !GLIB_LOCALE_DIR */
G_CONST_RETURN gchar *
_glib_gettext (const gchar *str)
diff --git a/glib/gwin32.c b/glib/gwin32.c
index 473071168..1a9481807 100644
--- a/glib/gwin32.c
+++ b/glib/gwin32.c
@@ -42,7 +42,10 @@
#define STRICT /* Strict typing, please */
#include <windows.h>
+#undef STRICT
+#ifndef G_WITH_CYGWIN
#include <direct.h>
+#endif
#include <errno.h>
#include <ctype.h>
#ifdef _MSC_VER
@@ -51,7 +54,13 @@
#include "glib.h"
-int
+#ifdef G_WITH_CYGWIN
+#include <sys/cygwin.h>
+#endif
+
+#ifndef G_WITH_CYGWIN
+
+gint
g_win32_ftruncate (gint fd,
guint size)
{
@@ -214,8 +223,9 @@ g_win32_closedir (DIR *dir)
return 0;
}
+#endif
-/* Mingw32 headers don't have latest language and sublanguage codes */
+/* Mingw headers don't have latest language and sublanguage codes */
#ifndef LANG_AFRIKAANS
#define LANG_AFRIKAANS 0x36
#endif
@@ -873,12 +883,23 @@ get_package_directory_from_module (gchar *module_name)
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
return NULL;
- if ((p = strrchr (fn, '\\')) != NULL)
+#ifdef G_WITH_CYGWIN
+ /* In Cygwin we need to have POSIX paths */
+ {
+ gchar tmp[MAX_PATH];
+
+ cygwin_conv_to_posix_path(fn, tmp);
+ g_free(fn);
+ fn = g_strdup(tmp);
+ }
+#endif
+
+ if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
if (module_name)
{
- p = strrchr (fn, '\\');
+ p = strrchr (fn, G_DIR_SEPARATOR);
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
g_strcasecmp (p + 1, "lib") == 0))
*p = '\0';
@@ -927,7 +948,6 @@ g_win32_get_package_installation_directory (gchar *package,
static GHashTable *package_dirs = NULL;
gchar *result = NULL;
gchar *key;
- char win_dir[MAX_PATH];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
@@ -1001,7 +1021,8 @@ g_win32_get_package_installation_subdirectory (gchar *package,
prefix = g_win32_get_package_installation_directory (package, dll_name);
- sep = (prefix[strlen (prefix) - 1] == '\\' ? "" : "\\");
+ sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
+ "" : G_DIR_SEPARATOR_S);
return g_strconcat (prefix, sep, subdir, NULL);
}
diff --git a/glib/gwin32.h b/glib/gwin32.h
index 3168e08b9..d3592490a 100644
--- a/glib/gwin32.h
+++ b/glib/gwin32.h
@@ -29,19 +29,23 @@
#include <gtypes.h>
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
/* Windows emulation stubs for common Unix functions
*/
G_BEGIN_DECLS
+#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
+#endif
#ifdef _MSC_VER
typedef int pid_t;
#endif
+#ifdef G_OS_WIN32
+
/*
* To get prototypes for the following POSIXish functions, you have to
* include the indicated non-POSIX headers. The functions are defined
@@ -89,13 +93,15 @@ struct DIR
typedef struct DIR DIR;
/* emulation functions */
-extern int g_win32_ftruncate (gint f,
+gint g_win32_ftruncate (gint f,
guint size);
DIR* g_win32_opendir (const gchar *dirname);
struct dirent* g_win32_readdir (DIR *dir);
void g_win32_rewinddir (DIR *dir);
gint g_win32_closedir (DIR *dir);
+#endif /* G_OS_WIN32 */
+
/* The MS setlocale uses locale names of the form "English_United
* States.1252" etc. We want the Unixish standard form "en", "zh_TW"
* etc. This function gets the current thread locale from Windows and
@@ -119,6 +125,6 @@ gchar* g_win32_get_package_installation_subdirectory (gchar *package,
G_END_DECLS
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
#endif /* __G_WIN32_H__ */
diff --git a/glib/makefile.mingw.in b/glib/makefile.mingw.in
index 338deb611..7c2df39ec 100644
--- a/glib/makefile.mingw.in
+++ b/glib/makefile.mingw.in
@@ -15,7 +15,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
# Nothing much configurable below
INCLUDES = -I .
-DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG
+DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DDLL_EXPORT
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
DLLS_TO_BUILD = \
diff --git a/gtimer.c b/gtimer.c
index 299d638c8..d5e06b011 100644
--- a/gtimer.c
+++ b/gtimer.c
@@ -59,6 +59,14 @@ struct _GRealTimer
guint active : 1;
};
+#ifdef G_OS_WIN32
+# define GETTIME(v) \
+ v = GetTickCount ()
+#else /* !G_OS_WIN32 */
+# define GETTIME(v) \
+ gettimeofday (&v, NULL)
+#endif /* !G_OS_WIN32 */
+
GTimer*
g_timer_new (void)
{
@@ -67,11 +75,7 @@ g_timer_new (void)
timer = g_new (GRealTimer, 1);
timer->active = TRUE;
-#ifdef G_OS_WIN32
- timer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&timer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (timer->start);
return ((GTimer*) timer);
}
@@ -94,11 +98,7 @@ g_timer_start (GTimer *timer)
rtimer = (GRealTimer*) timer;
rtimer->active = TRUE;
-#ifdef G_OS_WIN32
- rtimer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (rtimer->start);
}
void
@@ -111,11 +111,7 @@ g_timer_stop (GTimer *timer)
rtimer = (GRealTimer*) timer;
rtimer->active = FALSE;
-#ifdef G_OS_WIN32
- rtimer->end = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->end, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME(rtimer->end);
}
void
@@ -127,11 +123,7 @@ g_timer_reset (GTimer *timer)
rtimer = (GRealTimer*) timer;
-#ifdef G_OS_WIN32
- rtimer->start = GetTickCount ();
-#else /* !G_OS_WIN32 */
- gettimeofday (&rtimer->start, NULL);
-#endif /* !G_OS_WIN32 */
+ GETTIME (rtimer->start);
}
gdouble
@@ -152,10 +144,7 @@ g_timer_elapsed (GTimer *timer,
if (rtimer->active)
rtimer->end = GetTickCount ();
- /* Check for wraparound, which happens every 49.7 days.
- * No, Win95 machines probably are never running for that long,
- * but NT machines are.
- */
+ /* Check for wraparound, which happens every 49.7 days. */
if (rtimer->end < rtimer->start)
total = (UINT_MAX - (rtimer->start - rtimer->end)) / 1000.0;
else
diff --git a/gtypes.h b/gtypes.h
index 487ecdc77..29c4de81c 100644
--- a/gtypes.h
+++ b/gtypes.h
@@ -327,15 +327,25 @@ G_END_DECLS
/* We prefix variable declarations so they can
* properly get exported in windows dlls.
*/
-#ifdef G_OS_WIN32
-# ifdef GLIB_COMPILATION
-# define GLIB_VAR __declspec(dllexport)
-# else /* !GLIB_COMPILATION */
-# define GLIB_VAR extern __declspec(dllimport)
-# endif /* !GLIB_COMPILATION */
-#else /* !G_OS_WIN32 */
-# define GLIB_VAR extern
-#endif /* !G_OS_WIN32 */
+#ifndef GLIB_VAR
+# ifdef G_PLATFORM_WIN32
+# ifdef GLIB_STATIC_COMPILATION
+# define GLIB_VAR extern
+# else /* !GLIB_STATIC_COMPILATION */
+# ifdef GLIB_COMPILATION
+# ifdef DLL_EXPORT
+# define GLIB_VAR __declspec(dllexport)
+# else /* !DLL_EXPORT */
+# define GLIB_VAR extern
+# endif /* !DLL_EXPORT */
+# else /* !GLIB_COMPILATION */
+# define GLIB_VAR extern __declspec(dllimport)
+# endif /* !GLIB_COMPILATION */
+# endif /* !GLIB_STATIC_COMPILATION */
+# else /* !G_PLATFORM_WIN32 */
+# define GLIB_VAR extern
+# endif /* !G_PLATFORM_WIN32 */
+#endif /* GLIB_VAR */
#endif /* __G_TYPES_H__ */
diff --git a/gunicode.h b/gunicode.h
index 1abeced3d..8a7cc633f 100644
--- a/gunicode.h
+++ b/gunicode.h
@@ -161,7 +161,7 @@ gunichar *g_unicode_canonical_decomposition (gunichar ch,
/* Array of skip-bytes-per-initial character.
* We prefix variable declarations so they can
- * properly get exported in windows dlls.
+ * properly get exported in Windows DLLs.
*/
GLIB_VAR char g_utf8_skip[256];
diff --git a/gutf8.c b/gutf8.c
index 4ff956bbe..60efce27c 100644
--- a/gutf8.c
+++ b/gutf8.c
@@ -29,10 +29,11 @@
#include "glib.h"
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
#include <stdio.h>
#define STRICT
#include <windows.h>
+#undef STRICT
#endif
#include "glibintl.h"
@@ -341,7 +342,7 @@ g_utf8_get_charset_internal (char **a)
}
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
if (a && ! *a)
{
static char codepage[10];
diff --git a/gutils.c b/gutils.c
index 48ac588ac..c784a58f1 100644
--- a/gutils.c
+++ b/gutils.c
@@ -64,13 +64,16 @@
#define G_PATH_LENGTH 2048
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
# define STRICT /* Strict typing, please */
# include <windows.h>
# undef STRICT
# include <ctype.h>
+#endif /* G_PLATFORM_WIN32 */
+
+#ifdef G_OS_WIN32
# include <direct.h>
-#endif /* G_OS_WIN32 */
+#endif
#ifdef HAVE_CODESET
#include <langinfo.h>
@@ -548,9 +551,10 @@ g_path_is_absolute (const gchar *file_name)
return TRUE;
#ifdef G_OS_WIN32
+ /* Recognize drive letter on native Windows */
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE;
-#endif
+#endif /* G_OS_WIN32 */
return FALSE;
}
@@ -560,13 +564,13 @@ g_path_skip_root (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, NULL);
-#ifdef G_OS_WIN32
- /* Skip \\server\share */
+#ifdef G_PLATFORM_WIN32
+ /* Skip \\server\share (Win32) or //server/share (Cygwin) */
if (file_name[0] == G_DIR_SEPARATOR &&
file_name[1] == G_DIR_SEPARATOR &&
file_name[2])
{
- gchar *p, *q;
+ gchar *p;
if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
p[1])
@@ -1087,12 +1091,12 @@ g_get_codeset (void)
char *result = nl_langinfo (CODESET);
return g_strdup (result);
#else
-#ifndef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
+ return g_strdup_printf ("CP%d", GetACP ());
+#else
/* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
*/
return g_strdup ("ISO-8859-1");
-#else
- return g_strdup_printf ("CP%d", GetACP ());
#endif
#endif
}
@@ -1102,7 +1106,8 @@ g_get_codeset (void)
#include <libintl.h>
-#ifdef G_OS_WIN32
+#ifndef GLIB_LOCALE_DIR
+#ifdef G_PLATFORM_WIN32
#define GLIB_LOCALE_DIR \
g_win32_get_package_installation_subdirectory \
@@ -1111,7 +1116,8 @@ g_get_codeset (void)
GLIB_MINOR_VERSION), \
"locale")
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
+#endif /* !GLIB_LOCALE_DIR */
G_CONST_RETURN gchar *
_glib_gettext (const gchar *str)
diff --git a/gwin32.c b/gwin32.c
index 473071168..1a9481807 100644
--- a/gwin32.c
+++ b/gwin32.c
@@ -42,7 +42,10 @@
#define STRICT /* Strict typing, please */
#include <windows.h>
+#undef STRICT
+#ifndef G_WITH_CYGWIN
#include <direct.h>
+#endif
#include <errno.h>
#include <ctype.h>
#ifdef _MSC_VER
@@ -51,7 +54,13 @@
#include "glib.h"
-int
+#ifdef G_WITH_CYGWIN
+#include <sys/cygwin.h>
+#endif
+
+#ifndef G_WITH_CYGWIN
+
+gint
g_win32_ftruncate (gint fd,
guint size)
{
@@ -214,8 +223,9 @@ g_win32_closedir (DIR *dir)
return 0;
}
+#endif
-/* Mingw32 headers don't have latest language and sublanguage codes */
+/* Mingw headers don't have latest language and sublanguage codes */
#ifndef LANG_AFRIKAANS
#define LANG_AFRIKAANS 0x36
#endif
@@ -873,12 +883,23 @@ get_package_directory_from_module (gchar *module_name)
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
return NULL;
- if ((p = strrchr (fn, '\\')) != NULL)
+#ifdef G_WITH_CYGWIN
+ /* In Cygwin we need to have POSIX paths */
+ {
+ gchar tmp[MAX_PATH];
+
+ cygwin_conv_to_posix_path(fn, tmp);
+ g_free(fn);
+ fn = g_strdup(tmp);
+ }
+#endif
+
+ if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
if (module_name)
{
- p = strrchr (fn, '\\');
+ p = strrchr (fn, G_DIR_SEPARATOR);
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
g_strcasecmp (p + 1, "lib") == 0))
*p = '\0';
@@ -927,7 +948,6 @@ g_win32_get_package_installation_directory (gchar *package,
static GHashTable *package_dirs = NULL;
gchar *result = NULL;
gchar *key;
- char win_dir[MAX_PATH];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
@@ -1001,7 +1021,8 @@ g_win32_get_package_installation_subdirectory (gchar *package,
prefix = g_win32_get_package_installation_directory (package, dll_name);
- sep = (prefix[strlen (prefix) - 1] == '\\' ? "" : "\\");
+ sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
+ "" : G_DIR_SEPARATOR_S);
return g_strconcat (prefix, sep, subdir, NULL);
}
diff --git a/gwin32.h b/gwin32.h
index 3168e08b9..d3592490a 100644
--- a/gwin32.h
+++ b/gwin32.h
@@ -29,19 +29,23 @@
#include <gtypes.h>
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
/* Windows emulation stubs for common Unix functions
*/
G_BEGIN_DECLS
+#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
+#endif
#ifdef _MSC_VER
typedef int pid_t;
#endif
+#ifdef G_OS_WIN32
+
/*
* To get prototypes for the following POSIXish functions, you have to
* include the indicated non-POSIX headers. The functions are defined
@@ -89,13 +93,15 @@ struct DIR
typedef struct DIR DIR;
/* emulation functions */
-extern int g_win32_ftruncate (gint f,
+gint g_win32_ftruncate (gint f,
guint size);
DIR* g_win32_opendir (const gchar *dirname);
struct dirent* g_win32_readdir (DIR *dir);
void g_win32_rewinddir (DIR *dir);
gint g_win32_closedir (DIR *dir);
+#endif /* G_OS_WIN32 */
+
/* The MS setlocale uses locale names of the form "English_United
* States.1252" etc. We want the Unixish standard form "en", "zh_TW"
* etc. This function gets the current thread locale from Windows and
@@ -119,6 +125,6 @@ gchar* g_win32_get_package_installation_subdirectory (gchar *package,
G_END_DECLS
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
#endif /* __G_WIN32_H__ */
diff --git a/makefile.mingw.in b/makefile.mingw.in
index 338deb611..7c2df39ec 100644
--- a/makefile.mingw.in
+++ b/makefile.mingw.in
@@ -15,7 +15,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
# Nothing much configurable below
INCLUDES = -I .
-DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG
+DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DDLL_EXPORT
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
DLLS_TO_BUILD = \
diff --git a/testglib.c b/testglib.c
index 1e1adf3ce..4617487d6 100644
--- a/testglib.c
+++ b/testglib.c
@@ -46,8 +46,8 @@
#include <io.h> /* For read(), write() etc */
#endif
-int array[10000];
-gboolean failed = FALSE;
+static int array[10000];
+static gboolean failed = FALSE;
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
if (failed) \
@@ -351,6 +351,9 @@ main (int argc,
{ "a\\b\\", "a\\b" },
{ "c\\\\\\", "c" },
#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//server/share" },
+#endif
{ ".", "." },
{ "..", "." },
{ "", "." },
@@ -374,6 +377,9 @@ main (int argc,
{ "\\\\server\\foo\\bar", "bar" },
{ "a\\b", NULL },
#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//x" },
+#endif
{ ".", NULL },
{ "", NULL },
};
@@ -397,6 +403,11 @@ main (int argc,
GLIB_MAJOR_VERSION,
GLIB_MINOR_VERSION);
#endif
+#ifdef G_WITH_CYGWIN
+ gchar *glib_dll = g_strdup_printf ("cygglib-%d.%d.dll",
+ GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION);
+#endif
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
glib_major_version,
@@ -1151,7 +1162,7 @@ main (int argc,
g_print ("ok\n");
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
g_print ("current locale: %s\n", g_win32_getlocale ());
g_print ("GLib installation directory, from Registry entry for %s if available: %s\n",
diff --git a/tests/testglib.c b/tests/testglib.c
index 1e1adf3ce..4617487d6 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -46,8 +46,8 @@
#include <io.h> /* For read(), write() etc */
#endif
-int array[10000];
-gboolean failed = FALSE;
+static int array[10000];
+static gboolean failed = FALSE;
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
if (failed) \
@@ -351,6 +351,9 @@ main (int argc,
{ "a\\b\\", "a\\b" },
{ "c\\\\\\", "c" },
#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//server/share" },
+#endif
{ ".", "." },
{ "..", "." },
{ "", "." },
@@ -374,6 +377,9 @@ main (int argc,
{ "\\\\server\\foo\\bar", "bar" },
{ "a\\b", NULL },
#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//x" },
+#endif
{ ".", NULL },
{ "", NULL },
};
@@ -397,6 +403,11 @@ main (int argc,
GLIB_MAJOR_VERSION,
GLIB_MINOR_VERSION);
#endif
+#ifdef G_WITH_CYGWIN
+ gchar *glib_dll = g_strdup_printf ("cygglib-%d.%d.dll",
+ GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION);
+#endif
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
glib_major_version,
@@ -1151,7 +1162,7 @@ main (int argc,
g_print ("ok\n");
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
g_print ("current locale: %s\n", g_win32_getlocale ());
g_print ("GLib installation directory, from Registry entry for %s if available: %s\n",