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" "$@"
[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,
# 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
$(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 \
$(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; \
{
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;
{
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;
{
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;
{
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;
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;
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;
{
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;
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);
/* 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:
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
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}
#include <glib/gtestutils.h>
#include <glib/gmem.h>
#include <glib/gmessages.h>
+ #include <glib/grefcount.h>
#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef G_OS_UNIX
+#include "glib-unix.h"
+#include <sys/mman.h>
+#endif
/**
* GBytes:
/* 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;
};
- bytes->ref_count = 1;
+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;
++ 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):
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;
+ }
+ }
}
}
*
* 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.
*/
/**
* 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,