Esempio n. 1
0
int ck_ls_case (int array_no){ //1 for pass = good to go, 0 for fail
	//here the array_no is the same as q[] subscript
	int i;
	struct decoded_ins *ins;
	int opcode;

	if(cpre_issue->q[array_no]){
	ins= cpre_issue->q[array_no];//for currently checking ins
	opcode= get_opcode(ins->binary);		
	}
	else{
		printf("Error: in fn \"ck_ls_case()\", deref NULL ptr\n");
		return 0;
	}
	
	if(opcode ==22 || opcode ==23){  //if the ins is LW or SW
		for(i=0;i<array_no;i++){ //check previos ins if any SW exist
			if(get_opcode(cpre_issue->q[i]->binary) == 22)
				return 0;
		}

		return 1;
	}
	else{
		return 1;
	}
}
Esempio n. 2
0
/*
 * op_mergejoin_crossops
 *
 *		Returns the cross-type comparison operators (ltype "<" rtype and
 *		ltype ">" rtype) for an operator previously determined to be
 *		mergejoinable.	Optionally, fetches the regproc ids of these
 *		operators, as well as their operator OIDs.
 */
void
op_mergejoin_crossops(Oid opno, Oid *ltop, Oid *gtop,
					  RegProcedure *ltproc, RegProcedure *gtproc)
{
	HeapTuple	tp;
	Form_pg_operator optup;

	/*
	 * Get the declared comparison operators of the operator.
	 */
	tp = SearchSysCache(OPEROID,
						ObjectIdGetDatum(opno),
						0, 0, 0);
	if (!HeapTupleIsValid(tp))	/* shouldn't happen */
		elog(ERROR, "cache lookup failed for operator %u", opno);
	optup = (Form_pg_operator) GETSTRUCT(tp);
	*ltop = optup->oprltcmpop;
	*gtop = optup->oprgtcmpop;
	ReleaseSysCache(tp);

	/* Check < op provided */
	if (!OidIsValid(*ltop))
		elog(ERROR, "mergejoin operator %u has no matching < operator",
			 opno);
	if (ltproc)
		*ltproc = get_opcode(*ltop);

	/* Check > op provided */
	if (!OidIsValid(*gtop))
		elog(ERROR, "mergejoin operator %u has no matching > operator",
			 opno);
	if (gtproc)
		*gtproc = get_opcode(*gtop);
}
Esempio n. 3
0
int issue(void){
	//printf("in issue\n");
	struct decoded_ins *cand_ls=NULL;
	struct decoded_ins *cand_else=NULL;
	int issue_count=0;
	int i;
	clean_array();
	/*in the loop is ckecking and making candidates period*/

	for(i=0;i<4;i++){
		//printf("round: %d\n",i );
		struct decoded_ins *cking_ins;
		cking_ins = cpre_issue->q[i];
		
		//check breaking conditon for exiting examining for loop
		if(cking_ins ==NULL) //end of cpre_issue queue
			break;
		if(cand_ls!= NULL && cand_else!= NULL)//full cand
			break;


		ins2array(cking_ins,i);

		if(ck_hazard(i) && ck_ls_case(i)){ //both passed
			//printf("all pass\n");
			if(get_opcode(cking_ins->binary)== 22 || get_opcode(cking_ins->binary)==23){
				if(cand_ls == NULL){
					cand_ls=cking_ins;
					update_working_array(i);
				}
				else
					continue;
			}
			else{
				if(cand_else == NULL){
					cand_else=cking_ins;
					update_working_array(i);
				}
				else
					continue;
			}
		}
	}//end of for loop

	if(cand_ls!=NULL && cpre_alu1->count <2){
		enq_prealu(cand_ls,pre_alu1);
		deq_preissue(cand_ls);
		issue_count++;
	}
	if(cand_else!=NULL && cpre_alu2->count <2){
		enq_prealu(cand_else,pre_alu2 );
		deq_preissue(cand_else);
		issue_count++;
	}
	return issue_count;
}
Esempio n. 4
0
/*
 *	Pass 1:
 *	  - process one line of source
 *
 *	Output: 1 line processed
 *		0 EOF
 */
