/usr/include/libdazzle-1.0/util/dzl-macros.h is in libdazzle-1.0-dev 3.28.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* dzl-macros.h
*
* Copyright (C) 2017 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DZL_MACROS_H
#define DZL_MACROS_H
#include <glib.h>
#include <string.h>
#ifdef __linux__
# include <sys/types.h>
# include <sys/syscall.h>
# include <unistd.h>
#endif
G_BEGIN_DECLS
#if defined(_MSC_VER)
# define DZL_ALIGNED_BEGIN(_N) __declspec(align(_N))
# define DZL_ALIGNED_END(_N)
#else
# define DZL_ALIGNED_BEGIN(_N)
# define DZL_ALIGNED_END(_N) __attribute__((aligned(_N)))
#endif
#define dzl_clear_weak_pointer(ptr) \
(*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0)
#define dzl_set_weak_pointer(ptr,obj) \
((obj!=*(ptr))?(dzl_clear_weak_pointer(ptr),*(ptr)=obj,((obj)?g_object_add_weak_pointer((GObject*)obj,(gpointer*)ptr),NULL:NULL),1):0)
/* strlen() gets hoisted out automatically at -O0 for everything but MSVC */
#define DZL_LITERAL_LENGTH(s) (strlen(s))
static inline void
dzl_clear_signal_handler (gpointer object,
gulong *location_of_handler)
{
if (*location_of_handler != 0)
{
gulong handler = *location_of_handler;
*location_of_handler = 0;
g_signal_handler_disconnect (object, handler);
}
}
static inline gboolean
dzl_str_empty0 (gconstpointer str)
{
/* We use a gconstpointer to allow passing both
* signed and unsigned chars into this function */
return str == NULL || *(char*)str == '\0';
}
static inline gboolean
dzl_str_equal0 (gconstpointer str1,
gconstpointer str2)
{
/* We use gconstpointer so that we can allow
* both signed and unsigned chars here (such as xmlChar). */
return g_strcmp0 (str1, str2) == 0;
}
static inline void
dzl_clear_source (guint *source_ptr)
{
guint source = *source_ptr;
*source_ptr = 0;
if (source != 0)
g_source_remove (source);
}
static inline void
dzl_assert_is_main_thread (void)
{
#ifndef G_DISABLE_ASSERT
# ifdef __linux__
static GThread *main_thread;
GThread *self = g_thread_self ();
if G_LIKELY (main_thread == self)
return;
/* Slow path, rely on task id == process id */
if ((pid_t)syscall (SYS_gettid) == getpid ())
{
/* Allow for fast path next time */
main_thread = self;
return;
}
g_assert_not_reached ();
# endif
#endif
}
G_END_DECLS
#endif /* DZL_MACROS_H */
|