コード例 #1
0
ファイル: mal_factory.c プロジェクト: sekcheong/monetdb
/*
 * Upon reaching the yield operator, the factory is
 * suspended until the next request arrives.
 * The information in the target list should be delivered
 * to the caller stack frame.
 */
int
yieldResult(MalBlkPtr mb, InstrPtr p, int pc)
{
	Plant pl, plim = plants + lastPlant;
	ValPtr lhs, rhs;
	int i;

	(void) p;
	(void) pc;
	for (pl = plants; pl < plim; pl++)
		if (pl->factory == mb ) {
			if( pl->env == NULL)
				return(int) (pl-plants);
			for (i = 0; i < p->retc; i++) {
#ifdef DEBUG_MAL_FACTORY
				printf("lhs %d rhs %d\n", getArg(pl->pci, i), getArg(p, i));
#endif
				rhs = &pl->stk->stk[getArg(p, i)];
				lhs = &pl->env->stk[getArg(pl->pci, i)];
				VALcopy(lhs, rhs);
			}
			return (int) (pl-plants);
		}
	return -1;
}
コード例 #2
0
ファイル: Parser.cpp プロジェクト: 315234/lyx-retina
string const Parser::ertEnvironment(string const & name)
{
	if (!good())
		return string();

	ostringstream os;
	for (Token t = get_token(); good(); t = get_token()) {
		if (t.cat() == catBegin) {
			putback();
			os << '{' << verbatim_item() << '}';
		} else if (t.asInput() == "\\begin") {
			string const env = getArg('{', '}');
			os << "\\begin{" << env << '}'
			   << ertEnvironment(env)
			   << "\\end{" << env << '}';
		} else if (t.asInput() == "\\end") {
			string const end = getArg('{', '}');
			if (end != name)
				cerr << "\\end{" << end
				     << "} does not match \\begin{" << name
				     << "}." << endl;
			return os.str();
		} else
			os << t.asInput();
	}
	cerr << "unexpected end of input" << endl;
	return os.str();
}
コード例 #3
0
AREXPORT bool ArArgumentBuilder::isArgDouble(size_t whichArg) const
{
  const char *str;
  double ret;
  char *endPtr;
  if (whichArg > myArgc || getArg(whichArg) == NULL)
    return false;

  str = getArg(whichArg);
  if (strcmp(str, "-INF") == 0)
  {
	return true;
  }
  else if (strcmp(str, "INF") == 0)
  {
	return true;
  }
  else
  {
    ret = strtod(str, &endPtr);
    if (endPtr[0] == '\0' && endPtr != str)
      return true;
    else
      return false;
  }

}
コード例 #4
0
/**
 * Check whether a special "help" flag was given in the arguments, and also
 * print a warning (Using ArLog at Normal log level) if any unparsed arguments were found.   
 * The following are the help flags: -help, -h, --help, /?, /h.  
 * @return false if a help flag was found or unparsed arguments 
 * were found, true otherwise.
 * @param numArgsOkay If you plan on checking for additional 
 *  arguments later in the program, you can specify the number of arguments
 *  expected here, which prevents this method from warning about them being unparsed
 *  yet.
 */