int p1_line(void)
{
	register char *p;
	register int i;
	register struct opc *op;

	if ((p = fgets(line, MAXLINE, srcfp)) == NULL)
		return(0);
	c_line++;
	p = get_label(label, p);
	p = get_opcode(opcode, p);
	p = get_arg(operand, p);
	if (strcmp(opcode, ENDFILE) == 0)
		return(0);
	if (*opcode) {
		if ((op = search_op(opcode)) != NULL) {
			i = (*op->op_fun)(op->op_c1, op->op_c2);
			if (gencode)
				pc += i;
		} else
			asmerr(E_ILLOPC);
	} else
		if (*label)
			put_label();
	return(1);
}
Esempio n. 5
0
/*
 * execTuplesMatchPrepare
 *		Build expression that can be evaluated using ExecQual(), returning
 *		whether an ExprContext's inner/outer tuples are NOT DISTINCT
 */
ExprState *
execTuplesMatchPrepare(TupleDesc desc,
					   int numCols,
					   AttrNumber *keyColIdx,
					   Oid *eqOperators,
					   PlanState *parent)
{
	Oid		   *eqFunctions = (Oid *) palloc(numCols * sizeof(Oid));
	int			i;
	ExprState  *expr;

	if (numCols == 0)
		return NULL;

	/* lookup equality functions */
	for (i = 0; i < numCols; i++)
		eqFunctions[i] = get_opcode(eqOperators[i]);

	/* build actual expression */
	expr = ExecBuildGroupingEqual(desc, desc, NULL, NULL,
								  numCols, keyColIdx, eqFunctions,
								  parent);

	return expr;
}
Esempio n. 6
0
/*
 * Setup a ScanKey for a search in the relation 'rel' for a tuple 'key' that
 * is setup to match 'rel' (*NOT* idxrel!).
 *
 * Returns whether any column contains NULLs.
 *
 * This is not generic routine, it expects the idxrel to be replication
 * identity of a rel and meet all limitations associated with that.
 */
static bool
build_replindex_scan_key(ScanKey skey, Relation rel, Relation idxrel,
						 TupleTableSlot *searchslot)
{
	int			attoff;
	bool		isnull;
	Datum		indclassDatum;
	oidvector  *opclass;
	int2vector *indkey = &idxrel->rd_index->indkey;
	bool		hasnulls = false;

	Assert(RelationGetReplicaIndex(rel) == RelationGetRelid(idxrel));

	indclassDatum = SysCacheGetAttr(INDEXRELID, idxrel->rd_indextuple,
									Anum_pg_index_indclass, &isnull);
	Assert(!isnull);
	opclass = (oidvector *) DatumGetPointer(indclassDatum);

	/* Build scankey for every attribute in the index. */
	for (attoff = 0; attoff < IndexRelationGetNumberOfKeyAttributes(idxrel); attoff++)
	{
		Oid			operator;
		Oid			opfamily;
		RegProcedure regop;
		int			pkattno = attoff + 1;
		int			mainattno = indkey->values[attoff];
		Oid			optype = get_opclass_input_type(opclass->values[attoff]);

		/*
		 * Load the operator info.  We need this to get the equality operator
		 * function for the scan key.
		 */
		opfamily = get_opclass_family(opclass->values[attoff]);

		operator = get_opfamily_member(opfamily, optype,
									   optype,
									   BTEqualStrategyNumber);
		if (!OidIsValid(operator))
			elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
				 BTEqualStrategyNumber, optype, optype, opfamily);

		regop = get_opcode(operator);

		/* Initialize the scankey. */
		ScanKeyInit(&skey[attoff],
					pkattno,
					BTEqualStrategyNumber,
					regop,
					searchslot->tts_values[mainattno - 1]);

		/* Check for null value. */
		if (searchslot->tts_isnull[mainattno - 1])
		{
			hasnulls = true;
			skey[attoff].sk_flags |= SK_ISNULL;
		}
	}

	return hasnulls;
}
Esempio n. 7
0
/*
 *	Pass 2:
 *	  - process one line of source
 *
 *	Output: 1 line processed
 *		0 EOF
 */
