next up previous contents
Next: Under the hood Up: Meters Previous: Two rate three color   Contents


Accelerating three color meters

Color test macros are frequently used as shown in the example in section 2.13.5, e.g.

In this case, an alternative set of macros can be used, which exploits this regularity, and which is easier to process for tcc. These macros have the same names as the regular color test macros, but a double underscore (__) is added before these names.

Example:

#include "fields.tc"
#include "meters.tc"

$m = trTCM(cir 1Mbps,cbs 100kB,pir 10Mbps,pbs 40kB);
...
    class if ip_dst:8 == 10.0.0.0 && __trTCM_green($m);
    class if ip_dst:8 == 10.0.0.0 && __trTCM_yellow($m);
    class if ip_dst:8 == 10.0.0.0 && __trTCM_red($m);
...

Note that these macros will produce incorrect results if the constrains listed above are not followed. Also, the accelerated macros cannot be mixed with their non-accelerated counterparts.



Martin A. Brown 2003-11-06