Skip to content

Commit 5bc10bb

Browse files
author
Gabor Nagy
committed
glib: remove unnecessary glib compat functions
Signed-off-by: Gabor Nagy <gabor.nagy@oneidentity.com>
1 parent af1b6e3 commit 5bc10bb

12 files changed

+2
-287
lines changed

CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,8 @@ find_package(GLIB 2.32.0 REQUIRED COMPONENTS gmodule gthread)
187187
set(CMAKE_REQUIRED_INCLUDES ${GLIB_INCLUDE_DIRS})
188188
set(CMAKE_REQUIRED_LIBRARIES ${GLIB_LIBRARIES})
189189
check_symbol_exists(g_list_copy_deep "glib.h" SYSLOG_NG_HAVE_G_LIST_COPY_DEEP)
190-
check_symbol_exists(g_queue_free_full "glib.h" SYSLOG_NG_HAVE_G_QUEUE_FREE_FULL)
191-
check_symbol_exists(g_list_free_full "glib.h" SYSLOG_NG_HAVE_G_LIST_FREE_FULL)
192190
check_symbol_exists(g_ptr_array_find_with_equal_func "glib.h" SYSLOG_NG_HAVE_G_PTR_ARRAY_FIND_WITH_EQUAL_FUNC)
193191
check_symbol_exists(g_canonicalize_filename "glib.h" SYSLOG_NG_HAVE_G_CANONICALIZE_FILENAME)
194-
check_symbol_exists(g_hash_table_contains "glib.h" SYSLOG_NG_HAVE_G_HASH_TABLE_CONTAINS)
195192

196193
find_package(RabbitMQ)
197194
if (RabbitMQ_FOUND)

configure.ac

+1-4
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,8 @@ LDFLAGS="$LDFLAGS $GLIB_LIBS"
942942
old_LIBS=$LIBS
943943
LIBS="$LIBS $GLIB_LIBS"
944944
AC_CHECK_FUNCS(g_list_copy_deep \
945-
g_queue_free_full \
946-
g_list_free_full \
947945
g_ptr_array_find_with_equal_func \
948-
g_canonicalize_filename \
949-
g_hash_table_contains)
946+
g_canonicalize_filename)
950947
LIBS=$old_LIBS
951948