int p2_line(void)
{
	register char *p;
	register int op_count;
	register struct opc *op;

	if ((p = fgets(line, MAXLINE, srcfp)) == NULL)
		return(0);
	c_line++;
	s_line++;
	p = get_label(label, p);
	p = get_opcode(opcode, p);
	p = get_arg(operand, p);
	if (strcmp(opcode, ENDFILE) == 0) {
		lst_line(pc, 0);
		return(0);
	}
	if (*opcode) {
		op = search_op(opcode);
		op_count = (*op->op_fun)(op->op_c1, op->op_c2);
		if (gencode) {
			lst_line(pc, op_count);
			obj_writeb(op_count);
			pc += op_count;
		} else {
			sd_flag = 2;
			lst_line(0, 0);
		}
	} else {
		sd_flag = 2;
		lst_line(0, 0);
	}
	return(1);
}
Esempio n. 8
0
/*
 * get_expr_result_type
 *		As above, but work from a calling expression node tree
 */
TypeFuncClass
get_expr_result_type(Node *expr,
					 Oid *resultTypeId,
					 TupleDesc *resultTupleDesc)
{
	TypeFuncClass result;

	if (expr && IsA(expr, FuncExpr))
		result = internal_get_result_type(((FuncExpr *) expr)->funcid,
										  expr,
										  NULL,
										  resultTypeId,
										  resultTupleDesc);
	else if (expr && IsA(expr, OpExpr))
		result = internal_get_result_type(get_opcode(((OpExpr *) expr)->opno),
										  expr,
										  NULL,
										  resultTypeId,
										  resultTupleDesc);
	else
	{
		/* handle as a generic expression; no chance to resolve RECORD */
		Oid			typid = exprType(expr);

		if (resultTypeId)
			*resultTypeId = typid;
		if (resultTupleDesc)
			*resultTupleDesc = NULL;
		result = get_type_func_class(typid);
		if (result == TYPEFUNC_COMPOSITE && resultTupleDesc)
			*resultTupleDesc = lookup_rowtype_tupdesc_copy(typid, -1);
	}

	return result;
}
Esempio n. 9
0
File: pf_in.c Progetto: Gaffey/linux
unsigned int get_ins_mem_width(unsigned long ins_addr)
{
	unsigned int opcode;
	unsigned char *p;
	struct prefix_bits prf;
	int i;

	p = (unsigned char *)ins_addr;
	p += skip_prefix(p, &prf);
	p += get_opcode(p, &opcode);

	for (i = 0; i < ARRAY_SIZE(mw8); i++)
		if (mw8[i] == opcode)
			return 1;

	for (i = 0; i < ARRAY_SIZE(mw16); i++)
		if (mw16[i] == opcode)
			return 2;

	for (i = 0; i < ARRAY_SIZE(mw32); i++)
		if (mw32[i] == opcode)
			return prf.shorted ? 2 : 4;

	for (i = 0; i < ARRAY_SIZE(mw64); i++)
		if (mw64[i] == opcode)
			return prf.shorted ? 2 : (prf.enlarged ? 8 : 4);

	printk(KERN_ERR "mmiotrace: Unknown opcode 0x%02x\n", opcode);
	return 0;
}
Esempio n. 10
0
int execute_alu2(struct decoded_ins *ins){//return value or -1 for failure
	int value=0;
	int opcode;
	opcode = get_opcode(ins->binary);
	switch (opcode){
		case 24: //SLL
			value = (unsigned int)reg[ins->rt] << ins->shamt;
			break;
		case 25: //SRL
			value = (unsigned int)reg[ins->rt] >> ins->shamt;
			break;
		case 26: //SRA
			value = reg[ins->rt] >> ins->shamt;
			break;
		case 48: //ADD
			value =reg[ins->rs]+ reg[ins->rt];
			break;
		case 49: //SUB
			value =reg[ins->rs]- reg[ins->rt];
			break;
		case 50: //MUL
			value =reg[ins->rs]* reg[ins->rt];
			break;
		case 51: //AND
			value =reg[ins->rs]& reg[ins->rt];
			break;
		case 52: //OR
			value =reg[ins->rs]| reg[ins->rt];
			break;
		case 53: //XOR
			value =reg[ins->rs]^ reg[ins->rt];
			break;
		case 54: //NOR
			value = ~(reg[ins->rs] | reg[ins->rt]);
			break;
		case 55:{ //SLT
			if(reg[ins->rs] < reg[ins->rt])
				value=1;
			else
				value=0;
			break;
		}
		case 56: //ADDI
			value= reg[ins->rs]+ ins->imd;
			break;
		case 57: //ANDI
			value =reg[ins->rs]& ins->imd ;
			break;
		case 58: //ORI
			value =reg[ins->rs]| ins->imd ;
			break;
		case 59: //XORI
			value =reg[ins->rs]^ ins->imd ;
			break;
		default:
			return -1;
	}//end of switch
	
	return value;	
}
Esempio n. 11
0
static int riscv_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
{
    const int no_alias = 1;
    struct riscv_opcode *o = NULL;
    insn_t word = 0;
    int xlen = anal->bits;

    op->size = 4;
    op->addr = addr;
    op->type = R_ANAL_OP_TYPE_UNK;

    memcpy (&word, data, 4);
    o = get_opcode (word);
    if (o == NULL) {
        return op->size;
    }

    for(; o < &riscv_opcodes[NUMOPCODES]; o++) {
        if ( !(o->match_func)(o, word) ) continue;
        if ( no_alias && (o->pinfo & INSN_ALIAS) ) continue;
        if ( isdigit (o->subset[0]) && atoi (o->subset) != xlen) continue;
        else break;
    }
#define is_any(...) _is_any(NARGS(__VA_ARGS__), o->name, __VA_ARGS__)

// branch/jumps/calls/rets
    if (is_any ("jal")) {
        // decide wether it's ret or call
        int rd = (word >> OP_SH_RD) & OP_MASK_RD;
        op->type = (rd == 0) ? R_ANAL_OP_TYPE_RET : R_ANAL_OP_TYPE_CALL;
        op->jump = EXTRACT_UJTYPE_IMM (word) + addr;
        op->fail = addr + 4;
    } else if(is_any ("jr")) {
Esempio n. 12
0
Oid
equality_oper_funcid(Oid argtype)
{
	Oid	eq;
	get_sort_group_operators(argtype, false, true, false, NULL, &eq, NULL);
	return get_opcode(eq);
}
Esempio n. 13
0
void logWindow::appendText(AuditInfo *s){
	PERR("append Text");
	//logText->append(str);
	userText->append(s->m_UserName);
	userText->append("  ");
	clientText->append(s->m_ClientName);
	serverText->append(s->m_ServerName);
	opText->append(s->m_OperationName);
	timeText->append(s->m_time);
	timeText->append("  ");
	opText->append(get_opcode(s->m_OpCode));
	clientText->append(get_level(s->m_ClientBlpLevel));
	serverText->append(get_level(s->m_ServerBlpLevel));
	resultText->append(s->m_OpResult?"Allowed":"Denied");
	resultText->append(" ");
	//emit log_success();
	/*printlog(s[i].m_UserName,s[i].m_ClientName,s[i].m_ServerName);
				tolen15(s[i].m_OperationName);
				tolen10(s[i].m_time);
				tolen10(get_opcode(s[i].m_OpCode));
				tolen15(get_level(s[i].m_ClientBlpLevel));
				tolen15(get_level(s[i].m_ServerBlpLevel));
				tolen10(s[i].m_OpResult?"Allowed":"Denied");*/
	
}
Esempio n. 14
0
/*
 * execTuplesHashPrepare
 *		Look up the equality and hashing functions needed for a TupleHashTable.
 *
 * This is similar to execTuplesMatchPrepare, but we also need to find the
 * hash functions associated with the equality operators.  *eqFunctions and
 * *hashFunctions receive the palloc'd result arrays.
 *
 * Note: we expect that the given operators are not cross-type comparisons.
 */
void
execTuplesHashPrepare(int numCols,
					  Oid *eqOperators,
					  FmgrInfo **eqFunctions,
					  FmgrInfo **hashFunctions)
{
	int			i;

	*eqFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
	*hashFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));

	for (i = 0; i < numCols; i++)
	{
		Oid			eq_opr = eqOperators[i];
		Oid			eq_function;
		Oid			left_hash_function;
		Oid			right_hash_function;

		eq_function = get_opcode(eq_opr);
		if (!get_op_hash_functions(eq_opr,
								   &left_hash_function, &right_hash_function))
			elog(ERROR, "could not find hash function for hash operator %u",
				 eq_opr);
		/* We're not supporting cross-type cases here */
		Assert(left_hash_function == right_hash_function);
		fmgr_info(eq_function, &(*eqFunctions)[i]);
		fmgr_info(right_hash_function, &(*hashFunctions)[i]);
	}
}
Esempio n. 15
0
int step(s_emu *emu) {
    emu->display_changed = 0;
    if (execute_opcode(emu, get_opcode(emu)) < 0)
        return -1;
    emu->MC += 2;
    if (emu->delay_timer > 0) emu->delay_timer -= 1;
    if (emu->sound_timer > 0) emu->sound_timer -= 1;
}
Esempio n. 16
0
bool
is_change_PIC_reg(const insn_t *instr)
{
  const struct RP_opcode *rp = get_opcode(instr);
  if ( NULL == rp )
   return false;
  return is_change_reg(instr, rp, pic_reg);
}
Esempio n. 17
0
int execute_branch(struct decoded_ins *branch){ //return 1 for success, 0 failure
	clean_array();
	int i;
	for(i=0;i<cpre_issue->count;i++){
		ins2array(cpre_issue->q[i],i);
	}
	ins2array(branch,cpre_issue->count);

	if(ck_hazard(cpre_issue->count)){//if passed, execute it!
		int opcode;
		opcode = get_opcode(branch->binary);
		switch (opcode){
			case 18:{ //BEQ
				if(reg[branch->rt] == reg[branch->rs]){
					pc = pc +4 +branch->imd * 4;
					executed_ins = branch;
					waiting_ins =NULL;//afte exec, this should be NULL again
					return 1;;
				}
				else{
					pc+=4;
					executed_ins = branch;
					waiting_ins =NULL;
					return 1;;
				}
			}
			case 19:{ //BLTZ
				if(reg[branch->rs] < 0){
					pc = pc +4 +branch->imd * 4;
					executed_ins = branch;
					waiting_ins =NULL;
					return 1;;
				}
				else{
					pc+=4;
					executed_ins = branch;
					waiting_ins =NULL;
					return 1;;
				}
			}
			case 20:{ //BGTZ
				if(reg[branch->rs] > 0){
					pc = pc +4 +branch->imd * 4;
					executed_ins = branch;
					waiting_ins =NULL;
					return 1;;
				}
				else{
					pc+=4;
					executed_ins = branch;
					waiting_ins =NULL;
					return 1;;
				}
			}					
		}//end of switch
	}
	return 0;
}
Esempio n. 18
0
/*
 * Cache and return the procedure for the given strategy.
 */
