Blame glib/gmacros.h

Packit ae235b
/* GLIB - Library of useful routines for C programming
Packit ae235b
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public
Packit ae235b
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 */
Packit ae235b
Packit ae235b
/*
Packit ae235b
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
Packit ae235b
 * file for a list of people on the GLib Team.  See the ChangeLog
Packit ae235b
 * files for a list of changes.  These files are distributed with
Packit ae235b
 * GLib at ftp://ftp.gtk.org/pub/gtk/.
Packit ae235b
 */
Packit ae235b
Packit ae235b
/* This file must not include any other glib header file and must thus
Packit ae235b
 * not refer to variables from glibconfig.h
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifndef __G_MACROS_H__
Packit ae235b
#define __G_MACROS_H__
Packit ae235b
Packit ae235b
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
Packit ae235b
#error "Only <glib.h> can be included directly."
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* We include stddef.h to get the system's definition of NULL
Packit ae235b
 */
Packit ae235b
#include <stddef.h>
Packit ae235b
Packit ae235b
#ifdef __GNUC__
Packit ae235b
#define G_GNUC_CHECK_VERSION(major, minor) \
Packit ae235b
    ((__GNUC__ > (major)) || \
Packit ae235b
     ((__GNUC__ == (major)) && \
Packit ae235b
      (__GNUC_MINOR__ >= (minor))))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_CHECK_VERSION(major, minor) 0
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
Packit ae235b
 * where this is valid. This allows for warningless compilation of
Packit ae235b
 * "long long" types even in the presence of '-ansi -pedantic'. 
Packit ae235b
 */
Packit ae235b
#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
Packit ae235b
#define G_GNUC_EXTENSION __extension__
Packit ae235b
#else
Packit ae235b
#define G_GNUC_EXTENSION
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Every compiler that we target supports inlining, but some of them may
Packit ae235b
 * complain about it if we don't say "__inline".  If we have C99, or if
Packit ae235b
 * we are using C++, then we can use "inline" directly.  Unfortunately
Packit ae235b
 * Visual Studio does not support __STDC_VERSION__, so we need to check
Packit ae235b
 * whether we are on Visual Studio 2013 or earlier to see that we need to
Packit ae235b
 * say "__inline" in C mode.
Packit ae235b
 * Otherwise, we say "__inline" to avoid the warning.
Packit ae235b
 */
Packit ae235b
#define G_CAN_INLINE
Packit ae235b
#ifndef __cplusplus
Packit ae235b
# ifdef _MSC_VER
Packit ae235b
#  if (_MSC_VER < 1900)
Packit ae235b
#   define G_INLINE_DEFINE_NEEDED
Packit ae235b
#  endif
Packit ae235b
# elif !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900)
Packit ae235b
#  define G_INLINE_DEFINE_NEEDED
Packit ae235b
# endif
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifdef G_INLINE_DEFINE_NEEDED
Packit ae235b
# undef inline
Packit ae235b
# define inline __inline
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#undef G_INLINE_DEFINE_NEEDED
Packit ae235b
Packit ae235b
/* For historical reasons we need to continue to support those who
Packit ae235b
 * define G_IMPLEMENT_INLINES to mean "don't implement this here".
Packit ae235b
 */
Packit ae235b
#ifdef G_IMPLEMENT_INLINES
Packit ae235b
#  define G_INLINE_FUNC extern
Packit ae235b
#  undef  G_CAN_INLINE
Packit ae235b
#else
Packit ae235b
#  define G_INLINE_FUNC static inline
Packit ae235b
#endif /* G_IMPLEMENT_INLINES */
Packit ae235b
Packit ae235b
/* Provide macros to feature the GCC function attribute.
Packit ae235b
 */
