mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
Merge branch 'add-g-has-typeof-1440' into 'master'
gmacros: Add new private g_has_typeof to abstract __typeof__ checks Closes #1440 See merge request GNOME/glib!172
This commit is contained in:
commit
16c6a73586
@ -110,6 +110,18 @@
|
|||||||
#define G_GNUC_NULL_TERMINATED
|
#define G_GNUC_NULL_TERMINATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since
|
||||||
|
* __typeof__ is used in a few places in GLib, provide a pre-processor symbol
|
||||||
|
* to factor the check out from callers.
|
||||||
|
*
|
||||||
|
* This symbol is private.
|
||||||
|
*/
|
||||||
|
#undef g_has_typeof
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus)
|
||||||
|
#define g_has_typeof
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html
|
* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html
|
||||||
* These are not available on GCC, but since the pre-processor doesn't do
|
* These are not available on GCC, but since the pre-processor doesn't do
|
||||||
|
@ -110,7 +110,7 @@ gpointer g_try_realloc_n (gpointer mem,
|
|||||||
gsize n_blocks,
|
gsize n_blocks,
|
||||||
gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
|
#if defined(g_has_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
|
||||||
#define g_clear_pointer(pp, destroy) \
|
#define g_clear_pointer(pp, destroy) \
|
||||||
G_STMT_START { \
|
G_STMT_START { \
|
||||||
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
||||||
|
@ -71,7 +71,7 @@ gsize g_atomic_rc_box_get_size (gpointer mem_block);
|
|||||||
#define g_atomic_rc_box_new0(type) \
|
#define g_atomic_rc_box_new0(type) \
|
||||||
((type *) g_atomic_rc_box_alloc0 (sizeof (type)))
|
((type *) g_atomic_rc_box_alloc0 (sizeof (type)))
|
||||||
|
|
||||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(_cplusplus)
|
#ifdef g_has_typeof
|
||||||
/* Type check to avoid assigning references to different types */
|
/* Type check to avoid assigning references to different types */
|
||||||
# define g_rc_box_acquire(mem_block) \
|
# define g_rc_box_acquire(mem_block) \
|
||||||
((__typeof__(mem_block)) (g_rc_box_acquire) (mem_block))
|
((__typeof__(mem_block)) (g_rc_box_acquire) (mem_block))
|
||||||
|
@ -507,7 +507,7 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
void g_object_remove_weak_pointer (GObject *object,
|
void g_object_remove_weak_pointer (GObject *object,
|
||||||
gpointer *weak_pointer_location);
|
gpointer *weak_pointer_location);
|
||||||
|
|
||||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56
|
#if defined(g_has_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56
|
||||||
/* Make reference APIs type safe with macros */
|
/* Make reference APIs type safe with macros */
|
||||||
#define g_object_ref(Obj) ((__typeof__(Obj)) (g_object_ref) (Obj))
|
#define g_object_ref(Obj) ((__typeof__(Obj)) (g_object_ref) (Obj))
|
||||||
#define g_object_ref_sink(Obj) ((__typeof__(Obj)) (g_object_ref_sink) (Obj))
|
#define g_object_ref_sink(Obj) ((__typeof__(Obj)) (g_object_ref_sink) (Obj))
|
||||||
|
Loading…
Reference in New Issue
Block a user