FmgrInfo *
minmax_get_strategy_procinfo(BrinDesc *bdesc, uint16 attno, Oid subtype,
							 uint16 strategynum)
{
	MinmaxOpaque *opaque;

	Assert(strategynum >= 1 &&
		   strategynum <= BTMaxStrategyNumber);

	opaque = (MinmaxOpaque *) bdesc->bd_info[attno - 1]->oi_opaque;

	/*
	 * We cache the procedures for the previous subtype in the opaque struct,
	 * to avoid repetitive syscache lookups.  If the subtype changed,
	 * invalidate all the cached entries.
	 */
	if (opaque->cached_subtype != subtype)
	{
		uint16		i;

		for (i = 1; i <= BTMaxStrategyNumber; i++)
			opaque->strategy_procinfos[i - 1].fn_oid = InvalidOid;
		opaque->cached_subtype = subtype;
	}

	if (opaque->strategy_procinfos[strategynum - 1].fn_oid == InvalidOid)
	{
		Form_pg_attribute attr;
		HeapTuple	tuple;
		Oid			opfamily,
					oprid;
		bool		isNull;

		opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
		attr = bdesc->bd_tupdesc->attrs[attno - 1];
		tuple = SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily),
								ObjectIdGetDatum(attr->atttypid),
								ObjectIdGetDatum(subtype),
								Int16GetDatum(strategynum));

		if (!HeapTupleIsValid(tuple))
			elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
				 strategynum, attr->atttypid, subtype, opfamily);

		oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
												 Anum_pg_amop_amopopr, &isNull));
		ReleaseSysCache(tuple);
		Assert(!isNull && RegProcedureIsValid(oprid));

		fmgr_info_cxt(get_opcode(oprid),
					  &opaque->strategy_procinfos[strategynum - 1],
					  bdesc->bd_context);
	}

	return &opaque->strategy_procinfos[strategynum - 1];
}
Esempio n. 19
0
/*
 * op_volatile
 *
 * Get the provolatile flag for the operator's underlying function.
 */
