From 169ca1ba77bec76ac55333197ec47f875bd91ea9 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Mon, 13 Jan 2020 15:16:04 +0100 Subject: [PATCH] compat: Add compatibility defines for older GLib We are already using a number of defines and autoptrs from newer GLib releases. Add the appropriate compatibility defines rather than removing the corresponding code. Closes: #222 --- libfprint/drivers_api.h | 1 + libfprint/fp-print.c | 1 + libfprint/fpi-compat.h | 33 +++++++++++++++++++++++++++++++++ libfprint/fpi-context.h | 1 + tests/test-fpi-device.c | 1 + 5 files changed, 37 insertions(+) create mode 100644 libfprint/fpi-compat.h diff --git a/libfprint/drivers_api.h b/libfprint/drivers_api.h index 7476ba7..aef8c9d 100644 --- a/libfprint/drivers_api.h +++ b/libfprint/drivers_api.h @@ -21,6 +21,7 @@ #pragma once +#include "fpi-compat.h" #include "fpi-assembling.h" #include "fpi-device.h" #include "fpi-image-device.h" diff --git a/libfprint/fp-print.c b/libfprint/fp-print.c index 34139ce..b17b203 100644 --- a/libfprint/fp-print.c +++ b/libfprint/fp-print.c @@ -21,6 +21,7 @@ #define FP_COMPONENT "print" #include "fp-print-private.h" +#include "fpi-compat.h" #include "fpi-log.h" /** diff --git a/libfprint/fpi-compat.h b/libfprint/fpi-compat.h new file mode 100644 index 0000000..fcf1600 --- /dev/null +++ b/libfprint/fpi-compat.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 Benjamin Berg + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include + +#if !GLIB_CHECK_VERSION (2, 57, 0) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref); +G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref); +#else +/* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with + * the version we depend on currently. */ +#undef G_SOURCE_FUNC +#endif + +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f)) diff --git a/libfprint/fpi-context.h b/libfprint/fpi-context.h index 48fecb4..ec98675 100644 --- a/libfprint/fpi-context.h +++ b/libfprint/fpi-context.h @@ -20,6 +20,7 @@ #include #include "fp-context.h" +#include "fpi-compat.h" /** * fpi_get_driver_types: diff --git a/tests/test-fpi-device.c b/tests/test-fpi-device.c index 826c6cd..9f1da2e 100644 --- a/tests/test-fpi-device.c +++ b/tests/test-fpi-device.c @@ -22,6 +22,7 @@ #define FP_COMPONENT "device" #include "fpi-device.h" +#include "fpi-compat.h" #include "fpi-log.h" #include "test-device-fake.h"