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)
{
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);
}
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
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
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
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
/* 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__ */
/* 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];
#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"
}
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
if (a && ! *a)
{
static char codepage[10];
#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>
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;
}
{
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])
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
}
#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 \
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)
#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
#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)
{
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
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';
static GHashTable *package_dirs = NULL;
gchar *result = NULL;
gchar *key;
- char win_dir[MAX_PATH];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
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);
}
#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
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
G_END_DECLS
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
#endif /* __G_WIN32_H__ */
# 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 = \
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)
{
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);
}
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
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
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
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
/* 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__ */
/* 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];
#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"
}
#endif
-#ifdef G_OS_WIN32
+#ifdef G_PLATFORM_WIN32
if (a && ! *a)
{
static char codepage[10];
#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>
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;
}
{
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])
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
}
#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 \
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)
#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
#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)
{
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
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';
static GHashTable *package_dirs = NULL;
gchar *result = NULL;
gchar *key;
- char win_dir[MAX_PATH];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
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);
}
#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
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
G_END_DECLS
-#endif /* G_OS_WIN32 */
+#endif /* G_PLATFORM_WIN32 */
#endif /* __G_WIN32_H__ */
# 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 = \
#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) \
{ "a\\b", "a" },
{ "a\\b\\", "a\\b" },
{ "c\\\\\\", "c" },
+#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//server/share" },
#endif
{ ".", "." },
{ "..", "." },
{ "\\\\server\\foo", "" },
{ "\\\\server\\foo\\bar", "bar" },
{ "a\\b", NULL },
+#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//x" },
#endif
{ ".", NULL },
{ "", NULL },
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,
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",
#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) \
{ "a\\b", "a" },
{ "a\\b\\", "a\\b" },
{ "c\\\\\\", "c" },
+#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//server/share" },
#endif
{ ".", "." },
{ "..", "." },
{ "\\\\server\\foo", "" },
{ "\\\\server\\foo\\bar", "bar" },
{ "a\\b", NULL },
+#endif
+#ifdef G_WITH_CYGWIN
+ { "//server/share///x", "//x" },
#endif
{ ".", NULL },
{ "", NULL },
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,
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",