char
op_volatile(Oid opno)
{
	RegProcedure funcid = get_opcode(opno);

	if (funcid == (RegProcedure) InvalidOid)
		elog(ERROR, "operator %u does not exist", opno);

	return func_volatile((Oid) funcid);
}
Esempio n. 20
0
/*
 * op_strict
 *
 * Get the proisstrict flag for the operator's underlying function.
 */
bool
op_strict(Oid opno)
{
	RegProcedure funcid = get_opcode(opno);

	if (funcid == (RegProcedure) InvalidOid)
		elog(ERROR, "operator %u does not exist", opno);

	return func_strict((Oid) funcid);
}
Esempio n. 21
0
void decode( char *instr, _decoder_output *out){
if(instr){
get_opcode(instr,out);
get_operands(instr,out);
}
else{
out->opc[0] = '\0';
}
set_reg_val(regfile+REG_NEXTPC,get_reg_val(REG_NEXTPC)+1);
}
Esempio n. 22
0
File: cycle.c Progetto: Nemh/chip8
Exec_info play_game()
{
	static int delay_t, sound_t;
	char pc_s[10];
	uint16_t next_instruction;
	int id_opcode;
	int debug = 0, key_menu = 0;
	Exec_info exec_info = {0,0,0};

	exec_info.tick_start = time_getTicks();

	while(!keydown(47)) {
		if(debug) {
			memset(pc_s, '*', 10);
			itoa(machine.pc, pc_s + 3);
			PrintXY(2, 8, pc_s, 0, 0);
			Bdisp_PutDisp_DD();
			OS_InnerWait_ms(800);
		}
		if(keydown(78)) debug ^= 1;
		if(keydown(48)) {
			while(key_menu != KEY_CTRL_MENU) {
				GetKey(&key_menu);
			}
		}

		next_instruction = (machine.memory[machine.pc])<<8 | machine.memory[machine.pc+1];
		id_opcode = get_opcode(next_instruction);

		(*do_opcode[id_opcode])(next_instruction);

		exec_info.cycles_count++;

		if(machine.delay > 0 && time_getTicks() - delay_t > TIMER_TICKS_PERIOD) {
			machine.delay --;
			delay_t = time_getTicks();
		}
		if(machine.sound > 0 && time_getTicks() - sound_t > TIMER_TICKS_PERIOD) {
			machine.sound --;
			sound_t = time_getTicks();
		}
		if(id_opcode == 28) delay_t == time_getTicks();
		else if(id_opcode == 29) sound_t == time_getTicks();

		if(machine.draw_state) {
			display();
			machine.draw_state = 0;
		}
	}
	exec_info.tick_end = time_getTicks();

	return exec_info;
}
Esempio n. 23
0
    // some operand forms adbance the PC,
    void Skip()
    {
        uint16_t instruction = m[pc++];
        uint16_t dest, src;
        uint8_t opcode = get_opcode(instruction);
        pc += advance_pc(get_operand(instruction, 1));

        if (opcode == NON_BASIC)
        {
        }


    }
