diff options
author | Marcus Holland-Moritz <mhx-perl@gmx.net> | 2008-11-03 23:40:11 +0100 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2008-11-06 20:18:08 +0000 |
commit | e74475c7f7d5be6b248e4c69480e5336325d067b (patch) | |
tree | c26bc9eec1d1bb6ca5c4115cf3b28f0e97abb993 | |
parent | 24d786f4d2806834028ce32abc1769da2e945f9b (diff) | |
download | perl-e74475c7f7d5be6b248e4c69480e5336325d067b.tar.gz |
Add prototype detection for NDBM header files
Message-ID: <20081103224011.26c223b3@r2d2>
p4raw-id: //depot/perl@34756
-rwxr-xr-x | Configure | 91 | ||||
-rw-r--r-- | Porting/Glossary | 27 | ||||
-rw-r--r-- | config_h.SH | 21 | ||||
-rw-r--r-- | ext/NDBM_File/Makefile.PL | 9 | ||||
-rw-r--r-- | ext/NDBM_File/NDBM_File.xs | 14 |
5 files changed, 121 insertions, 41 deletions
@@ -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$$ <<EOF @@ -881,7 +881,10 @@ i_mallocmalloc='' i_math='' i_memory='' i_mntent='' +d_gdbm_ndbm_h_uses_prototypes='' +d_gdbmndbm_h_uses_prototypes='' d_ndbm='' +d_ndbm_h_uses_prototypes='' i_gdbm_ndbm='' i_gdbmndbm='' i_ndbm='' @@ -13283,6 +13286,60 @@ else fi $rm_try +: 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 + +val="$undef" +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 <ndbm.h>" + 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 <ndbm.h>" - 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 42cfc0ff02..8f0cdcec96 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 ad65bdfdc7..a01f274fda 100644 --- a/config_h.SH +++ b/config_h.SH @@ -2420,9 +2420,30 @@ sed <<!GROK!THIS! >$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 <ndbm.h> 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 <gdbm/ndbm.h> 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 <gdbm-ndbm.h> 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 <netdb.h> exists and diff --git a/ext/NDBM_File/Makefile.PL b/ext/NDBM_File/Makefile.PL index dc5cc447fb..7b586017d7 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 5e08330933..add9796ecf 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 <gdbm-ndbm.h> /* Debian compatibility version */ +# ifdef GDBM_NDBM_H_USES_PROTOTYPES +# define NDBM_HEADER_USES_PROTOTYPES +# endif #elif defined(I_GDBMNDBM) # include <gdbm/ndbm.h> /* RedHat compatibility version */ +# ifdef GDBMNDBM_H_USES_PROTOTYPES +# define NDBM_HEADER_USES_PROTOTYPES +# endif #elif defined(I_NDBM) -#include <ndbm.h> +# include <ndbm.h> +# 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. */ |