AREXPORT bool ArArgumentParser::checkHelpAndWarnUnparsed(
	unsigned int numArgsOkay)
{
  
  if (myHelp || checkArgument("-help") || checkArgument("-h") || 
      checkArgument("/?") || checkArgument("/h"))
  {
    myHelp = true;
    return false;
  }
      
  if (getArgc() <= 1 + numArgsOkay)
    return true;

  size_t i;
  char buf[2048];
  sprintf(buf, "Unhandled arguments to program:");
  for (i = 1 + (int)numArgsOkay; i < getArgc(); i++)
    sprintf(buf, "%s %s", buf, getArg(i));
  ArLog::log(ArLog::Normal, buf);
  ArLog::log(ArLog::Normal, 
	   "Program will continue but to see the help listing type '%s -help'",
	     getArg(0));
  return true;
}
コード例 #5
0
void EvtSVVNONCPEIGEN::init(){

  // check that there are 27 arguments
  checkNArg(27,15);
  checkNDaug(2);

  checkSpinDaughter(0,EvtSpinType::VECTOR);
  checkSpinDaughter(1,EvtSpinType::VECTOR);

  //  The ordering of A_f is :
  //  A_f[0-2] = A_f
  //  A_f[3-5] = Abar_f
  //  A_f[6-8] = A_fbar 
  //  A_f[9-11] = Abar_fbar
  //  
  //  Each of the 4 amplitudes include the 3 different helicity states in 
  //  the order +, 0, -. See more about helicity amplitude ordering in ::decay

  int i=0;
  int j=(getNArg()-3)/2;

  for(i=0; i<j; ++i){
    _A_f[i] = getArg((2*i)+3) * EvtComplex( cos(getArg((2*i)+4)),sin(getArg((2*i)+4)) );
  }

  //  If only 6 amplitudes are specified, calculate the last 6 from the first 6:
  if(6 == j){
    for(i = 0; i < 3; ++i){
      _A_f[6+i] = _A_f[3+i];
      _A_f[9+i] = _A_f[i];
    }
  }
}
コード例 #6
0
ファイル: opt_pushselect.c プロジェクト: sekcheong/monetdb
static InstrPtr
ReplaceWithNil(MalBlkPtr mb, InstrPtr p, int pos, int tpe)
{
	p = pushNil(mb, p, tpe); /* push at end */
	getArg(p, pos) = getArg(p, p->argc-1);
	p->argc--;
	return p;
}
コード例 #7
0
ファイル: EvtSSSCP.cpp プロジェクト: alberto-sanchez/EvtGen
void EvtSSSCP::initProbMax(){

  //This is probably not quite right, but it should do as a start...
  //Anders

  setProbMax(2*(getArg(3)*getArg(3)+getArg(5)*getArg(5)));

}
コード例 #8
0
void EvtHypNonLepton::init() {

    if(getNArg()<2 || getNArg()>3) { // alpha phi gamma delta
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton generator expected 2 or 3 arguments but found: " << getNArg() << std::endl;
        EvtGenReport(EVTGEN_INFO ,"EvtGen") << "  1. Decay asymmetry parameter - alpha" << std::endl;
        EvtGenReport(EVTGEN_INFO ,"EvtGen") << "  2. Parameter phi - in degrees (not radians)" << std::endl;
        EvtGenReport(EVTGEN_INFO ,"EvtGen") << "  3. Note on every x-th decay" << std::endl;
        ::abort();
    }

    if(getNDaug()!=2) { // Check that there are 2 daughters only
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton generator expected 2 daughters but found: " << getNDaug() << std::endl;
        ::abort();
    }

    // Check particles spins
    if(EvtSpinType::getSpin2(EvtPDL::getSpinType(getParentId()))!=1) {
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton generator expected dirac parent particle, but found " << EvtSpinType::getSpin2(EvtPDL::getSpinType(getParentId())) << " spin degrees of freedom" << std::endl;
        ::abort();
    }
    if(EvtSpinType::getSpin2(EvtPDL::getSpinType(getDaug(0)))!=1) {
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton generator expected the first child to be dirac particle, but found " << EvtSpinType::getSpin2(EvtPDL::getSpinType(getDaug(0))) << " spin degrees of freedom" << std::endl;
        ::abort();
    }
    if(EvtSpinType::getSpin2(EvtPDL::getSpinType(getDaug(1)))!=0) {
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton generator expected the second child to be scalar particle, but found " << EvtSpinType::getSpin2(EvtPDL::getSpinType(getDaug(1))) << " spin degrees of freedom" << std::endl;
        ::abort();
    }

    // Read all parameters
    m_alpha = getArg(0);
    m_phi   = getArg(1)*EvtConst::pi/180;
    if(getNArg()==3) m_noTries = static_cast<long>(getArg(2));
    else             m_noTries = 0;

    // calculate additional parameters
    double p,M,m1,m2;
    double p_to_s,beta,delta,gamma;

    M  = EvtPDL::getMass(getParentId());
    m1 = EvtPDL::getMass(getDaug(0));
    m2 = EvtPDL::getMass(getDaug(1));

    if(m1+m2>=M) {
        EvtGenReport(EVTGEN_ERROR,"EvtGen") << " ERROR: EvtHypNonLepton found impossible decay: " << M << " --> " << m1 << " + " << m2 << " GeV\n" << std::endl;
        ::abort();
    }

    p = sqrt(M*M-(m1+m2)*(m1+m2))*sqrt(M*M-(m1-m2)*(m1-m2))/2./M;

    beta = sqrt(1.-m_alpha*m_alpha)*sin(m_phi);
    delta = -atan2(beta,m_alpha);
    gamma = sqrt(1.-m_alpha*m_alpha-beta*beta);
    p_to_s = sqrt((1.-gamma)/(1.+gamma));

    m_B_to_A = p_to_s*(m1+sqrt(p*p+m1*m1))/p*EvtComplex(cos(delta),sin(delta));

}
コード例 #9
0
//
// Called to create the network connection.
//
static VMIOS_INTERCEPT_FN(netInit)
{
    object->domain = vmirtGetProcessorDataDomain(processor);

    Uns32 prefixStringAddr;
    Uns32 localNetAddr;

    getArg(processor, object, 0, &object->diagLevel);
    getArg(processor, object, 1, &object->packets);
    getArg(processor, object, 2, &prefixStringAddr);
    getArg(processor, object, 3, &localNetAddr);
    object->pollCount = 0;

    const char *tftp_path = NULL;
    if(prefixStringAddr) {
         tftp_path = vmirtGetString(object->domain, prefixStringAddr);

         if(DIAG_LOW) {
             vmiMessage("I", PREFIX,
                 "local tftp server is active. Root directory is '%s'",
                 object->tftpPath
             );
         }
    }
    const char *localNet = localNetAddr
        ?  vmirtGetString(object->domain, localNetAddr)
        : "10.0.2.0";


    char vhostname[256];
    vhostname[0] = 0;

    //gethostname(vhostname, sizeof(vhostname));
    const char *bootfile    = NULL;
    const char *vnetmask    = NULL;
    const char *vdhcp_start = NULL;
    const char *vnameserver = NULL;
    const char *vhost       = NULL;
    Bool  restricted        = False;

    object->slirp = net_slirp_init(
        restricted,
        localNet,
        vnetmask,
        vhost,
        vhostname,
        tftp_path,
        bootfile,
        vdhcp_start,
        vnameserver,
        object
    );
    if (!object->slirp) {
        vmiMessage("F", PREFIX, "Unable to start networking");
    }
}
コード例 #10
0
ファイル: mat.c プロジェクト: Mytherin/MonetDBLite
/*
 * Enable incremental packing. The SQL front-end requires
 * fixed oid sequences.
 */
