1 ?RCS: Copyright (c) 2006-2007, H.Merijn Brand
3 ?RCS: You may redistribute only under the terms of the Artistic License,
4 ?RCS: as specified in the README file that comes with the distribution.
5 ?RCS: You may reuse parts of this distribution only within the terms of
6 ?RCS: that same Artistic License; a copy of which may be found at the root
7 ?RCS: of the source tree for dist 3.0.
9 ?MAKE:d_builtin_choose_expr d_builtin_expect : Compile Setvar cat run rm_try
10 ?MAKE: -pick add $@ %<
11 ?S:d_builtin_choose_expr:
12 ?S: This conditionally defines HAS_BUILTIN_CHOOSE_EXPR, which
13 ?S: indicates that the compiler supports __builtin_choose_expr(x,y,z).
14 ?S: This built-in function is analogous to the "x?y:z" operator in C,
15 ?S: except that the expression returned has its type unaltered by
16 ?S: promotion rules. Also, the built-in function does not evaluate
17 ?S: the expression that was not chosen.
20 ?S: This conditionally defines HAS_BUILTIN_EXPECT, which indicates
21 ?S: that the compiler supports __builtin_expect(exp,c). You may use
22 ?S: __builtin_expect to provide the compiler with branch prediction
25 ?C:HAS_BUILTIN_CHOOSE_EXPR:
26 ?C: Can we handle GCC builtin for compile-time ternary-like expressions
28 ?C:HAS_BUILTIN_EXPECT:
29 ?C: Can we handle GCC builtin for telling that certain values are more
32 ?H:#$d_builtin_expect HAS_BUILTIN_EXPECT /**/
33 ?H:#$d_builtin_choose_expr HAS_BUILTIN_CHOOSE_EXPR /**/
36 ?LINT:set d_builtin_expect d_builtin_choose_expr
37 : Look for GCC-style __builtin_choose_expr
38 case "$d_builtin_choose_expr" in
41 echo "Checking whether your compiler can handle __builtin_choose_expr ..." >&4
47 #define SYRINX(x) __builtin_choose_expr( x, (1056*2), (103*50) )
50 assert( SYRINX(1) == 2112 );
51 assert( SYRINX(1) != 5150 );
52 assert( SYRINX(0) == 5150 );
53 assert( SYRINX(0) != 2112 );
60 if eval $compile && $run ./try; then
61 echo "Your C compiler supports __builtin_choose_expr."
64 echo "Your C compiler doesn't seem to understand __builtin_choose_expr."
68 *) val="$d_builtin_choose_expr" ;;
71 set d_builtin_choose_expr
75 : Look for GCC-style __builtin_expect
76 case "$d_builtin_expect" in
79 echo "Checking whether your compiler can handle __builtin_expect ..." >&4
83 if ( __builtin_expect(n, 0) ) n = 1;
84 /* Remember shell exit code truth is 0, C truth is non-zero */
89 if eval $compile && $run ./try; then
90 echo "Your C compiler supports __builtin_expect."
93 echo "Your C compiler doesn't seem to understand __builtin_expect."
97 *) val="$d_builtin_expect" ;;