From patchwork Tue May 27 12:10:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1167 Received: (qmail 17698 invoked by alias); 27 May 2014 12:10:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17685 invoked by uid 89); 27 May 2014 12:10:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: hera.aquilenet.fr Received: from hera.aquilenet.fr (HELO hera.aquilenet.fr) (141.255.128.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 May 2014 12:10:52 +0000 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id D53772B0D; Tue, 27 May 2014 14:10:49 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g7TxfK0ygDb7; Tue, 27 May 2014 14:10:49 +0200 (CEST) Received: from pluto (pluto.bordeaux.inria.fr [193.50.110.57]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 98401570; Tue, 27 May 2014 14:10:49 +0200 (CEST) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: gdb-patches@sourceware.org, Doug Evans Subject: [PATCH] guile: Allow compilation with Guile <= 2.0.5 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 8 Prairial an 222 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Tue, 27 May 2014 14:10:49 +0200 Message-ID: <87bnujcth2.fsf@gnu.org> User-Agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 The attached patch allows compilation with Guile <= 2.0.5. Guile 2.0.5 is 2.5 years old but is still commonly found in some distros such as the current Debian stable. Tested with Guile 2.1 (current master) and 2.0.5 on x86_64-linux-gnu. OK to push? Thanks, Ludo’. 2014-05-27 Ludovic Courtès * configure.ac: When Guile is available, check for the availability of 'scm_new_smob'. * configure, config.h.in: Regenerate. * guile/guile-internal.h (scm_new_smob) [!HAVE_SCM_NEW_SMOB]: New function. --- gdb/config.in | 3 +++ gdb/configure | 18 ++++++++++++++++++ gdb/configure.ac | 9 +++++++++ gdb/guile/guile-internal.h | 12 ++++++++++++ 4 files changed, 42 insertions(+) diff --git a/gdb/config.in b/gdb/config.in index 5c46567..cd4ce92 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -342,6 +342,9 @@ /* Define to 1 if you have the `sbrk' function. */ #undef HAVE_SBRK +/* Define to 1 if you have the `scm_new_smob' function. */ +#undef HAVE_SCM_NEW_SMOB + /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE diff --git a/gdb/configure b/gdb/configure index d7e5cef..56c92d3 100755 --- a/gdb/configure +++ b/gdb/configure @@ -9076,6 +9076,24 @@ $as_echo "#define HAVE_GUILE 1" >>confdefs.h CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_GUILE_SRCS)" CONFIG_INSTALL="$CONFIG_INSTALL install-guile" ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_GUILE_CFLAGS)" + + save_LIBS="$LIBS" + save_CPPFLAGS="$CPPFLAGS" + LIBS="$GUILE_LIBS" + CPPFLAGS="$GUILE_CPPFLAGS" + for ac_func in scm_new_smob +do : + ac_fn_c_check_func "$LINENO" "scm_new_smob" "ac_cv_func_scm_new_smob" +if test "x$ac_cv_func_scm_new_smob" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SCM_NEW_SMOB 1 +_ACEOF + +fi +done + + LIBS="$save_LIBS" + CPPFLAGS="$save_CPPFLAGS" else # Even if Guile support is not compiled in, we need to have these files # included. diff --git a/gdb/configure.ac b/gdb/configure.ac index ff84a2e..903f378 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1200,6 +1200,15 @@ if test "${have_libguile}" != no; then CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_GUILE_SRCS)" CONFIG_INSTALL="$CONFIG_INSTALL install-guile" ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_GUILE_CFLAGS)" + + dnl The 'scm_new_smob' function appeared in Guile 2.0.6. + save_LIBS="$LIBS" + save_CPPFLAGS="$CPPFLAGS" + LIBS="$GUILE_LIBS" + CPPFLAGS="$GUILE_CPPFLAGS" + AC_CHECK_FUNCS([scm_new_smob]) + LIBS="$save_LIBS" + CPPFLAGS="$save_CPPFLAGS" else # Even if Guile support is not compiled in, we need to have these files # included. diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index e2e1c01..ff891b5 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -97,6 +97,18 @@ typedef struct #define gdbscm_is_false(scm) scm_is_eq ((scm), SCM_BOOL_F) #define gdbscm_is_true(scm) (!gdbscm_is_false (scm)) +#ifndef HAVE_SCM_NEW_SMOB + +/* Guile <= 2.0.5 did not provide this function, so provide it here. */ + +static inline SCM +scm_new_smob (scm_t_bits tc, scm_t_bits data) +{ + SCM_RETURN_NEWSMOB (tc, data); +} + +#endif + /* Function name that is passed around in case an error needs to be reported. __func is in C99, but we provide a wrapper "just in case", and because FUNC_NAME is the canonical value used in guile sources.