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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
# ! is "expensive" ------------------------------------------------------------
tcc -c -Wexpensive -Wexperror 2>&1
prio {
class if !(raw[0] == 1);
}
EOF
ERROR
<stdin>:2: "!" is an "expensive" operation
# != is "expensive" -----------------------------------------------------------
tcc -c -Wexpensive -Wexperror 2>&1
prio {
class if raw[0] != 1;
}
EOF
ERROR
<stdin>:2: "!=" is an "expensive" operation
# > is "expensive" ------------------------------------------------------------
tcc -c -Wexpensive -Wexperror 2>&1
prio {
class if raw[0] > 1;
}
EOF
ERROR
<stdin>:2: ">" is an "expensive" operation
# >= is "expensive" -----------------------------------------------------------
tcc -c -Wexpensive -Wexperror 2>&1
prio {
class if raw[0] >= 2;
}
EOF
ERROR
<stdin>:2: ">=" is an "expensive" operation
# not self-contained action tree is "expensive" -------------------------------
tcc -xif:err -Wexpensive -Wexperror -Xx,nounspec 2>&1 >/dev/null
$p = police(rate 1Mbps,burst 2kB);
prio {
class if conform $p;
}
EOF
ERROR
<stdin>:3: policing expressions not always leading to a decision are "expensive"
# self-contained action tree is not "expensive" -------------------------------
tcc -xif:err -Wexpensive -Wexperror >/dev/null 2>/dev/null
$p = police(rate 1Mbps,burst 2kB);
prio {
class if raw[0] == 1 && (conform $p || drop);
}
EOF
# "light-weight" multi-color markers are not "expensive" (srTCM) --------------
tcc -xif:err -Wexpensive -Wexperror >/dev/null 2>/dev/null
#include "meters.tc"
set_srTCM($x,cir 1 kbps,cbs 1kB,ebs 500B,mtu 1000B);
#define C (raw[0] == 1 || raw[0] == 2)
prio {
class (1) if C && __srTCM_green($x);
class (2) if C && __srTCM_yellow($x);
class (3) if C && __srTCM_red($x);
}
EOF
# "light-weight" multi-color markers are not "expensive" (trTCM) --------------
tcc -xif:err -Wexpensive -Wexperror >/dev/null 2>/dev/null
#include "meters.tc"
set_trTCM($x,cir 1 kbps,cbs 1kB,pir 2kbps,pbs 500B);
#define C (raw[0] == 1 || raw[0] == 2)
prio {
class (1) if C && __trTCM_green($x);
class (2) if C && __trTCM_yellow($x);
class (3) if C && __trTCM_red($x);
}
EOF
# -Wexpensive: each operation is reported once --------------------------------
tcc -c -Wexpensive 2>&1
prio {
class if !(raw[0] == 1) || raw[1] != 2 || raw[2] > 3 || raw[3] >= 4;
class if !(raw[3] == 1) || raw[2] != 2 || raw[1] > 3 || raw[0] >= 4;
}
EOF
<stdin>:2: warning: "!" is an "expensive" operation
<stdin>:2: warning: "!=" is an "expensive" operation
<stdin>:2: warning: ">" is an "expensive" operation
<stdin>:2: warning: ">=" is an "expensive" operation
# -Wexpensive: each expression is reported once -------------------------------
tcc -xif:err -Wexpensive -Xx,nounspec 2>&1 | grep warning
$p = police(rate 1Mbps,burst 2kB);
$q = police(rate 1Mbps,burst 2kB);
prio {
class if conform $p;
class if conform $q;
}
EOF
<stdin>:4: warning: policing expressions not always leading to a decision are "expensive"
|