From: Marcus Holland-Moritz Date: Mon, 3 Nov 2008 22:40:11 +0000 (+0100) Subject: Add prototype detection for NDBM header files X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e74475c7f7d5be6b248e4c69480e5336325d067b;p=p5sagit%2Fp5-mst-13.2.git Add prototype detection for NDBM header files Message-ID: <20081103224011.26c223b3@r2d2> p4raw-id: //depot/perl@34756 --- diff --git a/Configure b/Configure index aa005d5..9ce8680 100755 --- a/Configure +++ b/Configure @@ -25,7 +25,7 @@ # $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $ # -# Generated on Wed Oct 29 09:08:09 CET 2008 [metaconfig 3.5 PL0] +# Generated on Thu Nov 6 21:06:19 CET 2008 [metaconfig 3.5 PL0] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ <" + val="$undef" + ;; + *) val="$define" + ;; + esac +fi +set d_ndbm +eval $setvar + +ndbm_hdr_protochk='name=$1; hdr=$2; +eval "ihdr=\$""i_$name"; +val="$undef"; +if $test "$ihdr" = "$define"; then + $echo "Checking if your <$hdr> uses prototypes..." >&4; + case "$d_cplusplus" in + $define) ./protochk "$extern_C void dbm_close(DBM *);" literal "extern \"C\" {" $ihdr $hdr literal "}" && val="$define" ;; + *) ./protochk "$extern_C void dbm_close(int, int);" $ihdr $hdr || val="$define" ;; + esac; + case "$val" in + $define) $echo "Your <$hdr> seems to have prototypes";; + *) $echo "Your <$hdr> does not seem to have prototypes";; + esac; +fi; +set "d_${name}_h_uses_prototypes"; +eval $setvar' + +set ndbm ndbm.h +eval $ndbm_hdr_protochk +set gdbmndbm gdbm/ndbm.h +eval $ndbm_hdr_protochk +set gdbm_ndbm gdbm-ndbm.h +eval $ndbm_hdr_protochk + : see if getcwd exists set getcwd d_getcwd eval $inlibc @@ -21044,35 +21101,6 @@ val="$t_gdbm" set i_gdbm eval $setvar -: see if ndbm.h is available -set ndbm.h i_ndbm -eval $inhdr -: Compatibility location for RedHat 7.1 -set gdbm/ndbm.h i_gdbmndbm -eval $inhdr -: Compatibility location for Debian 4.0 -set gdbm-ndbm.h i_gdbm_ndbm -eval $inhdr - -if $test "$i_ndbm" = "$define" -o "$i_gdbmndbm" = "$define" -o "$i_gdbm_ndbm" = "$define"; then - : see if dbm_open exists - set dbm_open d_dbm_open - eval $inlibc - case "$d_dbm_open" in - $undef) - i_ndbm="$undef" - i_gdbmndbm="$undef" - i_gdbm_ndbm="$undef" - echo "We won't be including " - val="$undef" - ;; - *) val="$define" - ;; - esac -fi -set d_ndbm -eval $setvar - : see if this is a ieeefp.h system case "$i_ieeefp" in '' ) set ieeefp.h i_ieeefp @@ -22198,6 +22226,8 @@ d_fsync='$d_fsync' d_ftello='$d_ftello' d_ftime='$d_ftime' d_futimes='$d_futimes' +d_gdbm_ndbm_h_uses_prototypes='$d_gdbm_ndbm_h_uses_prototypes' +d_gdbmndbm_h_uses_prototypes='$d_gdbmndbm_h_uses_prototypes' d_getcwd='$d_getcwd' d_getespwnam='$d_getespwnam' d_getfsstat='$d_getfsstat' @@ -22322,6 +22352,7 @@ d_msync='$d_msync' d_munmap='$d_munmap' d_mymalloc='$d_mymalloc' d_ndbm='$d_ndbm' +d_ndbm_h_uses_prototypes='$d_ndbm_h_uses_prototypes' d_nice='$d_nice' d_nl_langinfo='$d_nl_langinfo' d_nv_preserves_uv='$d_nv_preserves_uv' diff --git a/Porting/Glossary b/Porting/Glossary index 42cfc0f..8f0cdce 100644 --- a/Porting/Glossary +++ b/Porting/Glossary @@ -876,6 +876,24 @@ d_Gconvert (d_gconvert.U): call-back unit so that long doubles can be formatted without loss of precision. +d_gdbm_ndbm_h_uses_prototypes (i_ndbm.U): + This variable conditionally defines the NDBM_H_USES_PROTOTYPES symbol, + which indicates that the gdbm-ndbm.h include file uses real ANSI C + prototypes instead of K&R style function declarations. K&R style + declarations are unsupported in C++, so the include file requires + special handling when using a C++ compiler and this variable is + undefined. Consult the different d_*ndbm_h_uses_prototypes variables + to get the same information for alternative ndbm.h include files. + +d_gdbmndbm_h_uses_prototypes (i_ndbm.U): + This variable conditionally defines the NDBM_H_USES_PROTOTYPES symbol, + which indicates that the gdbm/ndbm.h include file uses real ANSI C + prototypes instead of K&R style function declarations. K&R style + declarations are unsupported in C++, so the include file requires + special handling when using a C++ compiler and this variable is + undefined. Consult the different d_*ndbm_h_uses_prototypes variables + to get the same information for alternative ndbm.h include files. + d_getcwd (d_getcwd.U): This variable conditionally defines the HAS_GETCWD symbol, which indicates to the C program that the getcwd() routine is available @@ -1461,6 +1479,15 @@ d_ndbm (i_ndbm.U): header file but not the library. This variable will only be set if the system has both. +d_ndbm_h_uses_prototypes (i_ndbm.U): + This variable conditionally defines the NDBM_H_USES_PROTOTYPES symbol, + which indicates that the ndbm.h include file uses real ANSI C + prototypes instead of K&R style function declarations. K&R style + declarations are unsupported in C++, so the include file requires + special handling when using a C++ compiler and this variable is + undefined. Consult the different d_*ndbm_h_uses_prototypes variables + to get the same information for alternative ndbm.h include files. + d_nice (d_nice.U): This variable conditionally defines the HAS_NICE symbol, which indicates to the C program that the nice() routine is available. diff --git a/config_h.SH b/config_h.SH index ad65bdf..a01f274 100644 --- a/config_h.SH +++ b/config_h.SH @@ -2420,9 +2420,30 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un * be included. This is the location of the ndbm.h compatibility file * in Debian 4.0. */ +/* NDBM_H_USES_PROTOTYPES: + * This symbol, if defined, indicates that uses real ANSI C + * prototypes instead of K&R style function declarations without any + * parameter information. While ANSI C prototypes are supported in C++, + * K&R style function declarations will yield errors. + */ +/* GDBMNDBM_H_USES_PROTOTYPES: + * This symbol, if defined, indicates that uses real ANSI C + * prototypes instead of K&R style function declarations without any + * parameter information. While ANSI C prototypes are supported in C++, + * K&R style function declarations will yield errors. + */ +/* GDBM_NDBM_H_USES_PROTOTYPES: + * This symbol, if defined, indicates that uses real ANSI C + * prototypes instead of K&R style function declarations without any + * parameter information. While ANSI C prototypes are supported in C++, + * K&R style function declarations will yield errors. + */ #$i_ndbm I_NDBM /**/ #$i_gdbmndbm I_GDBMNDBM /**/ #$i_gdbm_ndbm I_GDBM_NDBM /**/ +#$d_ndbm_h_uses_prototypes NDBM_H_USES_PROTOTYPES /**/ +#$d_gdbmndbm_h_uses_prototypes GDBMNDBM_H_USES_PROTOTYPES /**/ +#$d_gdbm_ndbm_h_uses_prototypes GDBM_NDBM_H_USES_PROTOTYPES /**/ /* I_NETDB: * This symbol, if defined, indicates that exists and diff --git a/ext/NDBM_File/Makefile.PL b/ext/NDBM_File/Makefile.PL index dc5cc44..7b58601 100644 --- a/ext/NDBM_File/Makefile.PL +++ b/ext/NDBM_File/Makefile.PL @@ -1,16 +1,7 @@ -use Config; use ExtUtils::MakeMaker; - -my $define = ""; - -if($Config{i_gdbm} && $Config{i_gdbm} eq 'define') { - $define .= " -DHAS_GDBM"; -} - WriteMakefile( NAME => 'NDBM_File', LIBS => ["-L/usr/local/lib -lndbm", "-ldbm -lucb"], - DEFINE => $define, MAN3PODS => {}, # Pods will be built by installman. XSPROTOARG => '-noprototypes', # XXX remove later? VERSION_FROM => 'NDBM_File.pm', diff --git a/ext/NDBM_File/NDBM_File.xs b/ext/NDBM_File/NDBM_File.xs index 5e08330..add9796 100644 --- a/ext/NDBM_File/NDBM_File.xs +++ b/ext/NDBM_File/NDBM_File.xs @@ -1,12 +1,22 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#undef NDBM_HEADER_USES_PROTOTYPES #if defined(I_GDBM_NDBM) # include /* Debian compatibility version */ +# ifdef GDBM_NDBM_H_USES_PROTOTYPES +# define NDBM_HEADER_USES_PROTOTYPES +# endif #elif defined(I_GDBMNDBM) # include /* RedHat compatibility version */ +# ifdef GDBMNDBM_H_USES_PROTOTYPES +# define NDBM_HEADER_USES_PROTOTYPES +# endif #elif defined(I_NDBM) -#include +# include +# ifdef NDBM_H_USES_PROTOTYPES +# define NDBM_HEADER_USES_PROTOTYPES +# endif #endif typedef struct { @@ -23,7 +33,7 @@ typedef datum datum_key ; typedef datum datum_value ; -#if defined(__cplusplus) && defined(HAS_GDBM) +#if defined(__cplusplus) && !defined(NDBM_HEADER_USES_PROTOTYPES) /* gdbm's header file used for compatibility with gdbm */ /* isn't compatible to C++ syntax, so we need these */ /* declarations to make everyone happy. */