2019-10-17 15:17:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* 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, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glib.h>
|
2019-12-24 15:25:40 +00:00
|
|
|
#include <glib/gstdio.h>
|
2020-11-12 12:58:53 +00:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2020-12-03 11:33:29 +00:00
|
|
|
#if GLIB_CHECK_VERSION(2, 67, 0)
|
|
|
|
|
|
|
|
# if defined(__clang__)
|
|
|
|
|
2020-11-12 12:58:53 +00:00
|
|
|
/*
|
|
|
|
* Clang detects (valid) issue in G_DEFINE_TYPE and derivatives starting with
|
|
|
|
* glib >= 2.67.0. See https://gitlab.gnome.org/GNOME/glib/-/issues/600
|
|
|
|
*
|
|
|
|
* For that we need to disable the one check that produces an error in our
|
|
|
|
* builds when using any G_DEFINE_TYPE* macro. Thankfully all those macros end
|
|
|
|
* up using _G_DEFINE_TYPE_EXTENDED_BEGIN. Because with that we can redefine
|
|
|
|
* this one macro to cover all use cases. The macro is defined the same way it
|
|
|
|
* is defined in glib (with a very low probability of being changed thanks to a
|
|
|
|
* comment above it).
|
|
|
|
*/
|
2020-12-03 11:33:29 +00:00
|
|
|
# undef _G_DEFINE_TYPE_EXTENDED_BEGIN
|
2020-11-12 12:58:53 +00:00
|
|
|
|
2020-12-03 11:33:29 +00:00
|
|
|
# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
|
2020-11-12 12:58:53 +00:00
|
|
|
_Pragma("GCC diagnostic push") \
|
|
|
|
_Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types-discards-qualifiers\"") \
|
|
|
|
_G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
|
|
|
|
_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
|
|
|
|
_Pragma("GCC diagnostic pop")
|
|
|
|
|
2020-12-03 11:33:29 +00:00
|
|
|
# endif /* __clang__ */
|
|
|
|
|
|
|
|
#else /* GLib < 2.67.0 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ...meanwhile GCC >= 11 has started issuing warnings about volatile
|
|
|
|
* from the old G_DEFINE_TYPE macro impl. IOW the new macros impls fixed
|
|
|
|
* new GCC, but broke CLang
|
|
|
|
*/
|
|
|
|
# if !defined(__clang__) && __GNUC_PREREQ (11, 0)
|
|
|
|
# undef _G_DEFINE_TYPE_EXTENDED_BEGIN
|
|
|
|
|
|
|
|
# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
|
|
|
|
_Pragma("GCC diagnostic push") \
|
|
|
|
_Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types\"") \
|
|
|
|
_G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
|
|
|
|
_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
|
|
|
|
_Pragma("GCC diagnostic pop")
|
|
|
|
# endif /* !clang && GCC >= 11.0 */
|
|
|
|
|
|
|
|
#endif /* GLib < 2.67.0 */
|
2019-10-17 15:17:01 +00:00
|
|
|
|
2020-01-06 11:54:20 +00:00
|
|
|
gchar * vir_g_canonicalize_filename(const gchar *filename,
|
|
|
|
const gchar *relative_to);
|
2020-01-06 15:56:10 +00:00
|
|
|
gint vir_g_fsync(gint fd);
|
2019-10-17 15:17:01 +00:00
|
|
|
char *vir_g_strdup_printf(const char *msg, ...)
|
|
|
|
G_GNUC_PRINTF(1, 2);
|
|
|
|
char *vir_g_strdup_vprintf(const char *msg, va_list args)
|
|
|
|
G_GNUC_PRINTF(1, 0);
|
|
|
|
|
|
|
|
#if !GLIB_CHECK_VERSION(2, 64, 0)
|
|
|
|
# define g_strdup_printf vir_g_strdup_printf
|
|
|
|
# define g_strdup_vprintf vir_g_strdup_vprintf
|
|
|
|
#endif
|
2019-12-23 10:10:20 +00:00
|
|
|
|
2020-01-06 11:54:20 +00:00
|
|
|
#define g_canonicalize_filename vir_g_canonicalize_filename
|
2020-01-06 11:42:17 +00:00
|
|
|
#undef g_fsync
|
|
|
|
#define g_fsync vir_g_fsync
|
2021-03-04 08:34:19 +00:00
|
|
|
|
2021-03-16 16:26:06 +00:00
|
|
|
void vir_g_source_unref(GSource *src, GMainContext *ctx);
|