Packit ae235b
#if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
Packit ae235b
#define G_GNUC_PURE __attribute__((__pure__))
Packit ae235b
#define G_GNUC_MALLOC __attribute__((__malloc__))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_PURE
Packit ae235b
#define G_GNUC_MALLOC
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if     __GNUC__ >= 4
Packit ae235b
#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_NULL_TERMINATED
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html */
Packit ae235b
#ifndef __has_attribute
Packit ae235b
#define __has_attribute(x) 0
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef __has_feature
Packit ae235b
#define __has_feature(x) 0
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef __has_builtin
Packit ae235b
#define __has_builtin(x) 0
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if     (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
Packit ae235b
        (defined(__clang__) && __has_attribute(__alloc_size__))
Packit ae235b
#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
Packit ae235b
#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_ALLOC_SIZE(x)
Packit ae235b
#define G_GNUC_ALLOC_SIZE2(x,y)
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
Packit ae235b
#define G_GNUC_PRINTF( format_idx, arg_idx )    \
Packit ae235b
  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
Packit ae235b
#define G_GNUC_SCANF( format_idx, arg_idx )     \
Packit ae235b
  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
Packit ae235b
#define G_GNUC_FORMAT( arg_idx )                \
Packit ae235b
  __attribute__((__format_arg__ (arg_idx)))
Packit ae235b
#define G_GNUC_NORETURN                         \
Packit ae235b
  __attribute__((__noreturn__))
Packit ae235b
#define G_GNUC_CONST                            \
Packit ae235b
  __attribute__((__const__))
Packit ae235b
#define G_GNUC_UNUSED                           \
Packit ae235b
  __attribute__((__unused__))
Packit ae235b
#define G_GNUC_NO_INSTRUMENT			\
Packit ae235b
  __attribute__((__no_instrument_function__))
Packit ae235b
#else   /* !__GNUC__ */
Packit ae235b
#define G_GNUC_PRINTF( format_idx, arg_idx )
Packit ae235b
#define G_GNUC_SCANF( format_idx, arg_idx )
Packit ae235b
#define G_GNUC_FORMAT( arg_idx )
Packit ae235b
#define G_GNUC_NORETURN
Packit ae235b
#define G_GNUC_CONST
Packit ae235b
#define G_GNUC_UNUSED
Packit ae235b
#define G_GNUC_NO_INSTRUMENT
Packit ae235b
#endif  /* !__GNUC__ */
Packit ae235b
Packit ae235b
#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
Packit ae235b
#define G_GNUC_DEPRECATED __attribute__((__deprecated__))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_DEPRECATED
Packit ae235b
#endif /* __GNUC__ */
Packit ae235b
Packit ae235b
#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
Packit ae235b
#define G_GNUC_DEPRECATED_FOR(f)                        \
Packit ae235b
  __attribute__((deprecated("Use " #f " instead")))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_DEPRECATED_FOR(f)        G_GNUC_DEPRECATED
Packit ae235b
#endif /* __GNUC__ */
Packit ae235b
Packit ae235b
#ifdef __ICC
Packit ae235b
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS                \
Packit ae235b
  _Pragma ("warning (push)")                            \
Packit ae235b
  _Pragma ("warning (disable:1478)")
Packit ae235b
#define G_GNUC_END_IGNORE_DEPRECATIONS			\
Packit ae235b
  _Pragma ("warning (pop)")
Packit ae235b
#elif    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
Packit ae235b
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS		\
Packit ae235b
  _Pragma ("GCC diagnostic push")			\
Packit ae235b
  _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
Packit ae235b
#define G_GNUC_END_IGNORE_DEPRECATIONS			\
Packit ae235b
  _Pragma ("GCC diagnostic pop")
Packit ae235b
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
Packit ae235b
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS		\
Packit ae235b
  __pragma (warning (push))  \
Packit ae235b
  __pragma (warning (disable : 4996))
Packit ae235b
#define G_GNUC_END_IGNORE_DEPRECATIONS			\
Packit ae235b
  __pragma (warning (pop))
Packit ae235b
#elif defined (__clang__)
Packit ae235b
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
Packit ae235b
  _Pragma("clang diagnostic push") \
Packit ae235b
  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
Packit ae235b
#define G_GNUC_END_IGNORE_DEPRECATIONS \
Packit ae235b
  _Pragma("clang diagnostic pop")
Packit ae235b
#else
Packit ae235b
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit ae235b
#define G_GNUC_END_IGNORE_DEPRECATIONS
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if     __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
Packit ae235b
#define G_GNUC_MAY_ALIAS __attribute__((may_alias))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_MAY_ALIAS
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
Packit ae235b
#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
Packit ae235b
#else
Packit ae235b
#define G_GNUC_WARN_UNUSED_RESULT
Packit ae235b
#endif /* __GNUC__ */
Packit ae235b
Packit ae235b
#ifndef G_DISABLE_DEPRECATED
Packit ae235b
/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
Packit ae235b
 * macros, so we can refer to them as strings unconditionally.
Packit ae235b
 * usage not-recommended since gcc-3.0
Packit ae235b
 */
Packit ae235b
#if defined (__GNUC__) && (__GNUC__ < 3)
Packit ae235b
#define G_GNUC_FUNCTION         __FUNCTION__
Packit ae235b
#define G_GNUC_PRETTY_FUNCTION  __PRETTY_FUNCTION__
Packit ae235b
#else   /* !__GNUC__ */
Packit ae235b
#define G_GNUC_FUNCTION         ""
Packit ae235b
#define G_GNUC_PRETTY_FUNCTION  ""
Packit ae235b
#endif  /* !__GNUC__ */
Packit ae235b
#endif  /* !G_DISABLE_DEPRECATED */
Packit ae235b
Packit ae235b
#if __has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__)
Packit ae235b
#define G_ANALYZER_ANALYZING 1
Packit ae235b
#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
Packit ae235b
#else
Packit ae235b
#define G_ANALYZER_ANALYZING 0
Packit ae235b
#define G_ANALYZER_NORETURN
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#define G_STRINGIFY(macro_or_string)	G_STRINGIFY_ARG (macro_or_string)
Packit ae235b
#define	G_STRINGIFY_ARG(contents)	#contents
Packit ae235b
Packit ae235b
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
Packit ae235b
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
Packit ae235b
#define G_PASTE(identifier1,identifier2)      G_PASTE_ARGS (identifier1, identifier2)
Packit ae235b
#ifdef __COUNTER__
Packit ae235b
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
Packit ae235b
#else
Packit ae235b
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED
Packit ae235b
#endif
Packit ae235b
#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1]))
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Provide a string identifying the current code position */
Packit ae235b
#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus)
Packit ae235b
#define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"
Packit ae235b
#else
Packit ae235b
#define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__)
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Provide a string identifying the current function, non-concatenatable */
Packit ae235b
#if defined (__GNUC__) && defined (__cplusplus)
Packit ae235b
#define G_STRFUNC     ((const char*) (__PRETTY_FUNCTION__))
Packit ae235b
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
Packit ae235b
#define G_STRFUNC     ((const char*) (__func__))
Packit ae235b
#elif defined (__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300))
Packit ae235b
#define G_STRFUNC     ((const char*) (__FUNCTION__))
Packit ae235b
#else
Packit ae235b
#define G_STRFUNC     ((const char*) ("???"))
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Guard C code in headers, while including them from C++ */
Packit ae235b
#ifdef  __cplusplus
Packit ae235b
#define G_BEGIN_DECLS  extern "C" {
Packit ae235b
#define G_END_DECLS    }
Packit ae235b
#else
Packit ae235b
#define G_BEGIN_DECLS
Packit ae235b
#define G_END_DECLS
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Provide definitions for some commonly used macros.
Packit ae235b
 *  Some of them are only provided if they haven't already
Packit ae235b
 *  been defined. It is assumed that if they are already
Packit ae235b
 *  defined then the current definition is correct.
Packit ae235b
 */
Packit ae235b
#ifndef NULL
Packit ae235b
#  ifdef __cplusplus
Packit ae235b
#  define NULL        (0L)
Packit ae235b
#  else /* !__cplusplus */
Packit ae235b
#  define NULL        ((void*) 0)
Packit ae235b
#  endif /* !__cplusplus */
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef	FALSE
Packit ae235b
#define	FALSE	(0)
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef	TRUE
Packit ae235b
#define	TRUE	(!FALSE)
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#undef	MAX
Packit ae235b
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
Packit ae235b
Packit ae235b
#undef	MIN
Packit ae235b
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
Packit ae235b
Packit ae235b
#undef	ABS
Packit ae235b
#define ABS(a)	   (((a) < 0) ? -(a) : (a))
Packit ae235b
Packit ae235b
#undef	CLAMP
Packit ae235b
#define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
Packit ae235b
Packit ae235b
/* Count the number of elements in an array. The array must be defined
Packit ae235b
 * as such; using this with a dynamically allocated array will give
Packit ae235b
 * incorrect results.
Packit ae235b
 */
Packit ae235b
#define G_N_ELEMENTS(arr)		(sizeof (arr) / sizeof ((arr)[0]))
Packit ae235b
Packit ae235b
/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
Packit ae235b
 */
Packit ae235b
#define GPOINTER_TO_SIZE(p)	((gsize) (p))
Packit ae235b
#define GSIZE_TO_POINTER(s)	((gpointer) (gsize) (s))
Packit ae235b
Packit ae235b
/* Provide convenience macros for handling structure
Packit ae235b
 * fields through their offsets.
Packit ae235b
 */
Packit ae235b
Packit ae235b
#if (defined(__GNUC__)  && __GNUC__ >= 4) || defined (_MSC_VER)
Packit ae235b
#define G_STRUCT_OFFSET(struct_type, member) \
Packit ae235b
      ((glong) offsetof (struct_type, member))
Packit ae235b
#else
Packit ae235b
#define G_STRUCT_OFFSET(struct_type, member)	\
Packit ae235b
      ((glong) ((guint8*) &((struct_type*) 0)->member))
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#define G_STRUCT_MEMBER_P(struct_p, struct_offset)   \
Packit ae235b
    ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
Packit ae235b
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset)   \
Packit ae235b
    (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
Packit ae235b
Packit ae235b
/* Provide simple macro statement wrappers:
Packit ae235b
 *   G_STMT_START { statements; } G_STMT_END;
Packit ae235b
 * This can be used as a single statement, like:
Packit ae235b
 *   if (x) G_STMT_START { ... } G_STMT_END; else ...
Packit ae235b
 * This intentionally does not use compiler extensions like GCC's '({...})' to
Packit ae235b
 * avoid portability issue or side effects when compiled with different compilers.
Packit ae235b
 * MSVC complains about "while(0)": C4127: "Conditional expression is constant",
Packit ae235b
 * so we use __pragma to avoid the warning since the use here is intentional.
Packit ae235b
 */
Packit ae235b
#if !(defined (G_STMT_START) && defined (G_STMT_END))
Packit ae235b
#define G_STMT_START  do
Packit ae235b
#if defined (_MSC_VER) && (_MSC_VER >= 1500)
Packit ae235b
#define G_STMT_END \
Packit ae235b
    __pragma(warning(push)) \
Packit ae235b
    __pragma(warning(disable:4127)) \
Packit ae235b
    while(0) \
Packit ae235b
    __pragma(warning(pop))
Packit ae235b
#else
Packit ae235b
#define G_STMT_END    while (0)
Packit ae235b
#endif
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Deprecated -- do not use. */
Packit ae235b
#ifndef G_DISABLE_DEPRECATED
Packit ae235b
#ifdef G_DISABLE_CONST_RETURNS
Packit ae235b
#define G_CONST_RETURN
Packit ae235b
#else
Packit ae235b
#define G_CONST_RETURN const
Packit ae235b
#endif
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/*
Packit ae235b
 * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to 
Packit ae235b
 * the compiler about the expected result of an expression. Some compilers
Packit ae235b
 * can use this information for optimizations.
Packit ae235b
 *
Packit ae235b
 * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
Packit ae235b
 * putting assignments in g_return_if_fail ().  
Packit ae235b
 */
Packit ae235b
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
Packit ae235b
#define _G_BOOLEAN_EXPR(expr)                   \
Packit ae235b
 G_GNUC_EXTENSION ({                            \
Packit ae235b
   int _g_boolean_var_;                         \
Packit ae235b
   if (expr)                                    \
Packit ae235b
      _g_boolean_var_ = 1;                      \
Packit ae235b
   else                                         \
Packit ae235b
      _g_boolean_var_ = 0;                      \
Packit ae235b
   _g_boolean_var_;                             \
Packit ae235b
})
Packit ae235b
#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
Packit ae235b
#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 0))
Packit ae235b
#else
Packit ae235b
#define G_LIKELY(expr) (expr)
Packit ae235b
#define G_UNLIKELY(expr) (expr)
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
Packit ae235b
#define G_DEPRECATED __attribute__((__deprecated__))
Packit ae235b
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
Packit ae235b
#define G_DEPRECATED __declspec(deprecated)
Packit ae235b
#else
Packit ae235b
#define G_DEPRECATED
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
Packit ae235b
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
Packit ae235b
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
Packit ae235b
#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
Packit ae235b
#else
Packit ae235b
#define G_DEPRECATED_FOR(f) G_DEPRECATED
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
Packit ae235b
#define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min)))
Packit ae235b
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
Packit ae235b
#define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min))
Packit ae235b
#else
Packit ae235b
#define G_UNAVAILABLE(maj,min) G_DEPRECATED
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef _GLIB_EXTERN
Packit ae235b
#define _GLIB_EXTERN extern
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* These macros are used to mark deprecated functions in GLib headers,
Packit ae235b
 * and thus have to be exposed in installed headers. But please
Packit ae235b
 * do *not* use them in other projects. Instead, use G_DEPRECATED
Packit ae235b
 * or define your own wrappers around it.
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS
Packit ae235b
#define GLIB_DEPRECATED _GLIB_EXTERN
Packit ae235b
#define GLIB_DEPRECATED_FOR(f) _GLIB_EXTERN
Packit ae235b
#define GLIB_UNAVAILABLE(maj,min) _GLIB_EXTERN
Packit ae235b
#else
Packit ae235b
#define GLIB_DEPRECATED G_DEPRECATED _GLIB_EXTERN
Packit ae235b
#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GLIB_EXTERN
Packit ae235b
#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GLIB_EXTERN
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#ifndef __GI_SCANNER__
Packit ae235b
Packit ae235b
#ifdef __GNUC__
Packit ae235b
Packit ae235b
/* these macros are private */
Packit ae235b
#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
Packit ae235b
#define _GLIB_AUTOPTR_TYPENAME(TypeName)  TypeName##_autoptr
Packit ae235b
#define _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) glib_listautoptr_cleanup_##TypeName
Packit ae235b
#define _GLIB_AUTOPTR_LIST_TYPENAME(TypeName)  TypeName##_listautoptr
Packit ae235b
#define _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) glib_slistautoptr_cleanup_##TypeName
Packit ae235b
#define _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName)  TypeName##_slistautoptr
Packit ae235b
#define _GLIB_AUTO_FUNC_NAME(TypeName)    glib_auto_cleanup_##TypeName
Packit ae235b
#define _GLIB_CLEANUP(func)               __attribute__((cleanup(func)))
Packit ae235b
#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) \
Packit ae235b
  typedef ModuleObjName *_GLIB_AUTOPTR_TYPENAME(ModuleObjName);                                          \
Packit ae235b
  static inline void _GLIB_AUTOPTR_FUNC_NAME(ModuleObjName) (ModuleObjName **_ptr) {                     \
Packit ae235b
    _GLIB_AUTOPTR_FUNC_NAME(ParentName) ((ParentName **) _ptr); }                                        \
Packit ae235b
Packit ae235b
Packit ae235b
/* these macros are API */
Packit ae235b
#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) \
Packit ae235b
  typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName);                                                           \
Packit ae235b
  typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName);                                                         \
Packit ae235b
  typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName);                                                         \
Packit ae235b
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                              \
Packit ae235b
  static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); }         \
