########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2011 AT&T Intellectual Property #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
# @(#)math.sh (AT&T Research) 2010-10-26
command=$0
iffeflags="-n -v"
iffelibs="-lm"
eval $1
shift
table=$1
: check long double
eval `iffe $iffeflags -F ast_standards.h -c "$cc" - tst use_ast_standards -lm 'note{' 'math.h needs ast_standards.h' '}end' 'link{' '#include <math.h>' '#ifndef isgreater' '#define isgreater(a,b) 0' '#endif' 'int main() { return isgreater(0.0,1.0); }' '}end'`
case $_use_ast_standards in
esac
eval `iffe $iffeflags -c "$cc" - tst use_ieeefp -lm 'note{' 'ieeefp.h plays nice' '}end' 'link{' '#include <math.h>' '#include <ieeefp.h>' 'int main() { return 0; }' '}end'`
case $_use_ieeefp in
esac
exec < $table
libs=
nums=
case $_typ_long_double in
esac
do case $a in
'{'*) break
;;
*=*) IFS='=|'
set $a
*,$1,*) ;;
case $_typ_long_double in
esac
;;
esac
shift
while :
do case $# in
0) break ;;
esac
*,$1,*) ;;
esac
shift
done
;;
esac
done
;;
esac
done
lib=
case $x in
esac
case $y in
1) case $x in
esac
;;
esac
done
cat <<!
#pragma prototyped
!
case $_use_ast_standards in
1) echo "#include <ast_standards.h>" ;;
esac
echo "#include <math.h>"
case $_hdr_ieeefp in
1) echo "#include <ieeefp.h>" ;;
esac
echo
nl='
'
ht=' '
tab=
case $r in
i) L=int R=1 ;;
x) L=Sfdouble_t R=4 ;;
*) L=Sfdouble_t R=0 ;;
esac
case $x:$y in
1:*) f=${name}l
local=
;;
*:1) f=${name}
t=double
local=$_typ_long_double
;;
*) body=
continue
;;
esac
case $k in
'{'*) body=$k
;;
*=*) IFS='=|'
set $k
f=$1
shift
v=$*
case $x:$y in
1:*) f=${f}l
;;
*:1) ;;
*) continue
;;
esac
y=
while :
do case $# in
0) break ;;
esac
case $x in
1) case $y in
?*) y="$y || " ;;
esac
y="${y}q == $1"
;;
esac
shift
done
case $y in
'') ;;
*) r=int R=1
echo "static $r $F(Sfdouble_t a1) { $r q = $f(a1); return $y; }"
break
;;
esac
;;
esac
done
?*) code="static $L $F("
sep=
ta=
tc=
td=
do case $R:$p in
4:2) T=int ;;
*) T=Sfdouble_t ;;
esac
td="${td}$T a$p;"
case $a in
$p) break ;;
esac
sep=","
done
eval `iffe $iffeflags -c "$cc" - tst it_links_ note{ $F function links }end link{ "static $L $F($ta)$td${body}int main(){return $F($tc)!=0;}" }end sfio.h $iffehdrs $iffelibs 2>&$stderr`
case $_it_links_ in
echo "$code"
;;
esac
;;
esac
continue
;;
esac
case $r in
i) r=int ;;
*) r=$t ;;
esac
case $d:$m:$n in
1:*:*|*:1:*)
;;
*:*:1) code="extern $r $f("
sep=
for p in 1 2 3 4 5 6 7
case $a in
$p) break ;;
esac
sep=","
done
echo "$code"
;;
esac
1:*:*:*|*:1:*:*|*:*:1:)
args=
code="static $L local_$f("
sep=
for p in 1 2 3 4 5 6 7 8 9
case $R:$p in
4:2) T=int ;;
*) T=Sfdouble_t ;;
esac
case $a in
$p) break ;;
esac
sep=","
done
echo "$code"
f=local_$f
;;
esac
do case $x in
'{'*) break
;;
*=*) continue
;;
esac
done
done
cat <<!
/*
*/
const struct mathtab shtab_math[] =
{$tab
};
!