summaryrefslogtreecommitdiff
path: root/mcon/U/d_fast_assert.U
blob: 10c60a04cfe212617b23f942b1a98fb662293660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
?RCS: $Id: d_fast_assert.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 2006, Christian Biere
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?MAKE:d_fast_assert: Myread Setvar cat gccversion spackage \
	sed +ccflags +cc +ldflags +optimize
?MAKE:	-pick add $@ %<
?S:d_fast_assert:
?S:	This variable conditionally defines FAST_ASSERTIONS.
?S:.
?C:FAST_ASSERTIONS:
?C:	This symbol, when defined, indicates that the program should make
?C:	use of its own asserting and failure reporting code, instead of
?C:	the one from GLib.
?C:.
?H:#$d_fast_assert FAST_ASSERTIONS	/**/
?H:.
?F:!try.c !try
?LINT:set d_fast_assert
?LINT:change ccflags
: determine whether to enable fast assertions
echo " "
case "$d_fast_assert" in
"$undef")
	dflt=n;;
*)
	dflt=y;;
esac
$cat <<EOM
$spackage contains code called "fast assertions" which are lightweight
assertions in terms of code space used.  They use much less code than
their GLib counterpart, and therefore should be more efficient.

EOM
rp='Shall I enable "fast assertions"'
. ./myread
case "$ans" in
y) val="$define";;
*) val="$undef";;
esac
set d_fast_assert
eval $setvar
?X: When gcc is used, see whether we can use -momit-leaf-frame-pointer
?X: This is useful for tail routines containing assertions if they use
?X: "fast assertions", given that the code is not calling any routine.
case "$gccversion" in
'') ;;
*)
	case "$d_fast_assert" in
	"$define")
		$cat >try.c <<'EOC'
int main()
{
	return 0;
}
EOC
	if $cc $ccflags -momit-leaf-frame-pointer $ldflags -o try try.c >/dev/null 2>&1
	then
		case "$ccflags $optimize" in
		*-momit-leaf-frame-pointer*) ;;
		*-O0*) ;;
		*-O*)
			ccflags="-momit-leaf-frame-pointer $ccflags"
			echo "Added -momit-leaf-frame-pointer to the cc flags." >&4
			;;
		esac
	else
		case "$ccflags" in
		*-momit-leaf-frame-pointer*)
			echo "Stripping -momit-leaf-frame-pointer from cc flags." >&4
			ccflags=`echo $ccflags | $sed 's/ *-momit-leaf-frame-pointer//'`
		;;
		esac
	fi
	;;
	esac
;;
esac