Packit ae235b
  static inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) func); } \
Packit ae235b
  static inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) func); } \
Packit ae235b
  G_GNUC_END_IGNORE_DEPRECATIONS
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
Packit ae235b
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                              \
Packit ae235b
  static inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { (func) (_ptr); }                         \
Packit ae235b
  G_GNUC_END_IGNORE_DEPRECATIONS
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) \
Packit ae235b
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                              \
Packit ae235b
  static inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); }     \
Packit ae235b
  G_GNUC_END_IGNORE_DEPRECATIONS
Packit ae235b
#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName)
Packit ae235b
#define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName)
Packit ae235b
#define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName)
Packit ae235b
#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName
Packit ae235b
#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree)
Packit ae235b
Packit ae235b
#else /* not GNU C */
Packit ae235b
/* this (dummy) macro is private */
Packit ae235b
#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName)
Packit ae235b
Packit ae235b
/* these (dummy) macros are API */
Packit ae235b
#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func)
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func)
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none)
Packit ae235b
Packit ae235b
/* no declaration of g_auto() or g_autoptr() here */
Packit ae235b
#endif /* __GNUC__ */
Packit ae235b
Packit ae235b
#else
Packit ae235b
Packit ae235b
#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName)
Packit ae235b
Packit ae235b
#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func)
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func)
Packit ae235b
#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none)
Packit ae235b
Packit ae235b
#endif /* __GI_SCANNER__ */
Packit ae235b
Packit ae235b
#endif /* __G_MACROS_H__ */