Esempio n. 24
0
/* Processes a received WPS message and returns the message type */
enum wps_type process_wps_message(const void *data, size_t data_size) {
    const struct wpabuf *msg = NULL;
    enum wps_type type = UNKNOWN;
    struct wps_data *wps = get_wps();
    unsigned char *element_data = NULL;
    struct wfa_element_header element = {0};
    int i = 0, header_size = sizeof (struct wfa_element_header);

    /* Shove data into a wpabuf structure for processing */
    msg = wpabuf_alloc_copy(data, data_size);
    if (msg) {
        /* Process the incoming message */
        wps_registrar_process_msg(wps, get_opcode(), msg);
        wpabuf_free((struct wpabuf *) msg);

        /* Loop through until we hit the end of the data buffer */
        for (i = 0; i < data_size; i += header_size) {
            element_data = NULL;
            memset((void *) &element, 0, header_size);

            /* Get the element header data */
            memcpy((void *) &element, (data + i), header_size);
            element.type = htons(element.type);
            element.length = htons(element.length);

            /* Make sure the element length does not exceed the remaining buffer size */
            if (element.length <= (data_size - i - header_size)) {
                element_data = (unsigned char *) (data + i + header_size);

                switch (element.type) {
                    case MESSAGE_TYPE:
                        type = (uint8_t) element_data[0];
                        break;
                    case CONFIGURATION_ERROR:
                        /* Check element_data length */
                        if (element.length == 2)
                            set_nack_reason(htons(*((uint16_t*) element_data)));
                        break;
                    default:
                        break;
                }
            }

            /* Offset must include element length(s) */
            i += element.length;
        }

    }

