This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Subject: optimize matching -g still enables -DDEBUGING
[metaconfig.git] / U / perl / d_builtin.U
index f66b3fa..28e3379 100644 (file)
@@ -1,4 +1,4 @@
-?RCS: Copyright (c) 2006-2006, H.Merijn Brand
+?RCS: Copyright (c) 2006-2007, H.Merijn Brand
 ?RCS:
 ?RCS: You may redistribute only under the terms of the Artistic Licence,
 ?RCS: as specified in the README file that comes with the distribution.
@@ -6,7 +6,7 @@
 ?RCS: that same Artistic Licence; a copy of which may be found at the root
 ?RCS: of the source tree for dist 3.0.
 ?RCS:
-?MAKE:d_builtin_choose_expr d_builtin_expect : Compile Setvar cat rm
+?MAKE:d_builtin_choose_expr d_builtin_expect : Compile Setvar cat run rm_try
 ?MAKE: -pick add $@ %<
 ?S:d_builtin_choose_expr:
 ?S:    This conditionally defines HAS_BUILTIN_CHOOSE_EXPR, which
@@ -32,6 +32,7 @@
 ?H:#$d_builtin_expect HAS_BUILTIN_EXPECT       /**/
 ?H:#$d_builtin_choose_expr HAS_BUILTIN_CHOOSE_EXPR     /**/
 ?H:.
+?F:!try
 ?LINT:set d_builtin_expect d_builtin_choose_expr
 : Look for GCC-style __builtin_choose_expr
 case "$d_builtin_choose_expr" in
@@ -56,7 +57,7 @@ int main(void) {
 
 EOCP
     set try
-    if eval $compile; then
+    if eval $compile && $run ./try; then
        echo "Your C compiler supports __builtin_choose_expr."
        val="$define"
     else
@@ -69,25 +70,27 @@ esac
 
 set d_builtin_choose_expr
 eval $setvar
-$rm -f try.* try core core.try.*
+$rm_try
 
 : Look for GCC-style __builtin_expect
 case "$d_builtin_expect" in
 '')
     echo " "
     echo "Checking whether your compiler can handle __builtin_expect ..." >&4
-    $cat >builtin.c <<'EOCP'
+    $cat >try.c <<'EOCP'
 int main(void) {
     int n = 50;
     if ( __builtin_expect(n, 0) ) n = 1;
+    /* Remember shell exit code truth is 0, C truth is non-zero */
+    return !(n == 1);
 }
 EOCP
     set try
-    if eval $compile; then
-       echo "Your C compiler supports __builtin_choose_expr."
+    if eval $compile && $run ./try; then
+       echo "Your C compiler supports __builtin_expect."
        val="$define"
     else
-       echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
+       echo "Your C compiler doesn't seem to understand __builtin_expect."
        val="$undef"
     fi
     ;;
@@ -96,5 +99,5 @@ esac
 
 set d_builtin_expect
 eval $setvar
-$rm -f try.* try core core.try.*
+$rm_try