From: Adrian Szyndela Date: Fri, 17 Jan 2020 14:27:39 +0000 (+0100) Subject: Merge 2.57.2 into tizen X-Git-Tag: submit/tizen/20200131.142009^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=580ccfe5291ec8448675fdaaf5f77c6c3420ae3a;p=platform%2Fupstream%2Fglib.git Merge 2.57.2 into tizen Change-Id: Id268f3b3a99b482c3023be25bc98cda4e1d41702 --- 580ccfe5291ec8448675fdaaf5f77c6c3420ae3a diff --cc autogen.sh index 77e1f4b,9e4ba4c..084559f --- a/autogen.sh +++ b/autogen.sh @@@ -25,12 -25,12 +25,12 @@@ if test -z $AUTORECONF; the exit 1 fi - # README and INSTALL are required by automake, but may be deleted by clean - # up rules. to get automake to work, simply touch these here, they will be - # regenerated from their corresponding *.in files by ./configure anyway. - touch README INSTALL + # INSTALL is required by automake, but may be deleted by clean + # up rules. to get automake to work, simply touch it here. It will be + # regenerated from its corresponding *.in file by ./configure anyway. + touch INSTALL -autoreconf --force --install --verbose || exit $? +test -n "$NOAUTORECONF" || autoreconf --force --install --verbose || exit $? cd "$olddir" test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --cc configure.ac index a5c0eb8,11fde90..c89032c --- a/configure.ac +++ b/configure.ac @@@ -248,45 -248,8 +248,23 @@@ AC_ARG_ENABLE(debug [turn on debugging @<:@default=glib_debug_default@:>@]),, enable_debug=glib_debug_default) - AC_ARG_ENABLE(gc_friendly, - [AS_HELP_STRING([--enable-gc-friendly], - [turn on garbage collector friendliness [default=no]])],, - [enable_gc_friendly=no]) - AC_ARG_ENABLE(mem_pools, - [AS_HELP_STRING([--disable-mem-pools], - [disable all glib memory pools])],, - [disable_mem_pools=no]) +AC_ARG_ENABLE(libdbuspolicy, + [AS_HELP_STRING([--enable-libdbuspolicy], + [enable libdbuspolicy for kdbus transport [default=no]])],, + [enable_libdbuspolicy=no]) + GLIB_TESTS - AC_MSG_CHECKING([whether to enable garbage collector friendliness]) - AS_IF([test "x$enable_gc_friendly" = "xyes"], [ - AC_DEFINE(ENABLE_GC_FRIENDLY_DEFAULT, 1, [Whether to enable GC friendliness by default]) - AC_MSG_RESULT([yes]) - ], [ AC_MSG_RESULT([no]) ]) - - AC_MSG_CHECKING([whether to disable memory pools]) - AS_IF([test "x$disable_mem_pools" = "xno"], [ - AC_MSG_RESULT([no]) - ], [ - AC_DEFINE(DISABLE_MEM_POOLS, [1], [Whether to disable memory pools]) - AC_MSG_RESULT([yes]) - ]) - +AC_MSG_CHECKING([whether to enable libdbuspolicy for kdbus transport]) +AM_CONDITIONAL(LIBDBUSPOLICY, [test "x$enable_libdbuspolicy" = "xyes"]) +AS_IF([test "x$enable_libdbuspolicy" = "xyes"], [ + PKG_CHECK_MODULES(LIBDBUSPOLICY1, libdbuspolicy1 >= 1) + AC_SUBST(LIBDBUSPOLICY1_CFLAGS) + AC_SUBST(LIBDBUSPOLICY1_LIBS) + AC_DEFINE(LIBDBUSPOLICY, 1, [Whether to enable libdbuspolicy for kdbus transport]) + AC_MSG_RESULT([yes]) +], [ AC_MSG_RESULT([no]) ]) + dnl location to install runtime libraries, e.g. ../../lib to install dnl to /lib if libdir is /usr/lib AC_ARG_WITH(runtime-libdir, @@@ -699,9 -644,9 +659,9 @@@ f # check for header files AC_CHECK_HEADERS([sys/param.h sys/resource.h mach/mach_time.h]) AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h]) - AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h]) + AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h sys/auxv.h]) AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h]) -AC_CHECK_HEADERS([linux/magic.h]) +AC_CHECK_HEADERS([linux/magic.h linux/memfd.h sys/prctl.h]) AC_CHECK_HEADERS([termios.h]) # Some versions of MSC lack these diff --cc gio/Makefile.am index 7c29156,e14cad2..682e3cc --- a/gio/Makefile.am +++ b/gio/Makefile.am @@@ -837,15 -855,14 +869,16 @@@ gio_querymodules_LDADD = libgio-2.0.l $(top_builddir)/gmodule/libgmodule-2.0.la \ $(top_builddir)/glib/libglib-2.0.la \ $(NULL) +gio_querymodules_LDFLAGS = -pie + gio_launch_desktop_SOURCES = gio-launch-desktop.c + gconstructor_as_data.h: $(top_srcdir)/glib/gconstructor.h data-to-c.py - $(AM_V_GEN) $(srcdir)/data-to-c.py $(top_srcdir)/glib/gconstructor.h gconstructor_code $@ + $(AM_V_GEN) $(PYTHON) $(srcdir)/data-to-c.py $(top_srcdir)/glib/gconstructor.h gconstructor_code $@ glib_compile_schemas_LDADD = $(top_builddir)/glib/libglib-2.0.la +glib_compile_schemas_LDFLAGS = -pie glib_compile_schemas_SOURCES = \ - gconstructor_as_data.h \ gvdb/gvdb-format.h \ gvdb/gvdb-builder.h \ gvdb/gvdb-builder.c \ @@@ -975,45 -992,8 +1012,9 @@@ gio_LDADD = libgio-2.0.la $(top_builddir)/gobject/libgobject-2.0.la \ $(top_builddir)/glib/libglib-2.0.la \ $(NULL) +gio_LDFLAGS = -pie - # ------------------------------------------------------------------------ - # ------ MSVC Project File Generation ------ - # ------------------------------------------------------------------------ - # - MSVCPROJS = gio glib-compile-resources glib-compile-schemas gio-tool - - gio_FILES = \ - $(gio_base_sources) \ - $(win32_actual_sources) \ - $(win32_more_sources_for_vcproj) \ - $(settings_base_sources) \ - $(win32_settings_sources) - - gio_EXCLUDES = dummy - - gio_HEADERS_DIR = $(includedir)/glib-2.0/gio - gio_HEADERS_INST = $(gioinclude_HEADERS) $(nodist_gioinclude_HEADERS) - gio_HEADERS_EXCLUDES = dummy - - glib_compile_resources_FILES = $(glib_compile_resources_SOURCES) - glib_compile_resources_EXCLUDES = dummy - - glib_compile_schemas_FILES = $(glib_compile_schemas_SOURCES) - glib_compile_schemas_EXCLUDES = dummy - - gio_tool_FILES = $(gio_SOURCES) - gio_tool_EXCLUDES = dummy - - include $(top_srcdir)/win32/Makefile.msvcproj - - dist-hook: \ - $(BUILT_EXTRA_DIST) \ - $(top_builddir)/win32/vs9/gio.vcproj \ - $(top_builddir)/win32/vs9/gio.headers \ - $(top_builddir)/win32/vs9/glib-compile-schemas.vcproj \ - $(top_builddir)/win32/vs9/glib-compile-resources.vcproj \ - $(top_builddir)/win32/vs9/gio-tool.vcproj + dist-hook: $(BUILT_EXTRA_DIST) files='$(BUILT_EXTRA_DIST)'; \ for f in $$files; do \ if test -f $$f; then d=.; else d=$(srcdir); fi; \ diff --cc gio/gdbusconnection.c index 1ba93fc,543ca0b..6466fbd mode 100755,100644..100755 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@@ -5165,9 -4254,9 +5156,9 @@@ validate_and_maybe_schedule_property_ge { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such property '%s'"), + _("No such property “%s”"), property_name); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5177,9 -4266,9 +5168,9 @@@ { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Property '%s' is not readable"), + _("Property “%s” is not readable"), property_name); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5188,9 -4277,9 +5179,9 @@@ { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Property '%s' is not writable"), + _("Property “%s” is not writable"), property_name); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5208,10 -4297,10 +5199,10 @@@ { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Error setting property '%s': Expected type '%s' but got '%s'"), + _("Error setting property “%s”: Expected type “%s” but got “%s”"), property_name, property_info->signature, g_variant_get_type_string (value)); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_variant_unref (value); g_object_unref (reply); handled = TRUE; @@@ -5313,9 -4402,9 +5304,9 @@@ handle_getset_property (GDBusConnectio GDBusMessage *reply; reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such interface '%s'"), + _("No such interface “%s”"), interface_name); - g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5521,9 -4610,9 +5512,9 @@@ handle_get_all_properties (GDBusConnect GDBusMessage *reply; reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("No such interface '%s'"), + _("No such interface “%s”"), interface_name); - g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (eo->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5837,9 -4926,9 +5828,9 @@@ validate_and_maybe_schedule_method_cal { reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.UnknownMethod", - _("No such method '%s'"), + _("No such method “%s”"), g_dbus_message_get_member (message)); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); handled = TRUE; goto out; @@@ -5868,10 -4957,10 +5859,10 @@@ reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.InvalidArgs", - _("Type of message, '%s', does not match expected type '%s'"), + _("Type of message, “%s”, does not match expected type “%s”"), g_variant_get_type_string (parameters), type_string); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_variant_type_free (in_type); g_variant_unref (parameters); g_object_unref (reply); @@@ -8009,10 -7088,10 +8000,10 @@@ distribute_method_call (GDBusConnectio /* if we end up here, the message has not been not handled - so return an error saying this */ reply = g_dbus_message_new_method_error (message, "org.freedesktop.DBus.Error.UnknownMethod", - _("No such interface '%s' on object at path %s"), + _("No such interface “%s” on object at path %s"), interface_name, object_path); - g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); + g_dbus_connection_send_message_unlocked (connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL, -1); g_object_unref (reply); out: diff --cc glib/Makefile.am index eab0b81,8f6536c..2e0d149 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@@ -410,14 -430,17 +433,17 @@@ CLEANFILES += $(nodist_win_helper_sourc if OS_WIN32 if OS_WIN32_X64 - INSTALL_PROGS += gspawn-win64-helper gspawn-win64-helper-console + bin_PROGRAMS += gspawn-win64-helper gspawn-win64-helper-console + nodist_gspawn_win64_helper_SOURCES = gspawn-win64-helper.c + nodist_gspawn_win64_helper_console_SOURCES = gspawn-win64-helper-console.c gspawn_win64_helper_LDADD = libglib-2.0.la -gspawn_win64_helper_LDFLAGS = -mwindows +gspawn_win64_helper_LDFLAGS = -pie -mwindows gspawn_win64_helper_console_LDADD = libglib-2.0.la else - INSTALL_PROGS += gspawn-win32-helper gspawn-win32-helper-console + bin_PROGRAMS += gspawn-win32-helper gspawn-win32-helper-console + nodist_gspawn_win32_helper_console_SOURCES = gspawn-win32-helper-console.c gspawn_win32_helper_LDADD = libglib-2.0.la -gspawn_win32_helper_LDFLAGS = -mwindows +gspawn_win32_helper_LDFLAGS = -pie -mwindows gspawn_win32_helper_console_LDADD = libglib-2.0.la endif endif @@@ -425,14 -448,11 +451,12 @@@ glib-win32-res.o: glib.rc $(WINDRES) glib.rc $@ - bin_PROGRAMS = ${INSTALL_PROGS} - if OS_UNIX - INSTALL_PROGS += gtester + bin_PROGRAMS += gtester gtester_SOURCES = gtester.c -gtester_LDADD = libglib-2.0.la +gtester_LDADD = libglib-2.0.la +gtester_LDFLAGS = -pie auto_config_binscripts = gtester-report bin_SCRIPTS = ${auto_config_binscripts} diff --cc glib/gbytes.c index 56133b6,74f8148..ee24844 --- a/glib/gbytes.c +++ b/glib/gbytes.c @@@ -30,16 -30,9 +30,17 @@@ #include #include #include + #include #include +#include +#include +#include + +#ifdef G_OS_UNIX +#include "glib-unix.h" +#include +#endif /** * GBytes: @@@ -75,75 -68,13 +76,75 @@@ /* Keep in sync with glib/tests/bytes.c */ struct _GBytes { - gconstpointer data; /* may be NULL iff (size == 0) */ - gsize size; /* may be 0 */ + gsize size; - gint ref_count; + gatomicrefcount ref_count; - GDestroyNotify free_func; - gpointer user_data; + gint type_or_fd; }; +typedef struct +{ + GBytes bytes; +#if GLIB_SIZEOF_SIZE_T == 4 + guint pad; +#endif + + guchar data[1]; +} GBytesInline; + +/* important: the ->data field of GBytesInline should always be 'nicely + * aligned'. + */ +G_STATIC_ASSERT (G_STRUCT_OFFSET (GBytesInline, data) % (2 * sizeof (gpointer)) == 0); +G_STATIC_ASSERT (G_STRUCT_OFFSET (GBytesInline, data) % 8 == 0); + + +typedef struct +{ + GBytes bytes; + + gpointer data; +} GBytesData; + +typedef struct +{ + GBytesData data_bytes; + + GDestroyNotify notify; + gpointer user_data; +} GBytesNotify; + +#define G_BYTES_TYPE_INLINE (-1) +#define G_BYTES_TYPE_STATIC (-2) +#define G_BYTES_TYPE_FREE (-3) +#define G_BYTES_TYPE_NOTIFY (-4) + +/* All bytes are either inline or subtypes of GBytesData */ +#define G_BYTES_IS_INLINE(bytes) ((bytes)->type_or_fd == G_BYTES_TYPE_INLINE) +#define G_BYTES_IS_DATA(bytes) (!G_BYTES_IS_INLINE(bytes)) + +/* More specific subtypes of GBytesData */ +#define G_BYTES_IS_STATIC(bytes) ((bytes)->type_or_fd == G_BYTES_TYPE_STATIC) +#define G_BYTES_IS_FREE(bytes) ((bytes)->type_or_fd == G_BYTES_TYPE_FREE) +#define G_BYTES_IS_NOTIFY(bytes) ((bytes)->type_or_fd == G_BYTES_TYPE_NOTIFY) + +/* we have a memfd if type_or_fd >= 0 */ +#define G_BYTES_IS_MEMFD(bytes) ((bytes)->type_or_fd >= 0) + +static gpointer +g_bytes_allocate (guint struct_size, + guint type_or_fd, + gsize data_size) +{ + GBytes *bytes; + + bytes = g_slice_alloc (struct_size); + bytes->size = data_size; - bytes->ref_count = 1; ++ g_atomic_ref_count_init (&bytes->ref_count); + bytes->type_or_fd = type_or_fd; + + return bytes; +} + /** * g_bytes_new: * @data: (transfer none) (array length=size) (element-type guint8) (nullable): @@@ -520,54 -331,11 +521,54 @@@ g_bytes_unref (GBytes *bytes if (bytes == NULL) return; - if (g_atomic_int_dec_and_test (&bytes->ref_count)) + if (g_atomic_ref_count_dec (&bytes->ref_count)) { - if (bytes->free_func != NULL) - bytes->free_func (bytes->user_data); - g_slice_free (GBytes, bytes); + switch (bytes->type_or_fd) + { + case G_BYTES_TYPE_STATIC: + /* data does not need to be freed */ + g_slice_free (GBytesData, (GBytesData *) bytes); + break; + + case G_BYTES_TYPE_INLINE: + /* data will be freed along with struct */ + g_slice_free1 (G_STRUCT_OFFSET (GBytesInline, data[bytes->size]), bytes); + break; + + case G_BYTES_TYPE_FREE: + { + GBytesData *data_bytes = (GBytesData *) bytes; + + g_free (data_bytes->data); + + g_slice_free (GBytesData, data_bytes); + break; + } + + case G_BYTES_TYPE_NOTIFY: + { + GBytesNotify *notify_bytes = (GBytesNotify *) bytes; + + /* We don't create GBytesNotify if callback was NULL */ + (* notify_bytes->notify) (notify_bytes->user_data); + + g_slice_free (GBytesNotify, notify_bytes); + break; + } + + default: + { + GBytesData *data_bytes = (GBytesData *) bytes; + + g_assert (bytes->type_or_fd >= 0); + + g_assert_se (munmap (data_bytes->data, bytes->size) == 0); + g_assert_se (close (bytes->type_or_fd) == 0); + + g_slice_free (GBytesData, data_bytes); + break; + } + } } } diff --cc glib/gtestutils.c index 761ad93,da6c733..9006c0c --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@@ -472,26 -477,10 +477,29 @@@ * * The macro can be turned off in final releases of code by defining * `G_DISABLE_ASSERT` when compiling the application, so code must - * not depend on any side effects from @expr. + * not depend on any side effects from @expr. Similarly, it must not be used + * in unit tests, otherwise the unit tests will be ineffective if compiled with + * `G_DISABLE_ASSERT`. Use g_assert_true() and related macros in unit tests + * instead. + * + * For a version which is guaranteed to evaluate side effects in @expr, + * see g_assert_se(). + */ + +/** + * g_assert_se: + * @expr: the expression to check + * + * Debugging macro to terminate the application if the assertion + * fails. If the assertion fails (i.e. the expression is not true), + * an error message is logged and the application is terminated. + * + * The check can be turned off in final releases of code by defining + * `G_DISABLE_ASSERT` when compiling the application. + * + * Unlike g_assert(), this macro is guaranteed to evaluate side effects + * of @expr, even if checks are disabled. It is still undefined if the + * program will actually be aborted or not. */ /** diff --cc glib/gvariant.c index d4bd8f2,2c9f951..5c2e801 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@@ -1122,9 -1105,8 +1122,9 @@@ g_variant_lookup_value (GVarian * the appropriate type: * - %G_VARIANT_TYPE_INT16 (etc.): #gint16 (etc.) * - %G_VARIANT_TYPE_BOOLEAN: #guchar (not #gboolean!) - * - %G_VARIANT_TYPE_BYTE: #guchar + * - %G_VARIANT_TYPE_BYTE: #guint8 * - %G_VARIANT_TYPE_HANDLE: #guint32 + * - %G_VARIANT_TYPE_FLOAT: #gfloat * - %G_VARIANT_TYPE_DOUBLE: #gdouble * * For example, if calling this function for an array of 32-bit integers,