void assist (char const * name, char const * type, struct _code_ const list [], size_t size) { extern char const * program_name; fprintf (stderr, "%s: ", program_name); fprintf (stderr, "%s: ", strerror (ENOTSUP)); if (name) { fprintf (stderr, "Have %s '%s' but need %s ", type, name, type); } else { fprintf (stderr, "Need %s ", type); } codelist (list, size, ",", "''", stderr); fprintf (stderr, ".\n"); exit (1); }
void assist(struct _code_ const list[], size_t size, char const * name, char const * type, FILE * fp) { extern char const * program_name; fprintf (fp, "%s: ", program_name); fprintf (fp, "%s: ", strerror(EINVAL)); if (name) { fprintf (fp, "Have %s '%s' but need ", type, name); } else { fprintf (fp, "Need %s ", type); } codelist (list, size, "''", ",", fp); fprintf (fp, ".\n"); exit (1); }
int main (int argc, char const * argv []) { extern struct channel channel; static char const * optv [] = { "ei:qrst:T:vV:", "action operand condition [...] control volatility [device] [...]\n\n where a condition is: field operator value", "Qualcomm Atheros Stream MakeRules Utility", "e\tredirect stderr to stdout", #if defined (WINPCAP) || defined (LIBPCAP) "i n\thost interface is (n) [" LITERAL (CHANNEL_ETHNUMBER) "]", #else "i s\thost interface is (s) [" LITERAL (CHANNEL_ETHDEVICE) "]", #endif "q\tquiet mode", "r\tread rules from device", "s\tdisplay symbol tables", "t n\tread timeout is (n) milliseconds [" LITERAL (CHANNEL_TIMEOUT) "]", "T x\tinserted vlan tag is x [" LITERAL (PLCRULE_VLAN_TAG) "]", "v\tverbose mode", "V n\tcspec version is n [" LITERAL (PLCRULE_CSPEC_VERSION) "]", (char const *) (0) }; #include "../plc/plc.c" struct cspec cspec; struct MMERule rule; signed c; memset (& rule, 0, sizeof (rule)); memset (& cspec, 0, sizeof (cspec)); cspec.VLAN_TAG = PLCRULE_VLAN_TAG; cspec.CSPEC_VERSION = PLCRULE_CSPEC_VERSION; if (getenv (PLCDEVICE)) { #if defined (WINPCAP) || defined (LIBPCAP) channel.ifindex = atoi (getenv (PLCDEVICE)); #else channel.ifname = strdup (getenv (PLCDEVICE)); #endif } optind = 1; while (~ (c = getoptv (argc, argv, optv))) { switch (c) { case 'e': dup2 (STDOUT_FILENO, STDERR_FILENO); break; case 'i': #if defined (WINPCAP) || defined (LIBPCAP) channel.ifindex = atoi (optarg); #else channel.ifname = optarg; #endif break; case 'q': _setbits (channel.flags, CHANNEL_SILENCE); _setbits (plc.flags, PLC_SILENCE); break; case 'r': _setbits (plc.flags, PLC_ANALYSE); break; case 's': printf ("\n"); printf (" Controls are "); codelist (controls, SIZEOF (controls), COMMA, QUOTE, stdout); printf (".\n"); printf (" Volatilities are "); codelist (volatilities, SIZEOF (volatilities), COMMA, QUOTE, stdout); printf (".\n"); printf (" Actions are "); codelist (actions, SIZEOF (actions), COMMA, QUOTE, stdout); printf (".\n"); printf (" Operands are "); codelist (operands, SIZEOF (operands), COMMA, QUOTE, stdout); printf (".\n"); printf (" Fields are "); codelist (fields, SIZEOF (fields), COMMA, QUOTE, stdout); printf (".\n"); printf (" Operators are "); codelist (operators, SIZEOF (operators), COMMA, QUOTE, stdout); printf (".\n"); printf (" States are "); codelist (states, SIZEOF (states), COMMA, QUOTE, stdout); printf (".\n"); printf ("\n"); return (0); case 't': channel.timeout = (signed) (uintspec (optarg, 0, UINT_MAX)); break; case 'T': cspec.VLAN_TAG = (uint32_t) (basespec (optarg, 16, sizeof (cspec.VLAN_TAG))); cspec.VLAN_TAG = htonl (cspec.VLAN_TAG); break; case 'v': _setbits (channel.flags, CHANNEL_VERBOSE); _setbits (plc.flags, PLC_VERBOSE); break; case 'V': cspec.CSPEC_VERSION = (uint16_t) (basespec (optarg, 10, sizeof (cspec.CSPEC_VERSION))); cspec.CSPEC_VERSION = HTOLE16 (cspec.CSPEC_VERSION); break; default: break; } } argc -= optind; argv += optind; if (_allclr (plc.flags, PLC_ANALYSE)) { if (ParseRule (& argc, & argv, & rule, & cspec) == -1) { error (1, 0, "invalid rule"); } } openchannel (& channel); if (! (plc.message = malloc (sizeof (* plc.message)))) { error (1, errno, PLC_NOMEMORY); } if (! argc) { if (_anyset (plc.flags, PLC_ANALYSE)) { ReadRules (& plc); } else { MakeRule (& plc, & rule); } } while ((argc) && (* argv)) { if (! hexencode (channel.peer, sizeof (channel.peer), synonym (* argv, devices, SIZEOF (devices)))) { error (1, errno, PLC_BAD_MAC, * argv); } if (_anyset (plc.flags, PLC_ANALYSE)) { ReadRules (& plc); } else { MakeRule (& plc, & rule); } argc--; argv++; } free (plc.message); closechannel (& channel); exit (0); }
void ReassociationFixer::VisitBasicBlock(PFLBasicBlock *bb, PFLBasicBlock *from) { typedef MIRONode IRType; typedef IRType::IRNodeIterator it_t; typedef list<IRType*>::iterator l_it_t; typedef PFLBasicBlock BBType; typedef MIRONode::RegType RegType; typedef map<RegType, IRType*> map_t; typedef set<RegType>::iterator s_it; set<RegType> locUses; BBType::IRStmtNodeIterator i; for(i = bb->codeBegin(); i != bb->codeEnd(); i++) { //cout << "Reassociation FIxer" << endl; //cout << " PRima passata Analizzo il nodo" << endl; //(*i)->printNode(std::cout, true); //cout << endl; IRType *root = (*i)->getTree(); if(root) { for(it_t j = root->nodeBegin(); j != root->nodeEnd(); j++) { if((*j)->isLoad()) { if( (*j)->getDefReg().get_model()->get_space() == 2) { //cout << "Inserisco l'uso di un nodo intermedio: " << (*j)->getDefReg() << endl; locUses.insert((*j)->getDefReg()); } continue; } } } } list<IRType*> &codelist(bb->getCode()); for(l_it_t k = codelist.begin(); k != codelist.end(); k++) { //cout << "Reassociation FIxer" << endl; //cout << "Seconda passata Analizzo il nodo" << endl; //(*k)->printNode(std::cout, true); //cout << endl; IRType *root = (*k)->getTree(); if(root) { for(it_t j = root->nodeBegin(); j != root->nodeEnd(); j++) { for(int n=0; n < 2; n++) { IRType *kid; if((kid = (*j)->getKid(n))) { s_it s; if(!kid->isStore() && !kid->isLoad() && ( (s = locUses.find(kid->getDefReg())) != locUses.end() )) { //cout << "il nodo definisce n registro usato!!!" << endl; RegType new_reg = RegType::get_new(2); RegType def_reg = kid->getDefReg(); IRType *str = new MIRONode(LOCST, kid->copy(), new SymbolTemp(kid->getDefReg())); GenMIRONode *stmt = new GenMIRONode(str); codelist.insert(k, stmt); str->getKid(0)->setDefReg(new_reg); //cout << "Ho inserito un nuovo nodo nella lista: " << endl; //stmt->printNode(cout, true); //cout << endl; IRType *lclod = new MIRONode(LOCLD, new SymbolTemp(def_reg)); locUses.erase(s); (*j)->setKid(lclod, n); } } } } } } return; }