diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | configure.ac | 21 | ||||
| -rw-r--r-- | libgnu/ChangeLog | 5 | ||||
| -rw-r--r-- | libgnu/Makefile.am | 6 | ||||
| -rw-r--r-- | libgnu/tdestroy.c | 47 |
5 files changed, 83 insertions, 1 deletions
@@ -1,5 +1,10 @@ 2017-05-04 Ulf Hermann <[email protected]> + * configure.ac: Check for tdestroy and node_t. Declare tdestroy in + config.h if tdestroy is not available from search.h, but node_t is. + +2017-05-04 Ulf Hermann <[email protected]> + * configure.ac: Check for unlocked I/O functions. 2017-04-28 Ulf Hermann <[email protected]> diff --git a/configure.ac b/configure.ac index bfdc53fb..88b9d0a9 100644 --- a/configure.ac +++ b/configure.ac @@ -610,6 +610,27 @@ AC_CHECK_DECLS([feof_unlocked, ferror_unlocked, fputc_unlocked, fputs_unlocked, fwrite_unlocked, putc_unlocked, putchar_unlocked], [], [], [[#include <stdio.h>]]) +AC_CHECK_DECLS([tdestroy], [], [], + [#include <search.h>]) +if test "x$ac_cv_have_decl_tdestroy" != "xyes"; then + AC_CHECK_MEMBERS([node_t.key, node_t.rlink, node_t.llink], + [have_node_t="yes"], [have_node_t="no"], + [#define _SEARCH_PRIVATE + #include <search.h>]) + if test "x$have_node_t" = "xyes"; then + AC_DEFINE([USE_PRIVATE_TDESTROY], [1], [Implement tdestroy using private node_t from search.h]) + fi +fi +AM_CONDITIONAL(USE_PRIVATE_TDESTROY, [test "x$have_node_t" = "xyes"]) + +AH_VERBATIM([USE_PRIVATE_TDESTROY], [ +/* Declare tdestroy here if it is not available from a system header. */ +#undef USE_PRIVATE_TDESTROY +#ifdef USE_PRIVATE_TDESTROY +void tdestroy(void *root, void (*free_node)(void *nodep)); +#endif +]) + dnl Check if we have <linux/bpf.h> for EM_BPF disassembly. AC_CHECK_HEADERS(linux/bpf.h) AM_CONDITIONAL(HAVE_LINUX_BPF_H, [test "x$ac_cv_header_linux_bpf_h" = "xyes"]) diff --git a/libgnu/ChangeLog b/libgnu/ChangeLog index 3394de6d..7b146b6c 100644 --- a/libgnu/ChangeLog +++ b/libgnu/ChangeLog @@ -1,5 +1,10 @@ 2017-05-04 Ulf Hermann <[email protected]> + * Makefile.am: Use our own implementation of tdestroy if we have to. + * tdestroy.c: New file. + +2017-05-04 Ulf Hermann <[email protected]> + * Makefile.am: If GNU basename is unavailable add our own implementation. * basename-gnu.c: New file. diff --git a/libgnu/Makefile.am b/libgnu/Makefile.am index 32c9aa71..99abab0d 100644 --- a/libgnu/Makefile.am +++ b/libgnu/Makefile.am @@ -36,7 +36,7 @@ MOSTLYCLEANFILES = MOSTLYCLEANDIRS = BUILT_SOURCES = EXTRA_DIST = endian.in.h byteswap.in.h sys_mman.win32.h mman_win32.c sysconf_win32.c ar.in.h features.in.h \ - stdio_ext.in.h fts.in.h basename-gnu.c + stdio_ext.in.h fts.in.h basename-gnu.c tdestroy.c CLEANFILES = SUFFIXES = @@ -108,3 +108,7 @@ endif if !HAVE_BASENAME libgnu_a_SOURCES += basename-gnu.c endif + +if USE_PRIVATE_TDESTROY +libgnu_a_SOURCES += tdestroy.c +endif diff --git a/libgnu/tdestroy.c b/libgnu/tdestroy.c new file mode 100644 index 00000000..d14b8756 --- /dev/null +++ b/libgnu/tdestroy.c @@ -0,0 +1,47 @@ +/* tdestroy, on systems where node is exposed from search.h + Copyright (C) 2017 The Qt Company Ltd. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils 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 copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <stdlib.h> +#define _SEARCH_PRIVATE +#include <search.h> + +void +tdestroy (void *vroot, void (*free_node)(void *nodep)) +{ + if (vroot == NULL) + return; + + node_t *root = (node_t *) vroot; + tdestroy (root->llink, free_node); + tdestroy (root->rlink, free_node); + free_node ((void *) root->key); + free (root); +} + |