str
MATpackIncrement(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	bat *ret = getArgReference_bat(stk,p,0);
	int	pieces;
	BAT *b, *bb, *bn;
	size_t newsize;

	(void) cntxt;
	b = BATdescriptor( stk->stk[getArg(p,1)].val.ival);
	if ( b == NULL)
		throw(MAL, "mat.pack", RUNTIME_OBJECT_MISSING);

	if ( getArgType(mb,p,2) == TYPE_int){
		/* first step, estimate with some slack */
		pieces = stk->stk[getArg(p,2)].val.ival;
		bn = BATnew(TYPE_void, b->ttype?b->ttype:TYPE_oid, (BUN)(1.2 * BATcount(b) * pieces), TRANSIENT);
		if (bn == NULL)
			throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
		/* allocate enough space for the vheap, but not for strings,
		 * since BATappend does clever things for strings */
		if ( b->T->vheap && bn->T->vheap && ATOMstorage(b->ttype) != TYPE_str){
			newsize =  b->T->vheap->size * pieces;
			if (HEAPextend(bn->T->vheap, newsize, TRUE) != GDK_SUCCEED)
				throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
		}
		BATseqbase(bn, b->H->seq);
		BATseqbase(BATmirror(bn), b->T->seq);
		BATappend(bn,b,FALSE);
		assert(!bn->H->nil || !bn->H->nonil);
		assert(!bn->T->nil || !bn->T->nonil);
		bn->H->align = (pieces-1);
		BBPkeepref(*ret = bn->batCacheid);
		BBPunfix(b->batCacheid);
	} else {
		/* remaining steps */
		bb = BATdescriptor(stk->stk[getArg(p,2)].val.ival);
		if ( bb ){
			if (BATcount(b) == 0)
				BATseqbase(b, bb->H->seq);
			if (BATcount(b) == 0)
				BATseqbase(BATmirror(b), bb->T->seq);
			BATappend(b,bb,FALSE);
		}
		b->H->align--;
		if(b->H->align == 0)
			BATsetaccess(b, BAT_READ);
		assert(!b->H->nil || !b->H->nonil);
		assert(!b->T->nil || !b->T->nonil);
		BBPkeepref(*ret = b->batCacheid);
		if( bb) 
			BBPunfix(bb->batCacheid);
	}
	return MAL_SUCCEED;
}
コード例 #11
0
ファイル: ArArgumentBuilder.cpp プロジェクト: DYFeng/mrpt
AREXPORT bool ArArgumentBuilder::getArgBool(size_t whichArg) const
{
  if (whichArg > myArgc || getArg(whichArg) == NULL)
    return false;

  if (strcasecmp(getArg(whichArg), "true") == 0 ||
      strcasecmp(getArg(whichArg), "1") == 0)
    return true;
  else
    return false;
}
コード例 #12
0
ファイル: opt_pushselect.c プロジェクト: sekcheong/monetdb
static InstrPtr
PushArgument(MalBlkPtr mb, InstrPtr p, int arg, int pos)
{
	int i;

	p = pushArgument(mb, p, arg); /* push at end */
	for (i = p->argc-1; i > pos; i--) 
		getArg(p, i) = getArg(p, i-1);
	getArg(p, pos) = arg;
	return p;
}
コード例 #13
0
ファイル: opt_sql_append.c プロジェクト: f7753/monetdb
str OPTsql_append(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p){
	str modnme;
	str fcnnme;
	str msg= MAL_SUCCEED;
	Symbol s= NULL;
	lng t,clk= GDKusec();
	int actions = 0;

	if( p )
		removeInstruction(mb, p);
	OPTDEBUGsql_append mnstr_printf(cntxt->fdout,"=APPLY OPTIMIZER sql_append\n");
	if( p && p->argc > 1 ){
		if( getArgType(mb,p,1) != TYPE_str ||
			getArgType(mb,p,2) != TYPE_str ||
			!isVarConstant(mb,getArg(p,1)) ||
			!isVarConstant(mb,getArg(p,2))
		) {
			throw(MAL, "optimizer.sql_append", ILLARG_CONSTANTS);
		}
		if( stk != 0){
			modnme= *getArgReference_str(stk,p,1);
			fcnnme= *getArgReference_str(stk,p,2);
		} else {
			modnme= getArgDefault(mb,p,1);
			fcnnme= getArgDefault(mb,p,2);
		}
		s= findSymbol(cntxt->nspace, putName(modnme,strlen(modnme)),putName(fcnnme,strlen(fcnnme)));

		if( s == NULL) {
			char buf[1024];
			snprintf(buf,1024, "%s.%s",modnme,fcnnme);
			throw(MAL, "optimizer.sql_append", RUNTIME_OBJECT_UNDEFINED ":%s", buf);
		}
		mb = s->def;
		stk= 0;
	}
	if( mb->errors ){
		/* when we have errors, we still want to see them */
		addtoMalBlkHistory(mb,"sql_append");
		return MAL_SUCCEED;
	}
	actions= OPTsql_appendImplementation(cntxt, mb,stk,p);
	msg= optimizerCheck(cntxt, mb, "optimizer.sql_append", actions, t=(GDKusec() - clk));
	OPTDEBUGsql_append {
		mnstr_printf(cntxt->fdout,"=FINISHED sql_append %d\n",actions);
		printFunction(cntxt->fdout,mb,0,LIST_MAL_ALL );
	}
	DEBUGoptimizers
		mnstr_printf(cntxt->fdout,"#opt_reduce: " LLFMT " ms\n",t);
	QOTupdateStatistics("sql_append",actions,t);
	addtoMalBlkHistory(mb,"sql_append");
	return msg;
}
コード例 #14
0
ファイル: opt_pushselect.c プロジェクト: sekcheong/monetdb
static InstrPtr
PushNil(MalBlkPtr mb, InstrPtr p, int pos, int tpe)
{
	int i, arg;

	p = pushNil(mb, p, tpe); /* push at end */
	arg = getArg(p, p->argc-1);
	for (i = p->argc-1; i > pos; i--) 
		getArg(p, i) = getArg(p, i-1);
	getArg(p, pos) = arg;
	return p;
}
コード例 #15
0
ファイル: mat.c プロジェクト: jaiminpan/Monetdb
/*
 * The pack is an ordinary multi BAT insert. Oid synchronistion
 * between pieces should be ensured by the code generators.
 * The pack operation could be quite expensive, because it
 * may create a really large BAT.
 * The slice over a mat helps to avoid constructing intermediates
 * that are subsequently reduced.
 * Contrary to most operations, NIL arguments are skipped and
 * do not produce RUNTIME_OBJECT_MISSING.
 */