    return type;
}
Esempio n. 25
0
/*
 * init_scankeys
 *
 * Initialize the scan keys.
 */
static void
init_scankeys(TupleDesc tupleDesc,
			  int nkeys, ScanKey scanKeys,
			  StrategyNumber *strategyNumbers)
{
	int keyNo;

	Assert(nkeys <= tupleDesc->natts);
	
	for (keyNo = 0; keyNo < nkeys; keyNo ++)
	{
		ScanKey scanKey = (ScanKey)(((char *)scanKeys) + 
									keyNo * sizeof(ScanKeyData));
		RegProcedure opfuncid;
		StrategyNumber strategyNumber = strategyNumbers[keyNo];

		Assert(strategyNumber <= BTMaxStrategyNumber &&
			   strategyNumber != InvalidStrategy);
		
		if (strategyNumber == BTEqualStrategyNumber)
		{
			opfuncid = equality_oper_funcid(tupleDesc->attrs[keyNo]->atttypid);
			ScanKeyEntryInitialize(scanKey,
								   0, /* sk_flag */
								   keyNo + 1, /* attribute number to scan */
								   BTEqualStrategyNumber, /* strategy */
								   InvalidOid, /* strategy subtype */
								   opfuncid, /* reg proc to use */
								   0 /* constant */
				);
		}
		else
		{
			Oid gtOid, leOid;
			
			gtOid = reverse_ordering_oper_opid(tupleDesc->attrs[keyNo]->atttypid);
			leOid = get_negator(gtOid);
			opfuncid = get_opcode(leOid);
			
			ScanKeyEntryInitialize(scanKey,
								   0, /* sk_flag */
								   keyNo + 1, /* attribute number to scan */
								   strategyNumber, /* strategy */
								   InvalidOid, /* strategy subtype */
								   opfuncid, /* reg proc to use */
								   0 /* constant */
				);
		}
	}
}
Esempio n. 26
0
/*
 * execTuplesMatchPrepare
 *		Look up the equality functions needed for execTuplesMatch or
 *		execTuplesUnequal, given an array of equality operator OIDs.
 *
 * The result is a palloc'd array.
 */
