Use $((...)) instead of expr.
Use $((...)) for math in size_classes.h rather than expr, because it is much faster. This is not supported syntax in the classic Bourne shell, but all modern sh implementations support it, including bash, zsh, and ash.
This commit is contained in:
parent
9d4d76874d
commit
12a6845b6c
@ -17,8 +17,8 @@ pow2() {
|
|||||||
e=$1
|
e=$1
|
||||||
pow2_result=1
|
pow2_result=1
|
||||||
while [ ${e} -gt 0 ] ; do
|
while [ ${e} -gt 0 ] ; do
|
||||||
pow2_result=`expr ${pow2_result} + ${pow2_result}`
|
pow2_result=$((${pow2_result} + ${pow2_result}))
|
||||||
e=`expr ${e} - 1`
|
e=$((${e} - 1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ EOF
|
|||||||
bin=0
|
bin=0
|
||||||
psz=0
|
psz=0
|
||||||
sz=${t}
|
sz=${t}
|
||||||
delta=`expr ${sz} - ${psz}`
|
delta=$((${sz} - ${psz}))
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
/* SIZE_CLASS(bin, delta, sz) */
|
/* SIZE_CLASS(bin, delta, sz) */
|
||||||
#define SIZE_CLASSES \\
|
#define SIZE_CLASSES \\
|
||||||
@ -56,30 +56,30 @@ EOF
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
|
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
|
||||||
EOF
|
EOF
|
||||||
bin=`expr ${bin} + 1`
|
bin=$((${bin} + 1))
|
||||||
psz=${sz}
|
psz=${sz}
|
||||||
sz=`expr ${sz} + ${sz}`
|
sz=$((${sz} + ${sz}))
|
||||||
delta=`expr ${sz} - ${psz}`
|
delta=$((${sz} - ${psz}))
|
||||||
done
|
done
|
||||||
# Quantum-multiple size classes. For each doubling of sz, as many as 4
|
# Quantum-multiple size classes. For each doubling of sz, as many as 4
|
||||||
# size classes exist. Their spacing is the greater of:
|
# size classes exist. Their spacing is the greater of:
|
||||||
# - q
|
# - q
|
||||||
# - sz/4, where sz is a power of 2
|
# - sz/4, where sz is a power of 2
|
||||||
while [ ${sz} -lt ${p} ] ; do
|
while [ ${sz} -lt ${p} ] ; do
|
||||||
if [ ${sz} -ge `expr ${q} \* 4` ] ; then
|
if [ ${sz} -ge $((${q} * 4)) ] ; then
|
||||||
i=`expr ${sz} / 4`
|
i=$((${sz} / 4))
|
||||||
else
|
else
|
||||||
i=${q}
|
i=${q}
|
||||||
fi
|
fi
|
||||||
next_2pow=`expr ${sz} \* 2`
|
next_2pow=$((${sz} * 2))
|
||||||
while [ ${sz} -lt $next_2pow ] ; do
|
while [ ${sz} -lt $next_2pow ] ; do
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
|
SIZE_CLASS(${bin}, ${delta}, ${sz}) \\
|
||||||
EOF
|
EOF
|
||||||
bin=`expr ${bin} + 1`
|
bin=$((${bin} + 1))
|
||||||
psz=${sz}
|
psz=${sz}
|
||||||
sz=`expr ${sz} + ${i}`
|
sz=$((${sz} + ${i}))
|
||||||
delta=`expr ${sz} - ${psz}`
|
delta=$((${sz} - ${psz}))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@ -89,11 +89,11 @@ EOF
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
lg_p=`expr ${lg_p} + 1`
|
lg_p=$((${lg_p} + 1))
|
||||||
done
|
done
|
||||||
lg_t=`expr ${lg_t} + 1`
|
lg_t=$((${lg_t} + 1))
|
||||||
done
|
done
|
||||||
lg_q=`expr ${lg_q} + 1`
|
lg_q=$((${lg_q} + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user