Front page | perl.perl5.porters |
Postings from July 2010
Re: [PATCH] Configure probe for static inline
Thread Previous
|
Thread Next
From:
H.Merijn Brand
Date:
July 8, 2010 05:14
Subject:
Re: [PATCH] Configure probe for static inline
Message ID:
20100708141434.5d17e85a@pc09.procura.nl
On Tue, 6 Jul 2010 12:48:56 -0400 (EDT), Andy Dougherty
<doughera@lafayette.edu> wrote:
> Here is a proposed patch to enable Configure to probe for C99-style
> 'static inline'. (That is, functions may be inlined, but will not be
> externally visible.) The initial idea is that some common code in messy
> macros inside headers might be simplified using inline functions. If the
> compiler does not support 'static inline', then a plain 'static' is used
> instead, along with the consequent implications of a function call. In
> either case, you simply use PERL_STATIC_INLINE.
I suggest just committing this and see how smokes react
> I'd appreciate it if folks could give this a try and let me know of any
> problems. (Specifically, after you run Configure as usual, grep for
> 'd_static_inline' in config.sh and see if it matches what you think it
> should be.)
>
> This patch does not *use* this facility at all yet. It is merely a
> Configure patch to make the facility availble for others to experiment
> with.
>
> Finally, before actually converting anything to inline functions, please
> try to carefully evaluate the performance implications of any proposed
> changes. Compilers vary in what they will and will not convert to inline
> functions, so it's worth proceeding slowly and carefully.
>
> This patch results from a single new metaconfig unit, d_static_inline.U,
> which I have attached. If there are no problems reported, I'll push that
> unit to the metaconfig repository later this week.
>
> diff -r -u perl-git/Configure perl-andy/Configure
> --- perl-git/Configure 2010-06-30 12:27:44.000000000 -0400
> +++ /home/doughera/src/kepler/perl/perl-git/Configure 2010-07-06 11:29:52.000000000 -0400
> @@ -30,7 +30,7 @@
>
> # $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
> #
> -# Generated on Wed Jun 23 16:03:55 CEST 2010 [metaconfig 3.5 PL0]
> +# Generated on Tue Jul 6 11:29:50 EDT 2010 [metaconfig 3.5 PL0]
> # (with additional metaconfig patches by perlbug@perl.org)
>
> cat >c1$$ <<EOF
> @@ -748,6 +749,7 @@
> d_statblks=''
> d_statfs_f_flags=''
> d_statfs_s=''
> +d_static_inline=''
> d_fstatvfs=''
> d_statvfs=''
> d_stdio_cnt_lval=''
> @@ -17874,6 +17903,70 @@
> *) echo "No, it doesn't." ;;
> esac
>
> +: see if static inline is supported
> +echo " "
> +$cat > try.c <<'EOCP'
> +#include <stdlib.h>
> +extern int f_via_a(int x);
> +extern int f_via_b(int x);
> +int main(int argc, char **argv)
> +{
> + int y;
> +
> + y = f_via_a(0);
> +#ifdef USE_B
> + y = f_via_b(0);
> +#endif
> + if (y == 42) {
> + return EXIT_SUCCESS;
> + }
> + else {
> + return EXIT_FAILURE;
> + }
> +}
> +EOCP
> +$cat > a.c <<'EOCP'
> +static inline int f(int x) {
> + int y;
> + y = x + 42;
> + return y;
> +}
> +
> +int f_via_a(int x)
> +{
> + return f(x);
> +}
> +EOCP
> +$cat > b.c <<'EOCP'
> +extern int f(int x);
> +
> +int f_via_b(int x)
> +{
> + return f(x);
> +}
> +EOCP
> +val="$undef"
> +set try a.c
> +if eval $compile && $run ./try; then
> + # Now make sure there is no external linkage of static
> + # functions
> + set try -DUSE_B a.c b.c
> + if eval $compile && $run ./try; then
> + $echo "Your compiler supports static inline, " >&4
> + $echo "but it also creates an external definition," >&4
> + $echo "so I won't use it." >&4
> + val=$undef
> + else
> + $echo "Your compiler supports static inline." >&4
> + val=$define
> + fi
> +else
> + $echo "Your compiler does NOT support static inline." >&4
> + val="$undef"
> +fi
> +set d_static_inline
> +eval $setvar
> +
> : Check stream access
> $cat >&4 <<EOM
> Checking how to access stdio streams by file descriptor number...
> @@ -22716,6 +22825,7 @@
> d_statblks='$d_statblks'
> d_statfs_f_flags='$d_statfs_f_flags'
> d_statfs_s='$d_statfs_s'
> +d_static_inline='$d_static_inline'
> d_statvfs='$d_statvfs'
> d_stdio_cnt_lval='$d_stdio_cnt_lval'
> d_stdio_ptr_lval='$d_stdio_ptr_lval'
> diff -r -u perl-git/perl.h perl-andy/perl.h
> --- perl-git/perl.h 2010-07-06 09:29:45.000000000 -0400
> +++ /home/doughera/src/kepler/perl/perl-git/perl.h 2010-07-06 10:20:43.000000000 -0400
> @@ -140,6 +140,12 @@
> # define EXTERN_C extern
> #endif
>
> +#ifdef HAS_STATIC_INLINE
> +# define PERL_STATIC_INLINE static inline
> +#else
> +# define PERL_STATIC_INLINE static
> +#endif
> +
> #ifdef PERL_GLOBAL_STRUCT
> # ifndef PERL_GET_VARS
> # ifdef PERL_GLOBAL_STRUCT_PRIVATE
> diff -r -u perl-git/config_h.SH perl-andy/config_h.SH
> --- perl-git/config_h.SH 2010-06-30 12:27:45.000000000 -0400
> +++ /home/doughera/src/kepler/perl/perl-git/config_h.SH 2010-07-06 11:37:24.000000000 -0400
> @@ -536,6 +536,13 @@
> */
> #$d_setsid HAS_SETSID /**/
>
> +/* HAS_STATIC_INLINE:
> + * This symbol, if defined, indicates that the C compiler supports
> + * supports C99-style static inline. That is, the function can't
> + * be called from another translation unit.
> + */
> +#$d_static_inline HAS_STATIC_INLINE /**/
> +
> /* HAS_STRCHR:
> * This symbol is defined to indicate that the strchr()/strrchr()
> * functions are available for string searching. If not, try the
>
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Thread Previous
|
Thread Next