static str
MATpackInternal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int i, *ret = (int*) getArgReference(stk,p,0);
	BAT *b, *bn;
	BUN cap = 0;
	int tt = TYPE_any;
	(void) cntxt;
	(void) mb;

	for (i = 1; i < p->argc; i++) {
		int bid = stk->stk[getArg(p,i)].val.ival;
		b = BBPquickdesc(abs(bid),FALSE);
		if (b && bid < 0)
			b = BATmirror(b);
		if( b ){
			assert(BAThdense(b));
			if (tt == TYPE_any){
				tt = b->ttype;
			}
			if (!tt && tt != b->ttype)
				tt = b->ttype;
			cap += BATcount(b);
		}
	}
	if (tt == TYPE_any){
		*ret = 0;
		return MAL_SUCCEED;
	}

	bn = BATnew(TYPE_void, tt, cap, TRANSIENT);
	if (bn == NULL)
		throw(MAL, "mat.pack", MAL_MALLOC_FAIL);

	for (i = 1; i < p->argc; i++) {
		b = BATdescriptor(stk->stk[getArg(p,i)].val.ival);
		if( b ){
			if (BATcount(bn) == 0)
				BATseqbase(bn, b->H->seq);
			if (BATcount(bn) == 0)
				BATseqbase(BATmirror(bn), b->T->seq);
			BATappend(bn,b,FALSE);
			BBPunfix(b->batCacheid);
		}
	}
	assert(!bn->H->nil || !bn->H->nonil);
	assert(!bn->T->nil || !bn->T->nonil);
	BATsettrivprop(bn);
	BATderiveProps(bn,FALSE);
	BBPkeepref(*ret = bn->batCacheid);
	return MAL_SUCCEED;
}
コード例 #16
0
int main ( int argc, char * argv [] )
{
    int status = 1;
    
    try
    {

        const char *outfile = "./db/";
        const char *schema_path = "./test-general-writer.vschema";
        int num_columns = 0;
    
        for ( int i = 1; i < argc; ++ i )
        {
            const char * arg = argv [ i ];
            if ( arg [ 0 ] != '-' )
            {
                // have an input column
                argv [ num_columns ++ ] = ( char* ) arg;
            }
            else do switch ( ( ++ arg ) [ 0 ] )
            {
                case 'o':
                    outfile = getArg ( arg, i, argc, argv );
                    break;
                case 's':
                    schema_path = getArg ( arg, i, argc, argv );
                default:
                    throw "Invalid argument";
            }
            while ( arg [ 1 ] != 0 );
        }
        
        if ( num_columns == 0 )
        {
            const char * columns [ 2 ] = { "input/column01", "input/column02" };
            ncbi :: runTest ( 2, columns, outfile, schema_path );
        }
        else
        {
            ncbi :: runTest ( num_columns, ( const char ** ) argv, outfile, schema_path );
        }
        
        status = 0;
    }
    catch ( const char x [] )
    {
        std :: cerr << x << std :: endl;
    }
    
    return status;
}
コード例 #17
0
ファイル: Mql4jUtil.cpp プロジェクト: NiceBlueEyes/mql4j
int main(int argc, const char* argv[]) {
	if(argc < 2) {
		printHelp();
	}
	const string func = getArg(argc, argv, 1);
	if(func.compare("help") == 0) {
		printHelp();
	} else if(func.compare("activemqSend") == 0) {
		const string brokerURI = getArg(argc, argv, 2);
		const bool destType = getDestType(getArg(argc, argv, 3));
		const string dest = getArg(argc, argv, 4);
		const string message = getArg(argc, argv, 5);
		mql4j::activemqSend(brokerURI, destType, dest , message);
	} else if(func.compare("activemqRecv") == 0) {
		const string brokerURI = getArg(argc, argv, 2);
		const bool destType = getDestType(getArg(argc, argv, 3));
		const string dest = getArg(argc, argv, 4);
		mql4j::activemqRecv(brokerURI, destType, dest);
	} else if(func.compare("jvmStart") == 0) {
		mql4j::jvmStart();
	} else {
		printHelp();
	}
	return 0;
}
コード例 #18
0
void EvtbsToLLLL::decay( EvtParticle *p ){
  
  double         mu = getArg(0);        // the scale parameter
  int            Nf = (int) getArg(1);  // number of "effective" flavors
  int      res_swch = (int) getArg(2);  // resonant switching parametr
  int           ias = (int) getArg(3);  // switching parametr for \alpha_s(M_Z)
  double      CKM_A = getArg(4); 
  double CKM_lambda = getArg(5); 
  double CKM_barrho = getArg(6); 
  double CKM_bareta = getArg(7);

  p->initializePhaseSpace(getNDaug(),getDaugs());

  _calcamp->CalcAmp(p,_amp2, _mntffmodel, _wilscoeff, mu, Nf, res_swch, ias, 
                    CKM_A,CKM_lambda,CKM_barrho,CKM_bareta);

//  EvtGenReport(NOTICE,"EvtGen") << "\n The function EvtbTosllMSExt::decay(...) passed with arguments:"
//                        << "\n mu = " << mu << " Nf =" << Nf 
//                        << " res_swch = " << res_swch 
//                        << " ias = " << ias 
//                        << " CKM_A = " << CKM_A
//                        << " CKM_lambda = " << CKM_lambda
//                        << " CKM_barrho = " << CKM_barrho
//                        << " CKM_bareta = " << CKM_bareta 
//                        << " ReA7 = " << ReA7
//                        << " ImA7 = " << ImA7
//                        << " ReA10 = " << ReA10
//                        << " ImA10 = " << ImA10 << std::endl;

}
コード例 #19
0
ファイル: sql_optimizer.c プロジェクト: Mytherin/MonetDBLite
static lng 
SQLgetSpace(mvc *m, MalBlkPtr mb)
{
	sql_trans *tr = m->session->tr;
	lng space = 0, i; 

	for (i = 0; i < mb->stop; i++) {
		InstrPtr p = mb->stmt[i];
		char *f = getFunctionId(p);

		if (getModuleId(p) == sqlRef && (f == bindRef || f == bindidxRef)) {
			int upd = (p->argc == 7 || p->argc == 9), mode = 0;
			char *sname = getVarConstant(mb, getArg(p, 2 + upd)).val.sval;
			char *tname = getVarConstant(mb, getArg(p, 3 + upd)).val.sval;
			char *cname = NULL;
			sql_schema *s = mvc_bind_schema(m, sname);

			if (!s || strcmp(s->base.name, dt_schema) == 0) 
				continue;
			cname = getVarConstant(mb, getArg(p, 4 + upd)).val.sval;
			mode = getVarConstant(mb, getArg(p, 5 + upd)).val.ival;
			if (mode != 0 || !cname || !s)
				continue;
			if (f == bindidxRef) {
				sql_idx *i = mvc_bind_idx(m, s, cname);

				if (i && (!isRemote(i->t) && !isMergeTable(i->t))) {
					BAT *b = store_funcs.bind_idx(tr, i, RDONLY);
					if (b) {
						space += getBatSpace(b);
						BBPunfix(b->batCacheid);
					}
				}
			} else if (f == bindRef) {
				sql_table *t = mvc_bind_table(m, s, tname);
				sql_column *c = mvc_bind_column(m, t, cname);

				if (c && (!isRemote(c->t) && !isMergeTable(c->t))) {
					BAT *b = store_funcs.bind_col(tr, c, RDONLY);
					if (b) {
						space += getBatSpace(b);
						BBPunfix(b->batCacheid);
					}
				}
			}
		}
	}
	return space;
}
コード例 #20
0
ファイル: opt_macro.c プロジェクト: jaiminpan/Monetdb
/*
 * Matching a block calls for building two variable lists used.
 * The isomorphism can be determined after-wards using a single scan.
 * The candidate block is matched with mb starting at a given pc.
 * The candidate block is expected to defined as a function, including
 * a signature and end-statement. They are ignored in the comparison
 *
 * Beware, the variables in the block being removed, could be
 * used furtheron in the program. [tricky to detect, todo]
 */
