Updating glib2.0
Ken Brown
kbrown@cornell.edu
Sat May 23 18:08:35 GMT 2020
On 5/22/2020 7:18 PM, Ken Brown via Cygwin-apps wrote:
> I've been planning to adopt gimp and some related build dependencies. My reason
> is that I use gimp and would like to see it kept up to date.
>
> I thought I had all the prerequisites I needed. But when I built gimp, I
> discovered that it used two functions, g_set_weak_pointer and
> g_date_time_new_from_iso8601, that were introduced in glib-2.56.
>
> [gimp's configure.ac says that it only requires glib 2.54.2, but this seems to
> be wrong. Cygwin's glib is at 2.54.3. Fedora's is at 2.64.3, which is the
> latest upstream release.]
>
> I'd appreciate some advice about how to proceed. I'm not interested in adopting
> all of GNOME, and it probably doesn't make sense for different components of
> GNOME to be adopted by different people.
>
> A short-term solution (from my personal POV) would be for me to do a
> non-maintainer update of glib to 2.56, assuming that's doable without messing up
> other GNOME components.
>
> A better solution (again from my personal POV) would be for someone to adopt
> GNOME and update it to its latest release.
To focus the discussion a little better, I've built and installed
glib2.0-2.56.4. My cygport file and patches are attached. I can now build
gimp-2.10.18, and it seems to run fine in limited testing.
Ken
-------------- next part --------------
Fix for -Werror=nested-externs
--- origsrc/glib-2.34.3/m4macros/glib-gettext.m4 2012-11-20 08:27:12.000000000 -0600
+++ src/glib-2.34.3/m4macros/glib-gettext.m4 2013-04-15 02:04:25.707401500 -0500
@@ -222,8 +222,8 @@ msgstr ""
AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
- AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
- return _nl_msg_cat_cntr],
+ AC_TRY_LINK([extern int _nl_msg_cat_cntr;],
+ [return _nl_msg_cat_cntr],
[CATOBJEXT=.gmo
DATADIRNAME=share],
[case $host in
-------------- next part --------------
--- origsrc/glib-2.36.3/configure.ac 2013-08-04 20:21:20.808722600 -0500
+++ src/glib-2.36.3/configure.ac 2013-08-04 18:30:21.852852200 -0500
@@ -1880,7 +1880,7 @@ dnl ************************************
AC_MSG_CHECKING(for platform-dependent source)
case "$host" in
- *-*-cygwin*|*-*-mingw*)
+ *-*-mingw*)
PLATFORMDEP=gwin32.lo
;;
*)
@@ -2594,9 +2594,6 @@ dnl *** Win32 API libs ***
dnl **********************
case $host in
- *-*-cygwin*)
- G_LIBS_EXTRA="-luser32 -lkernel32"
- ;;
*-*-mingw*)
G_LIBS_EXTRA="-lws2_32 -lole32 -lwinmm -lshlwapi"
;;
--- origsrc/glib-2.36.3/docs/reference/gio/Makefile.am 2013-08-04 20:21:20.849725000 -0500
+++ src/glib-2.36.3/docs/reference/gio/Makefile.am 2013-08-04 18:11:14.000000000 -0500
@@ -77,6 +77,8 @@ IGNORE_HFILES = \
gunixvolume.h \
gunixvolumemonitor.h \
gwin32appinfo.h \
+ gwin32inputstream.h \
+ gwin32outputstream.h \
gwin32mount.h \
gwin32resolver.h \
gwin32volumemonitor.h
--- origsrc/glib-2.36.3/gio/giomodule-priv.h 2013-08-04 20:21:20.877726600 -0500
+++ src/glib-2.36.3/gio/giomodule-priv.h 2013-08-04 18:11:14.000000000 -0500
@@ -39,7 +39,7 @@ GType _g_io_module_get_default_type (
const gchar *envvar,
guint is_supported_offset);
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
void *_g_io_win32_get_module (void);
#endif
--- origsrc/glib-2.36.3/gio/giomodule.c 2013-08-04 20:21:20.886727100 -0500
+++ src/glib-2.36.3/gio/giomodule.c 2013-08-04 18:11:14.000000000 -0500
@@ -894,7 +894,7 @@ extern GType g_network_monitor_base_get_
extern GType _g_network_monitor_netlink_get_type (void);
#endif
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
#include <windows.h>
--- origsrc/glib-2.36.3/gio/tests/live-g-file.c 2013-08-04 20:21:20.898727800 -0500
+++ src/glib-2.36.3/gio/tests/live-g-file.c 2013-08-04 18:11:14.000000000 -0500
@@ -1282,7 +1282,7 @@ main (int argc, char *argv[])
write_test = TRUE;
only_create_struct = FALSE;
target_path = DEFAULT_TEST_DIR;
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
posix_compat = FALSE;
#else
posix_compat = TRUE;
--- origsrc/glib-2.36.3/glib/gatomic.c 2013-08-04 20:21:20.907728300 -0500
+++ src/glib-2.36.3/glib/gatomic.c 2013-08-04 18:11:14.000000000 -0500
@@ -464,7 +464,7 @@ gsize
return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);
}
-#elif defined (G_PLATFORM_WIN32)
+#elif defined (G_OS_WIN32)
#include <windows.h>
#if !defined(_M_AMD64) && !defined (_M_IA64) && !defined(_M_X64) && !(defined _MSC_VER && _MSC_VER <= 1200)
--- origsrc/glib-2.36.3/glib/gcharset.c 2013-08-04 20:21:20.925729300 -0500
+++ src/glib-2.36.3/glib/gcharset.c 2013-08-04 18:11:14.000000000 -0500
@@ -496,7 +496,7 @@ guess_category_value (const gchar *categ
if ((retval != NULL) && (retval[0] != '\0'))
return retval;
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
/* g_win32_getlocale() first checks for LC_ALL, LC_MESSAGES and
* LANG, which we already did above. Oh well. The main point of
* calling g_win32_getlocale() is to get the thread's locale as used
--- origsrc/glib-2.36.3/glib/gconvert.c 2013-08-04 20:21:20.933729800 -0500
+++ src/glib-2.36.3/glib/gconvert.c 2013-08-04 18:11:14.000000000 -0500
@@ -33,9 +33,6 @@
#ifdef G_OS_WIN32
#include "win_iconv.c"
-#endif
-
-#ifdef G_PLATFORM_WIN32
#define STRICT
#include <windows.h>
#undef STRICT
@@ -1258,7 +1255,7 @@ g_locale_from_utf8 (const gchar *utf8str
charset, "UTF-8", bytes_read, bytes_written, error);
}
-#ifndef G_PLATFORM_WIN32
+#ifndef G_OS_WIN32
typedef struct _GFilenameCharsetCache GFilenameCharsetCache;
@@ -1374,7 +1371,7 @@ g_get_filename_charsets (const gchar ***
return cache->is_utf8;
}
-#else /* G_PLATFORM_WIN32 */
+#else /* G_OS_WIN32 */
gboolean
g_get_filename_charsets (const gchar ***filename_charsets)
@@ -1403,7 +1400,7 @@ g_get_filename_charsets (const gchar ***
#endif
}
-#endif /* G_PLATFORM_WIN32 */
+#endif /* G_OS_WIN32 */
static gboolean
get_filename_charset (const gchar **filename_charset)
--- origsrc/glib-2.36.3/glib/gfileutils.c 2013-08-04 20:21:20.942730300 -0500
+++ src/glib-2.36.3/glib/gfileutils.c 2013-08-04 18:11:14.000000000 -0500
@@ -2153,7 +2153,7 @@ g_path_skip_root (const gchar *file_name
{
g_return_val_if_fail (file_name != NULL, NULL);
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
/* Skip \\server\share or //server/share */
if (G_IS_DIR_SEPARATOR (file_name[0]) &&
G_IS_DIR_SEPARATOR (file_name[1]) &&
@@ -2163,7 +2163,6 @@ g_path_skip_root (const gchar *file_name
gchar *p;
p = strchr (file_name + 2, G_DIR_SEPARATOR);
-#ifdef G_OS_WIN32
{
gchar *q;
@@ -2171,7 +2170,6 @@ g_path_skip_root (const gchar *file_name
if (p == NULL || (q != NULL && q < p))
p = q;
}
-#endif
if (p && p > file_name + 2 && p[1])
{
--- origsrc/glib-2.36.3/glib/glib.h 2013-08-04 20:21:20.949730700 -0500
+++ src/glib-2.36.3/glib/glib.h 2013-08-04 18:11:14.000000000 -0500
@@ -96,7 +96,7 @@
#include <glib/gvariant.h>
#include <glib/gversion.h>
#include <glib/gversionmacros.h>
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
#include <glib/gwin32.h>
#endif
--- origsrc/glib-2.36.3/glib/gutf8.c 2013-08-04 20:21:20.984732700 -0500
+++ src/glib-2.36.3/glib/gutf8.c 2013-08-04 18:11:14.000000000 -0500
@@ -27,7 +27,7 @@
#endif
#include <string.h>
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
#include <stdio.h>
#define STRICT
#include <windows.h>
--- origsrc/glib-2.36.3/glib/gutils.c 2013-08-04 20:21:21.015734500 -0500
+++ src/glib-2.36.3/glib/gutils.c 2013-08-04 18:11:14.000000000 -0500
@@ -72,7 +72,7 @@
#include "garray.h"
#include "glibintl.h"
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
#include "gconvert.h"
#include "gwin32.h"
#endif
@@ -86,16 +86,13 @@
* These are portable utility functions.
*/
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
# include <windows.h>
# ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
# define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2
# define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4
# endif
# include <lmcons.h> /* For UNLEN */
-#endif /* G_PLATFORM_WIN32 */
-
-#ifdef G_OS_WIN32
# include <direct.h>
# include <shlobj.h>
/* older SDK (e.g. msvc 5.0) does not have these*/
@@ -131,7 +128,7 @@
#include <langinfo.h>
#endif
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
gchar *
_glib_get_dll_directory (void)
--- origsrc/glib-2.36.3/glib/gutils.h 2013-08-04 20:21:21.067737500 -0500
+++ src/glib-2.36.3/glib/gutils.h 2013-08-04 18:11:14.000000000 -0500
@@ -350,7 +350,7 @@ g_bit_storage (gulong number)
* On non-Windows platforms, expands to nothing.
*/
-#ifndef G_PLATFORM_WIN32
+#ifndef G_OS_WIN32
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
#else
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \
@@ -378,7 +378,7 @@ DllMain (HINSTANCE hinstDLL, \
#endif /* !G_DISABLE_DEPRECATED */
-#endif /* G_PLATFORM_WIN32 */
+#endif /* G_OS_WIN32 */
G_END_DECLS
--- origsrc/glib-2.36.3/glib/gwin32.h 2013-08-04 20:21:21.081738300 -0500
+++ src/glib-2.36.3/glib/gwin32.h 2013-08-04 18:11:14.000000000 -0500
@@ -33,7 +33,7 @@
#include <glib/gtypes.h>
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
G_BEGIN_DECLS
@@ -41,8 +41,6 @@ G_BEGIN_DECLS
#define MAXPATHLEN 1024
#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
@@ -68,7 +66,6 @@ G_BEGIN_DECLS
GLIB_AVAILABLE_IN_ALL
gint g_win32_ftruncate (gint f,
guint size);
-#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"
@@ -112,7 +109,7 @@ gchar* g_win32_locale_filename_
G_END_DECLS
-#endif /* G_PLATFORM_WIN32 */
+#endif /* G_OS_WIN32 */
#ifdef G_OS_WIN32
#ifdef _WIN64
--- origsrc/glib-2.36.3/glib/libcharset/localcharset.c 2013-08-04 20:21:21.095739100 -0500
+++ src/glib-2.36.3/glib/libcharset/localcharset.c 2013-08-04 18:11:14.000000000 -0500
@@ -46,10 +46,6 @@
# include <locale.h>
# endif
# endif
-# ifdef __CYGWIN__
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# endif
#elif defined WIN32_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
@@ -111,7 +107,7 @@ _g_locale_get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
+#if !(defined VMS || defined WIN32_NATIVE)
FILE *fp;
const char *dir;
const char *base = "charset.alias";
@@ -237,7 +233,7 @@ _g_locale_get_charset_aliases (void)
"DECKOREAN" "\0" "EUC-KR" "\0";
# endif
-# if defined WIN32_NATIVE || defined __CYGWIN__
+# if defined WIN32_NATIVE
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
@@ -292,53 +288,6 @@ _g_locale_charset_raw (void)
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
-# ifdef __CYGWIN__
- /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
- returns "US-ASCII". As long as this is not fixed, return the suffix
- of the locale name from the environment variables (if present) or
- the codepage as a number. */
- if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
- {
- const char *locale;
- static char buf[2 + 10 + 1];
-
- locale = getenv ("LC_ALL");
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_CTYPE");
- if (locale == NULL || locale[0] == '\0')
- locale = getenv ("LANG");
- }
- if (locale != NULL && locale[0] != '\0')
- {
- /* If the locale name contains an encoding after the dot, return
- it. */
- const char *dot = strchr (locale, '.');
-
- if (dot != NULL)
- {
- const char *modifier;
-
- dot++;
- /* Look for the possible @... trailer and remove it, if any. */
- modifier = strchr (dot, '@');
- if (modifier == NULL)
- return dot;
- if (modifier - dot < sizeof (buf))
- {
- memcpy (buf, dot, modifier - dot);
- buf [modifier - dot] = '\0';
- return buf;
- }
- }
- }
-
- /* Woe32 has a function returning the locale's codepage as a number. */
- sprintf (buf, "CP%u", GetACP ());
- codeset = buf;
- }
-# endif
-
# else
/* On old systems which lack it, use setlocale or getenv. */
--- origsrc/glib-2.36.3/glib/tests/uri.c 2013-08-04 20:21:21.104739600 -0500
+++ src/glib-2.36.3/glib/tests/uri.c 2013-08-04 18:11:14.000000000 -0500
@@ -56,7 +56,7 @@ to_uri_tests[] = {
{ "c:\\windows", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
#endif
{ "etc", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
-#ifndef G_PLATFORM_WIN32
+#ifndef G_OS_WIN32
{ "/etc/\xE5\xE4\xF6", NULL, "file:///etc/%E5%E4%F6" },
{ "/etc/\xC3\xB6\xC3\xA4\xC3\xA5", NULL, "file:///etc/%C3%B6%C3%A4%C3%A5"},
#endif
--- origsrc/glib-2.36.3/tests/Makefile.am 2013-08-04 20:21:21.109739900 -0500
+++ src/glib-2.36.3/tests/Makefile.am 2013-08-04 18:11:14.000000000 -0500
@@ -20,7 +20,9 @@ libadd_libgmodule = $(libgmodule)
libadd_libglib = $(libglib)
if PLATFORM_WIN32
no_undefined = -no-undefined
+endif
+if OS_WIN32
module_test_exp = module-test.exp
module-test.exp: module-test.o
--- origsrc/glib-2.36.3/tests/testglib.c 2013-08-04 20:21:21.118740400 -0500
+++ src/glib-2.36.3/tests/testglib.c 2013-08-04 18:11:14.000000000 -0500
@@ -776,7 +776,7 @@ test_info (void)
if (g_test_verbose())
{
-#ifdef G_PLATFORM_WIN32
+#ifdef G_OS_WIN32
g_printerr ("current locale: %s\n", g_win32_getlocale ());
g_printerr ("found more.com as %s\n", g_find_program_in_path ("more.com"));
-------------- next part --------------
--- origsrc/glib-2.36.3/configure.ac 2013-08-04 18:11:14.140206800 -0500
+++ src/glib-2.36.3/configure.ac 2013-08-04 18:30:21.852852200 -0500
@@ -3584,7 +3584,7 @@ dnl visibility attributes for symbol exp
dnl
GLIB_HIDDEN_VISIBILITY_CFLAGS=""
case "$host" in
- *-*-mingw*)
+ *-*-cygwin*|*-*-mingw*)
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
[defines how to decorate public symbols while building])
-------------- next part --------------
--- origsrc/glib-2.36.4/glib/gspawn.c 2013-08-07 09:36:32.000000000 -0500
+++ src/glib-2.36.4/glib/gspawn.c 2013-10-21 13:25:34.502441400 -0500
@@ -1040,7 +1040,7 @@ fdwalk (int (*cb)(void *data, int fd), v
struct rlimit rl;
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__CYGWIN__)
DIR *d;
if ((d = opendir("/proc/self/fd"))) {
-------------- next part --------------
Cygwin defines this since 1.7.8, but our wchar_t is only 16-bit while
this code seems to assume 32-bit wchar_t. So, either some incorrect
assumptions need to be fixed in the __STDC_ISO_10646__ code paths, or
the conditionals need to also be guarded && (__SIZEOF_WCHAR_T__ == 4).
Reported by SLao:
http://article.gmane.org/gmane.os.cygwin.ports.general/1330
--- origsrc/glib-2.36.4/glib/gunicollate.c 2013-05-07 13:26:07.000000000 -0500
+++ src/glib-2.36.4/glib/gunicollate.c 2013-11-30 21:36:27.710188300 -0600
@@ -37,9 +37,12 @@
#include "gstrfuncs.h"
#include "gtestutils.h"
#include "gcharset.h"
-#ifndef __STDC_ISO_10646__
+#if !defined(__STDC_ISO_10646__) || defined(G_WITH_CYGWIN)
#include "gconvert.h"
#endif
+#ifdef G_WITH_CYGWIN
+#undef __STDC_ISO_10646__
+#endif
#ifdef _MSC_VER
-------------- next part --------------
--- origsrc/glib-2.38.2/glib/gconvert.c 2014-04-02 01:48:25.505447200 -0500
+++ src/glib-2.38.2/glib/gconvert.c 2014-04-02 02:22:47.959345500 -0500
@@ -1583,7 +1583,9 @@ g_filename_from_uri (const gchar *uri,
return NULL;
}
- if (has_case_prefix (path_part, "///"))
+ if (has_case_prefix (path_part, "////"))
+ path_part += 1;
+ else if (has_case_prefix (path_part, "///"))
path_part += 2;
else if (has_case_prefix (path_part, "//"))
{
-------------- next part --------------
--- origsrc/glib-2.42.1/glib/goption.c 2014-11-09 15:54:26.000000000 -0600
+++ src/glib-2.42.1/glib/goption.c 2015-01-01 19:39:40.385456500 -0600
@@ -1740,7 +1740,7 @@ free_pending_nulls (GOptionContext *cont
static char *
platform_get_argv0 (void)
{
-#if defined __linux
+#if defined __linux || defined __CYGWIN__
char *cmdline;
char *base_arg0;
gsize len;
--- origsrc/glib-2.42.1/glib/tests/option-argv0.c 2014-06-28 12:02:43.000000000 -0500
+++ src/glib-2.42.1/glib/tests/option-argv0.c 2015-01-01 19:39:34.848253300 -0600
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <string.h>
-#if defined __linux || defined __OpenBSD__
+#if defined __linux || defined __OpenBSD__ || defined __CYGWIN__
static void
test_platform_argv0 (void)
{
@@ -56,7 +56,7 @@ main (int argc,
{
g_test_init (&argc, &argv, "no_g_set_prgname", NULL);
-#if defined __linux || defined __OpenBSD__
+#if defined __linux || defined __OpenBSD__ || defined __CYGWIN__
g_test_add_func ("/option/argv0", test_platform_argv0);
#endif
-------------- next part --------------
--- origsrc/glib-2.56.4/gio/gdbusauth.c 2018-12-18 10:03:26.000000000 -0500
+++ src/glib-2.56.4/gio/gdbusauth.c 2020-05-23 08:58:55.003593200 -0400
@@ -1299,9 +1299,9 @@ _g_dbus_auth_run_server (GDBusAuth
&line_length,
cancellable,
error);
- debug_print ("SERVER: WaitingForBegin, read '%s'", line);
if (line == NULL)
goto out;
+ debug_print ("SERVER: WaitingForBegin, read '%s'", line);
if (g_strcmp0 (line, "BEGIN") == 0)
{
/* YAY, done! */
--- origsrc/glib-2.56.4/gio/gdbusmessage.c 2018-12-18 10:03:26.000000000 -0500
+++ src/glib-2.56.4/gio/gdbusmessage.c 2020-05-23 09:18:23.976547300 -0400
@@ -2727,7 +2727,6 @@ g_dbus_message_to_blob (GDBusMessage
if (message->body != NULL)
{
gchar *tupled_signature_str;
- tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
if (signature == NULL)
{
g_set_error (error,
@@ -2735,10 +2734,10 @@ g_dbus_message_to_blob (GDBusMessage
G_IO_ERROR_INVALID_ARGUMENT,
_("Message body has signature “%s” but there is no signature header"),
signature_str);
- g_free (tupled_signature_str);
goto out;
}
- else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
+ tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
+ if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
{
g_set_error (error,
G_IO_ERROR,
-------------- next part --------------
--- origsrc/glib-2.56.4/gmodule/gmodule-win32.c 2018-08-15 12:22:08.000000000 -0400
+++ src/glib-2.56.4/gmodule/gmodule-win32.c 2020-05-23 08:29:18.332616700 -0400
@@ -37,7 +37,20 @@
#ifdef G_WITH_CYGWIN
#include <sys/cygwin.h>
-#endif
+#include <dlfcn.h>
+
+static gchar*
+fetch_dlerror (gboolean replace_null)
+{
+ gchar *msg = dlerror ();
+
+ if (!msg && replace_null)
+ return "unknown dl-error";
+
+ return msg;
+}
+
+#else
static void
set_error (const gchar *format,
@@ -62,22 +75,26 @@ set_error (const gchar *format,
g_free (error);
}
+#endif /* G_WITH_CYGWIN */
+
/* --- functions --- */
static gpointer
_g_module_open (const gchar *file_name,
gboolean bind_lazy,
gboolean bind_local)
{
- HINSTANCE handle;
- wchar_t *wfilename;
DWORD old_mode;
BOOL success;
#ifdef G_WITH_CYGWIN
- gchar tmp[MAX_PATH];
+ gpointer handle;
- cygwin_conv_to_win32_path(file_name, tmp);
- file_name = tmp;
-#endif
+ handle = dlopen (file_name,
+ (bind_local ? RTLD_LOCAL : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
+ if (!handle)
+ g_module_set_error (fetch_dlerror (TRUE));
+#else
+ HINSTANCE handle;
+ wchar_t *wfilename;
wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
/* suppress error dialog */
@@ -91,26 +108,44 @@ _g_module_open (const gchar *file_name,
if (!handle)
set_error ("'%s': ", file_name);
+#endif
return handle;
}
+#ifndef G_WITH_CYGWIN
static gint dummy;
static gpointer null_module_handle = &dummy;
+#endif
static gpointer
_g_module_self (void)
{
+#ifdef G_WITH_CYGWIN
+ gpointer handle;
+
+ handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
+ if (!handle)
+ g_module_set_error (fetch_dlerror (TRUE));
+
+ return handle;
+#else
return null_module_handle;
+#endif
}
static void
_g_module_close (gpointer handle,
gboolean is_unref)
{
+#ifdef G_WITH_CYGWIN
+ if (dlclose (handle) != 0)
+ g_module_set_error (fetch_dlerror (TRUE));
+#else
if (handle != null_module_handle)
if (!FreeLibrary (handle))
set_error ("");
+#endif
}
static gpointer
@@ -129,8 +164,19 @@ find_in_any_module_using_toolhelp (const
if (Module32First (snapshot, &me32))
{
do {
- if ((p = GetProcAddress (me32.hModule, symbol_name)) != NULL)
- break;
+ if ((p = GetProcAddress (me32.hModule, symbol_name)) != NULL) {
+#ifdef G_WITH_CYGWIN
+ /* if symbol is found in another module, we probably do not want it */
+ ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX, me32.szExePath, NULL, 0);
+ char *posix = (char *) alloca (size);
+ cygwin_conv_path (CCP_WIN_A_TO_POSIX, me32.szExePath, posix, size);
+ if (g_strstr_len (posix, size, "/usr/lib")
+ || g_strstr_len (posix, size, "/usr/local/lib"))
+ p = NULL;
+ else
+#endif
+ break;
+ }
} while (Module32Next (snapshot, &me32));
}
@@ -156,6 +202,13 @@ _g_module_symbol (gpointer handle,
{
gpointer p;
+#ifdef G_WITH_CYGWIN
+ p = dlsym (handle, symbol_name);
+ if (!p)
+ p = find_in_any_module (symbol_name);
+ if (!p)
+ g_module_set_error (fetch_dlerror (FALSE));
+#else
if (handle == null_module_handle)
{
if ((p = GetProcAddress (GetModuleHandle (NULL), symbol_name)) == NULL)
@@ -166,6 +219,7 @@ _g_module_symbol (gpointer handle,
if (!p)
set_error ("");
+#endif
return p;
}
-------------- next part --------------
ORIG_PN="glib"
inherit gnome2 python
NAME="glib2.0"
VERSION=2.56.4
RELEASE=1
CATEGORY="Libs"
SUMMARY="GNOME core C function library"
DESCRIPTION="GLib is the low-level core library that forms the basis for
projects such as GTK+ and GNOME. It provides data structure handling for C,
portability wrappers, and interfaces for such runtime functionality as
an event loop, threads, dynamic loading, and an object system."
HOMEPAGE="http://www.gtk.org/"
PATCH_URI="
2.56-gmodule-cygwin.patch
2.36.3-not-win32.patch
2.36.4-gspawn-cygwin.patch
2.42.1-goption-cygwin.patch
2.34.3-m4macros.patch
2.36.3-visibility.patch
2.36.4-gutf8-cygwin.patch
2.38.2-gconvert-cygwin.patch
2.56.4-dont-print-null-strings.patch
"
# 2.36.4-gsocket-cygwin.patch # requires abstract sockets
BUILD_REQUIRES="gnome-common \
gettext \
gettext-devel \
libfam-devel \
libiconv \
libpcre-devel \
zlib-devel"
DISTCLEANFILES="gmodule/gmodule-cygwin.c gio/gdbus-2.0/codegen/config.py"
# libelf: for gresource(1), only useful on ELF platforms
CYGCONF_ARGS="
--disable-visibility
--disable-libelf
--with-libiconv=gnu
--with-pcre=system
--with-threads=posix
ac_cv_header_winsock2_h=no
ac_cv_header_mswsock_h=no
"
PKG_NAMES="lib${NAME}_0 lib${NAME}-devel lib${NAME}-doc"
libglib2_0_0_SUMMARY="${SUMMARY} (runtime)"
libglib2_0_0_REQUIRES="desktop-file-utils gsettings-desktop-schemas shared-mime-info tzdata"
libglib2_0_0_CONTENTS="
etc/
usr/bin/cyg*-2.0-0.dll
usr/bin/gapplication.exe
usr/bin/gdbus.exe
usr/bin/gio.exe
usr/bin/gio-querymodules.exe
usr/bin/glib-compile-schemas.exe
usr/bin/gobject-query.exe
usr/bin/gsettings.exe
usr/lib/gio/
usr/share/doc/
usr/share/glib-2.0/schemas/
usr/share/locale/
usr/share/man/man1/gapplication.*
usr/share/man/man1/gdbus.*
usr/share/man/man1/gio*
usr/share/man/man1/glib-compile-schemas*
usr/share/man/man1/gobject*
usr/share/man/man1/gsettings.*
"
libglib2_0_devel_SUMMARY="${SUMMARY} (development)"
libglib2_0_devel_CONTENTS="
--exclude=glib-compile-schemas.[^html]*
usr/bin/gdbus-codegen
usr/bin/glib-*
usr/bin/gresource*
usr/bin/gtester*
usr/include/gio-unix-2.0/
usr/include/glib-2.0/
usr/lib/glib-2.0/include/
usr/lib/lib*-2.0.dll.a
usr/lib/pkgconfig/*
usr/share/aclocal/
usr/share/gettext/
usr/share/glib-2.0/codegen/
usr/share/glib-2.0/gettext/
usr/share/man/man1/gdbus-codegen*
usr/share/man/man1/glib-*
usr/share/man/man1/gresource*
usr/share/man/man1/gtester*
"
libglib2_0_doc_CATEGORY="Doc"
libglib2_0_doc_CONTENTS="usr/share/gtk-doc/"
glib2_0_debuginfo_CONTENTS+=" usr/share/glib-2.0/gdb/"
PKG_IGNORE="
usr/share/glib-2.0/valgrind/
"
src_install() {
local giomodule_cache=/usr/lib/gio/modules/giomodule.cache
local gschemas_compiled=/usr/share/glib-2.0/schemas/gschemas.compiled
cd ${B}
cyginstall completiondir=/etc/bash_completion.d
rm -f ${D}/usr/lib/charset.alias
pushd ${D}/usr/share/gdb/auto-load
mkdir -p usr/bin
mv libglib* usr/bin/cygglib-2.0-0.dll-gdb.py
mv libgobject* usr/bin/cyggobject-2.0-0.dll-gdb.py
popd
python_optimize /usr/share/glib-2.0/gdb
dodir /etc/postinstall /etc/preremove
cat > ${D}/etc/postinstall/zp_${NAME}.sh <<EOF
if [ ! -f $giomodule_cache ]
then
/usr/bin/gio-querymodules ${giomodule_cache%/*}
fi
find ${giomodule_cache%/*} -name '*.dll' -cnewer $giomodule_cache -exec /usr/bin/gio-querymodules ${giomodule_cache%/*} \;
if [ ! -f $gschemas_compiled ]
then
/usr/bin/glib-compile-schemas ${gschemas_compiled%/*}
fi
find ${gschemas_compiled%/*} -name '*.xml' -cnewer $gschemas_compiled -exec /usr/bin/glib-compile-schemas ${gschemas_compiled%/*} \;
EOF
cat > ${D}/etc/preremove/${NAME}.sh <<EOF
rm -f $giomodule_cache $gschemas_compiled
EOF
chmod +x ${D}/etc/{postinstall,preremove}/*.sh
}
More information about the Cygwin-apps
mailing list