FmgrInfo *
execTuplesMatchPrepare(int numCols,
					   Oid *eqOperators)
{
	FmgrInfo   *eqFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
	int			i;

	for (i = 0; i < numCols; i++)
	{
		Oid			eq_opr = eqOperators[i];
		Oid			eq_function;

		eq_function = get_opcode(eq_opr);
		fmgr_info(eq_function, &eqFunctions[i]);
	}

	return eqFunctions;
}
Esempio n. 27
0
void
oj_program_parse (OJProgram *p, const char *program)
{
  char **lines;
  char *line;
  char *s;
  int i;

  lines = g_strsplit(program, "\n", 0);

  for(i=0;lines[i];i++){
    p->insn = p->insns + p->n_insns;
    line = lines[i];

    s = line;

    g_print("looking at \"%s\"\n", s);

    while (g_ascii_isspace (s[0])) s++;
    if (s[0] == 0 || s[0] == '#') continue;

    p->s = s;
    get_opcode (p);

    get_arg (p, 0);
    if (opcode_list[p->insn->opcode].n_args >= 2) {
      skip_comma (p);
      get_arg (p, 1);
      if (opcode_list[p->insn->opcode].n_args >= 3) {
        skip_comma (p);
        get_arg (p, 2);
      }
    }

    if (p->error) {
      g_print("error on line %d: %s at \"%s\"\n", i, p->error, p->s);
      g_free(p->error);
      p->error = NULL;
    }

    p->n_insns++;
  }
  g_strfreev (lines);
}
Esempio n. 28
0
File: ana.cpp Progetto: nealey/vera
// analyze an instruction
int ana(void) {
    bool special;
    int byte;

    byte = ua_next_byte();
    special = ana_special(byte);

    if ( !special ) {

        const struct opcode *op = get_opcode(byte);
        if ( op == NULL )        // unmatched insn
            return 0;

        cmd.itype = op->insn;
        fill_cmd(op->addr, get_opcode_flags(op->insn));
    }

    return cmd.size;
}
Esempio n. 29
0
File: pf_in.c Progetto: Gaffey/linux
enum reason_type get_ins_type(unsigned long ins_addr)
{
	unsigned int opcode;
	unsigned char *p;
	struct prefix_bits prf;
	int i;
	enum reason_type rv = OTHERS;

	p = (unsigned char *)ins_addr;
	p += skip_prefix(p, &prf);
	p += get_opcode(p, &opcode);

	CHECK_OP_TYPE(opcode, reg_rop, REG_READ);
	CHECK_OP_TYPE(opcode, reg_wop, REG_WRITE);
	CHECK_OP_TYPE(opcode, imm_wop, IMM_WRITE);

exit:
	return rv;
}
/*
 * Inet MCV vs MCV join selectivity estimation
 *
 * We simply add up the fractions of the populations that satisfy the clause.
 * The result is exact and does not need to be scaled further.
 */
static Selectivity
inet_mcv_join_sel(Datum *mcv1_values, float4 *mcv1_numbers, int mcv1_nvalues,
				  Datum *mcv2_values, float4 *mcv2_numbers, int mcv2_nvalues,
				  Oid operator)
{
	Selectivity selec = 0.0;
	FmgrInfo	proc;
	int			i,
				j;

	fmgr_info(get_opcode(operator), &proc);

	for (i = 0; i < mcv1_nvalues; i++)
	{
		for (j = 0; j < mcv2_nvalues; j++)
			if (DatumGetBool(FunctionCall2(&proc,
										   mcv1_values[i],
										   mcv2_values[j])))
				selec += mcv1_numbers[i] * mcv2_numbers[j];
	}
	return selec;
}