952949
AC_CACHE_CHECK(sanity checking Glib headers,

lib/atomic.h

-4
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ g_atomic_counter_get(GAtomicCounter *c)
5353
static inline gint
5454
g_atomic_counter_exchange_and_add(GAtomicCounter *c, gint val)
5555
{
56-
#if GLIB_CHECK_VERSION(2, 30, 0)
5756
return g_atomic_int_add(&c->counter, val);
58-
#else
59-
return g_atomic_int_exchange_and_add(&c->counter, val);
60-
#endif
6157
}
6258

6359
static inline gint

lib/compat/Makefile.am

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
compatincludedir = ${pkgincludedir}/compat
22

33
EXTRA_DIST += \
4-
lib/compat/CMakeLists.txt \
5-
lib/compat/glib-g_mkdtemp.c
4+
lib/compat/CMakeLists.txt
65

76
compatinclude_HEADERS = \
87
lib/compat/compat.h \

lib/compat/glib-g_mkdtemp.c

-135
This file was deleted.

lib/compat/glib.c

-60
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,6 @@ g_list_copy_deep(GList *list,
5858

5959
#endif
6060

61-
#ifndef SYSLOG_NG_HAVE_G_QUEUE_FREE_FULL
62-
63-
void
64-
g_queue_free_full(GQueue *queue, GDestroyNotify free_func)
65-
{
66-
g_queue_foreach(queue, (GFunc) free_func, NULL);
67-
g_queue_free(queue);
68-
}
69-
70-
#endif
71-
72-
#ifndef SYSLOG_NG_HAVE_G_LIST_FREE_FULL
73-
74-
void
75-
g_list_free_full (GList *list, GDestroyNotify free_func)
76-
{
77-
g_list_foreach (list, (GFunc) free_func, NULL);
78-
g_list_free (list);
79-
}
80-
81-
#endif
82-
83-
8461
#ifndef SYSLOG_NG_HAVE_G_PTR_ARRAY_FIND_WITH_EQUAL_FUNC
8562
gboolean
8663
g_ptr_array_find_with_equal_func (GPtrArray *haystack,
@@ -248,17 +225,6 @@ g_canonicalize_filename (const gchar *filename,
248225

249226
#endif
250227

251-
#ifndef SYSLOG_NG_HAVE_G_HASH_TABLE_CONTAINS
252-
gboolean
253-
g_hash_table_contains (GHashTable *hash_table,
254-
gconstpointer key)
255-
{
256-
gpointer orig_key;
257-
gpointer value;
258-
return g_hash_table_lookup_extended(hash_table, key, &orig_key, &value);
259-
}
260-
#endif
261-
262228
#if !GLIB_CHECK_VERSION(2, 54, 0)
263229
/**
264230
* g_base64_encode:
@@ -331,29 +297,3 @@ g_utf8_get_char_validated_fixed(const gchar *p, gssize max_len)
331297
return g_utf8_get_char_validated(p, max_len);
332298
}
333299
#endif
334-
335-
#if !GLIB_CHECK_VERSION(2, 32, 0)
336-
GThread *
337-
g_thread_new(const gchar *name, GThreadFunc func, gpointer data)
338-
{
339-
return g_thread_create(func, data, TRUE, NULL);
340-
}
341-
#endif
342-
343-
#if !GLIB_CHECK_VERSION(2, 32, 0)
344-
gboolean
345-
g_cond_wait_until (GCond *cond, GMutex *mutex, gint64 end_time)
346-
{
347-
gint64 diff_in_millisec = (end_time - g_get_monotonic_time()) / G_TIME_SPAN_MILLISECOND;
348-
349-
GTimeVal tv;
350-
g_get_current_time(&tv);
351-
g_time_val_add(&tv, diff_in_millisec * 1000);
352-
353-
return g_cond_timed_wait(cond, mutex, &tv);
354-
}
355-
#endif
356-
357-
#if !GLIB_CHECK_VERSION(2, 30, 0)
358-
#include "glib-g_mkdtemp.c"
359-
#endif

lib/compat/glib.h

-66
Original file line numberDiff line numberDiff line change
@@ -37,66 +37,13 @@ gchar *g_canonicalize_filename (const gchar *filename,
3737
const gchar *relative_to);
3838
#endif
3939

40-
#ifndef g_atomic_pointer_add
41-
42-
/* This implementation was copied from glib 2.46, copyright Ryan Lortie
43-
* under the LGPL 2 or later, which is compatible with our LGPL 2.1 license.
44-
* NOTE: this code only runs if we are running on an old glib version (e.g.
45-
* older than 2.32)
46-
* */
47-
48-
#define g_atomic_pointer_add(atomic, val) \
49-
(G_GNUC_EXTENSION ({ \
50-
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
51-
(void) (0 ? (gpointer) *(atomic) : NULL); \
52-
(void) (0 ? (val) ^ (val) : 1); \
53-
(gssize) __sync_fetch_and_add ((atomic), (val)); \
54-
}))
55-
#define g_atomic_pointer_or(atomic, val) \
56-
(G_GNUC_EXTENSION ({ \
57-
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
58-
(void) (0 ? (gpointer) *(atomic) : NULL); \
59-
(void) (0 ? (val) ^ (val) : 1); \
60-
(gsize) __sync_fetch_and_or ((atomic), (val)); \
61-
}))
62-
#define g_atomic_pointer_xor(atomic, val) \
63-
(G_GNUC_EXTENSION ({ \
64-
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
65-
(void) (0 ? (gpointer) *(atomic) : NULL); \
66-
(void) (0 ? (val) ^ (val) : 1); \
67-
(gsize) __sync_fetch_and_xor ((atomic), (val)); \
68-
}))
69-
#define g_atomic_pointer_and(atomic, val) \
70-
(G_GNUC_EXTENSION ({ \
71-
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
72-
(void) (0 ? (gpointer) *(atomic) : NULL); \
73-
(void) (0 ? (val) ^ (val) : 1); \
74-
(gsize) __sync_fetch_and_and ((atomic), (val)); \
75-
}))
76-
77-
#endif
78-
79-
#ifndef SYSLOG_NG_HAVE_G_QUEUE_FREE_FULL
80-
void g_queue_free_full(GQueue *queue, GDestroyNotify free_func);
81-
#endif
82-
83-
#ifndef SYSLOG_NG_HAVE_G_LIST_FREE_FULL
84-
void g_list_free_full (GList *list, GDestroyNotify free_func);
85-
#endif
86-
8740
#ifndef SYSLOG_NG_HAVE_G_PTR_ARRAY_FIND_WITH_EQUAL_FUNC
8841
gboolean g_ptr_array_find_with_equal_func (GPtrArray *haystack,
8942
gconstpointer needle,
9043
GEqualFunc equal_func,
9144
guint *index_);
9245
#endif
9346

94-
#ifndef SYSLOG_NG_HAVE_G_HASH_TABLE_CONTAINS
95-
gboolean
96-
g_hash_table_contains (GHashTable *hash_table,
97-
gconstpointer key);
98-
#endif
99-
10047
#if !GLIB_CHECK_VERSION(2, 54, 0)
10148
#define g_base64_encode g_base64_encode_fixed
10249
gchar *g_base64_encode_fixed(const guchar *data, gsize len);
@@ -112,17 +59,4 @@ gboolean slng_g_hash_table_insert (GHashTable *hash_table, gpointer key, gpointe
11259
gunichar g_utf8_get_char_validated_fixed (const gchar *p, gssize max_len);
11360
#endif
11461

115-
#if !GLIB_CHECK_VERSION(2, 32, 0)
116-
GThread *g_thread_new(const gchar *name, GThreadFunc func, gpointer data);
117-
#endif
118-
119-
#if !GLIB_CHECK_VERSION(2, 32, 0)
120-
gboolean g_cond_wait_until (GCond *cond, GMutex *mutex, gint64 end_time);
121-
#endif
122-
123-
#if !GLIB_CHECK_VERSION(2, 30, 0)
124-
gchar *g_mkdtemp_full (gchar *tmpl, gint mode);
125-
gchar *g_mkdtemp (gchar *tmpl);
126-
#endif
127-
12862
#endif

lib/seqnum.h

-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ step_sequence_number(gint32 *seqnum)
4545
static inline gint32
4646
step_sequence_number_atomic(gint32 *seqnum)
4747
{
48-
#if GLIB_CHECK_VERSION(2, 30, 0)
4948
return (gint32)g_atomic_int_add(seqnum, 1);
50-
#else
51-
return (gint32)g_atomic_int_exchange_and_add(seqnum, 1);
52-
#endif
5349
}
5450

5551

modules/diskq/dqtool.c

-2
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,7 @@ main(int argc, char *argv[])
680680
if (strcmp(modes[mode].mode, mode_string) == 0)
681681
{
682682
ctx = g_option_context_new(mode_string);
683-
#if GLIB_CHECK_VERSION (2, 12, 0)
684683
g_option_context_set_summary(ctx, modes[mode].description);
685-
#endif
686684
g_option_context_add_main_entries(ctx, modes[mode].options, NULL);
687685
g_option_context_add_main_entries(ctx, dqtool_options, NULL);
688686
break;

persist-tool/persist-tool.c

-2
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ main(int argc, char *argv[])
231231
if (strcmp(modes[mode].mode, mode_string) == 0)
232232
{
233233
ctx = g_option_context_new(modes[mode].parameter_description);
234-
#if GLIB_CHECK_VERSION (2, 12, 0)
235234
g_option_context_set_summary(ctx, modes[mode].description);
236-
#endif
237235
g_option_context_add_main_entries(ctx, modes[mode].options, NULL );
238236
break;
239237
}

syslog-ng-config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@
7272
#cmakedefine01 SYSLOG_NG_HAVE_GETOPT_H
7373
#cmakedefine SYSLOG_NG_HAVE_GETPROTOBYNUMBER_R
7474
#cmakedefine SYSLOG_NG_HAVE_G_LIST_COPY_DEEP
75-
#cmakedefine SYSLOG_NG_HAVE_G_QUEUE_FREE_FULL
76-
#cmakedefine SYSLOG_NG_HAVE_G_LIST_FREE_FULL
7775
#cmakedefine SYSLOG_NG_HAVE_G_PTR_ARRAY_FIND_WITH_EQUAL_FUNC
7876
#cmakedefine SYSLOG_NG_HAVE_G_CANONICALIZE_FILENAME
79-
#cmakedefine SYSLOG_NG_HAVE_G_HASH_TABLE_CONTAINS
8077
#cmakedefine SYSLOG_NG_HAVE_GMTIME_R
8178
#cmakedefine SYSLOG_NG_HAVE_LOCALTIME_R
8279
#cmakedefine SYSLOG_NG_HAVE_AMQP_SSL_SOCKET_SET_VERIFY_PEER

syslog-ng-ctl/syslog-ng-ctl.c

-2
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ setup_help_context(const gchar *cmdname, CommandDescriptor *active_mode)
174174
return NULL;
175175

176176
GOptionContext *ctx = g_option_context_new(cmdname);
177-
#if GLIB_CHECK_VERSION (2, 12, 0)
178177
g_option_context_set_summary(ctx, active_mode->description);
179-
#endif
180178
g_option_context_add_main_entries(ctx, active_mode->options, NULL);
181179
g_option_context_add_main_entries(ctx, slng_options, NULL);
182180

0 commit comments

Comments
 (0)