static int
malFcnMatch(MalBlkPtr mc, MalBlkPtr mb, int pc)
{
	int i, j, k, lim;
	int *cvar, *mvar;
	int ctop = 0, mtop = 0;
	InstrPtr p, q;

	if (mb->stop - pc < mc->stop - 2)
		return 0;

	cvar = (int *) GDKmalloc(mc->vtop * mc->maxarg * sizeof(*cvar));
	if (cvar == NULL)
		return 0;
	mvar = (int *) GDKmalloc(mb->vtop * mc->maxarg * sizeof(*mvar));
	if (mvar == NULL){
		GDKfree(cvar);
		return 0;
	}
	/* also trim the return statement */
	lim = pc + mc->stop - 3;
	k = 1;
	for (i = pc; i < lim; i++, k++) {
		p = getInstrPtr(mb, i);
		q = getInstrPtr(mc, k);
		if (malMatch(p, q) == 0){
			GDKfree(cvar);
			GDKfree(mvar);
			return 0;
		}
		for (j = 0; j < p->argc; j++)
			cvar[ctop++] = getArg(p, j);

		for (j = 0; j < q->argc; j++)
			mvar[mtop++] = getArg(q, j);
	}
	assert(mtop == ctop);	/*shouldn't happen */

	for (i = 0; i < ctop; i++)
		for (j = i + 1; j < ctop; j++)
			if ((cvar[i] == cvar[j]) != (mvar[i] == mvar[j])) {
				GDKfree(cvar);
				GDKfree(mvar);
				return 0;
			}
	GDKfree(cvar);
	GDKfree(mvar);
	return 1;
}
コード例 #21
0
ファイル: ArArgumentBuilder.cpp プロジェクト: DYFeng/mrpt
AREXPORT int ArArgumentBuilder::getArgInt(size_t whichArg) const
{
  const char *str;
  int ret;
  char *endPtr;
  if (whichArg > myArgc || getArg(whichArg) == NULL)
    return 0;

  str = getArg(whichArg);
  ret = strtol(str, &endPtr, 10);
  if (endPtr[0] == '\0' && endPtr != str)
    return ret;
  else
    return 0;
}
コード例 #22
0
static VMIOS_INTERCEPT_FN(netTxPacket)
{
    Uns32 addr, bytes;
    getArg(processor, object, 0, &addr);
    getArg(processor, object, 1, &bytes);

    // copy data from PSE to host memory space.
    Uns8 packet[bytes];
    vmirtReadNByteDomain(object->domain, addr, packet, bytes, NULL, False);

    if(DIAG_HIGH) vmiMessage("I", PREFIX, "netTxPacket bytes:%d", bytes);

    // send to slirp
    slirp_input(object->slirp, packet, bytes);
}
コード例 #23
0
ファイル: opt_inline.c プロジェクト: Clay-Birkett/monetdb
int
OPTinlineImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
    int i;
    InstrPtr q,sig;
    int actions = 0;

    (void) p;
    (void)stk;

    for (i = 1; i < mb->stop; i++) {
        q = getInstrPtr(mb, i);
        if( q->blk ) {
            sig = getInstrPtr(q->blk,0);
            /*
             * Time for inlining functions that are used in multiplex operations.
             * They are produced by SQL compiler.
             */
            if( getFunctionId(q)== multiplexRef &&
                    getModuleId(q) == malRef &&
                    OPTinlineMultiplex(cntxt,mb,q)) {

                OPTDEBUGinline {
                    mnstr_printf(cntxt->fdout,"#multiplex inline function\n");
                    printInstruction(cntxt->fdout,mb,0,q,LIST_MAL_ALL);
                }

                varSetProp(mb, getArg(q,0), inlineProp, op_eq, NULL);
            } else
                /*
                 * Check if the function definition is tagged as being inlined.
                 */
                if (sig->token == FUNCTIONsymbol &&
コード例 #24
0
ファイル: W32Carnage.cpp プロジェクト: ISergey256/W32Carnage
void fuzz(struct syscall_t *curSyscall){
	//printf("%s\n", curSyscall->name);
	UINT64 ret = 0xDEADBEEFDEADBEEF;

	UINT64 args[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

	try{
		for (int i = 0; i < curSyscall->argn; i++){
			args[i] = getArg(curSyscall, i);
		}
		ret = _syscall(curSyscall->syscallnumber,
			args[0],
			args[1],
			args[2],
			args[3],
			args[4],
			args[5],
			args[6],
			args[7]);
	}
	catch (...){
		printf("...\n");
		return ;
	}
	//printf("ret %p\n", ret);
}
コード例 #25
0
AREXPORT bool ArArgumentBuilder::getArgBool(size_t whichArg, 
                                            bool *ok) const
{
  bool isSuccess = false;
  bool ret = false;
 
  const char *str = getArg(whichArg);

  // If the arg was successfully obtained...
  if (str != NULL) {

    if (strcasecmp(str, "true") == 0 || 
        strcasecmp(str, "1") == 0) {
      isSuccess = true;
      ret = true;
    }
    else if (strcasecmp(str, "false") == 0 || 
             strcasecmp(str, "0") == 0) {
      isSuccess = true;
      ret = false;
    }
  } // end if valid arg

  if (ok != NULL) {
    *ok = isSuccess;
  }
  if (isSuccess) {
    return ret;
  }
  else {
    return 0;
  }
} // end method getArgBool
コード例 #26
0
static VMIOS_INTERCEPT_FN(netPoll)
{
    u_int timeMS;
    getArg(processor, object, 0, &timeMS);

    if(DIAG_HIGH) {
        vmiMessage("I", PREFIX, "netPoll #" FMT_64d " at %d ***********", object->pollCount, timeMS);
    }

    object->pollCount++;

    int nfds = -1;

    Slirp *slirp = object->slirp;

    FD_ZERO(&slirp->rfds);
    FD_ZERO(&slirp->wfds);
    FD_ZERO(&slirp->xfds);

    slirp_select_fill(slirp, &nfds, &slirp->rfds, &slirp->wfds, &slirp->xfds);

    struct timeval tv;
    tv.tv_sec = 0;
    tv.tv_usec = 0;

    int r = recSelectSocket(nfds + 1, &slirp->rfds, &slirp->wfds, &slirp->xfds, &tv);
    slirp_select_poll(slirp, &slirp->rfds, &slirp->wfds, &slirp->xfds, timeMS, r >= 0);
}
コード例 #27
0
ファイル: mat.c プロジェクト: Mytherin/MonetDBLite
str
MATpackValues(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int i, type, first = 1;
	bat *ret;
	BAT *bn;

	(void) cntxt;
	type = getArgType(mb,p,first);
	bn = BATnew(TYPE_void, type, p->argc, TRANSIENT);
	if( bn == NULL)
		throw(MAL, "mat.pack", MAL_MALLOC_FAIL);

	if (ATOMextern(type)) {
		for(i = first; i < p->argc; i++)
			BUNappend(bn, stk->stk[getArg(p,i)].val.pval, TRUE);
	} else {
		for(i = first; i < p->argc; i++)
			BUNappend(bn, getArgReference(stk, p, i), TRUE);
	}
	BATseqbase(bn, 0);
	ret= getArgReference_bat(stk,p,0);
	BBPkeepref(*ret = bn->batCacheid);
	return MAL_SUCCEED;
}
コード例 #28
0
ファイル: ArArgumentBuilder.cpp プロジェクト: DYFeng/mrpt
AREXPORT bool ArArgumentBuilder::isArgInt(size_t whichArg) const
{
  const char *str;
  //int ret;
  char *endPtr;
  if (whichArg > myArgc || getArg(whichArg) == NULL)
    return false;

  str = getArg(whichArg);
  int ret = strtol(str, &endPtr, 10);
  (void)(ret); // Avoid unused var warning
  if (endPtr[0] == '\0' && endPtr != str)
    return true;
  else
    return false;
}
コード例 #29
0
ファイル: mat.c プロジェクト: jaiminpan/Monetdb
str
MATpackValues(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int i,*ret, type, first = 1;
	BAT *bn;

	(void) cntxt;
	type = getArgType(mb,p,first);
	bn = BATnew(TYPE_void, type, p->argc, TRANSIENT);
	if( bn == NULL)
		throw(MAL, "mat.pack", MAL_MALLOC_FAIL);

	if (ATOMvarsized(type)) {
		for(i = first; i < p->argc; i++)
			BUNappend(bn, stk->stk[getArg(p,i)].val.sval, TRUE);
	} else {
		for(i = first; i < p->argc; i++)
			BUNappend(bn, getArgReference(stk, p, i), TRUE);
	}
    BATsettrivprop(bn);
    BATderiveProps(bn,FALSE);
	ret= (int*) getArgReference(stk,p,0);
	BBPkeepref(*ret = bn->batCacheid);
	return MAL_SUCCEED;
}
コード例 #30
0
ファイル: opt_evaluate.c プロジェクト: MonetDB/MonetDB
static int
OPTallConstant(Client cntxt, MalBlkPtr mb, InstrPtr p)
{
	int i;
	(void)cntxt;

	if ( !(p->token == ASSIGNsymbol ||
		   getModuleId(p) == calcRef ||
		   getModuleId(p) == strRef ||
		   getModuleId(p) == mtimeRef ||
		   getModuleId(p) == mmathRef))
		return FALSE;
	if (getModuleId(p) == mmathRef && strcmp(getFunctionId(p), "rand") == 0)
		return FALSE;

	for (i = p->retc; i < p->argc; i++)
		if (isVarConstant(mb, getArg(p, i)) == FALSE)
			return FALSE;
	for (i = 0; i < p->retc; i++) {
		if (isaBatType(getArgType(mb, p, i)))
			return FALSE;
		if ( mb->unsafeProp ) 
			return FALSE;
	}
	return TRUE;
}