当前位置: 首页>>代码示例>>C++>>正文


C++ CMP函数代码示例

本文整理汇总了C++中CMP函数的典型用法代码示例。如果您正苦于以下问题:C++ CMP函数的具体用法?C++ CMP怎么用?C++ CMP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CMP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ll_to_n

void ll_to_n(num *a,ll n){
    ll hover[N];
    register int k=0;
    if(n==0){
        a->n=1;
        a->a[0]=0;
        a->sbit=PLUS;
        return;
    }
    a->sbit=CMP(n,0);
    n=n*a->sbit;
    while(n){
        hover[k++]=n%B;
        n/=B;
    }
    RM0(hover,k,a);
}
开发者ID:nphuc,项目名称:alg,代码行数:17,代码来源:karatsuba.c

示例2: compareResults

C4Err compareResults(const void* expected, const void* calculated, size_t len,
                        DumpFormatType format, char* comment  )
{
    C4Err err = kC4Err_NoErr;
    
    err = CMP(expected, calculated, len)
    ? kC4Err_NoErr : kC4Err_SelfTestFailed;
    
    if( (err != kC4Err_NoErr)  && IsntNull(comment) && (format != kResultFormat_None))
    {
        OPTESTLogError( "\n\t\tFAILED %s\n",comment );
        switch(format)
        {
            case kResultFormat_Byte:
                OPTESTLogError( "\t\texpected:\n");
                dumpHex(IF_LOG_ERROR, ( uint8_t*) expected, (int)len, 0);
                OPTESTLogError( "\t\tcalulated:\n");
                dumpHex(IF_LOG_ERROR,( uint8_t*) calculated, (int)len, 0);
                OPTESTLogError( "\n");
                break;
                
            case kResultFormat_Long:
                OPTESTLogError( "\t\texpected:\n");
                dump64(IF_LOG_ERROR,( uint8_t*) expected, len);
                OPTESTLogError( "\t\tcalulated:\n");
                dump64(IF_LOG_ERROR,( uint8_t*) calculated, len );
                OPTESTLogError( "\n");
                break;
                
            case kResultFormat_Cstr:
                OPTESTLogError( "\t\texpected:\n");
                dump8(IF_LOG_ERROR,( uint8_t*) expected, len);
                OPTESTLogError( "\t\tcalulated:\n");
                dump8(IF_LOG_ERROR,( uint8_t*) calculated, len );
                OPTESTLogError( "\n");
                break;
               
                
            default:
                break;
        }
    }
    
    return err;
}
开发者ID:rhardman,项目名称:C4,代码行数:45,代码来源:optestutilities.c

示例3: cmp_mon_ref

static ERTS_INLINE int cmp_mon_ref(Eterm ref1, Eterm ref2) 
{
    Eterm *b1, *b2;


    b1 = boxed_val(ref1);
    b2 = boxed_val(ref2);
    if (is_ref_thing_header(*b1)) {
	if (is_ref_thing_header(*b2)) {
	    return memcmp(b1+1,b2+1,ERTS_REF_WORDS*sizeof(Uint));
	}
	return -1;
    }
    if (is_ref_thing_header(*b2)) {
	return 1;
    }
    return CMP(ref1,ref2);
}
开发者ID:DavidAlphaFox,项目名称:my_otp,代码行数:18,代码来源:erl_monitors.c

示例4: check_crc

/* detect if a block is used in a particular pattern */
static int
check_crc(const u_char *S, const u_char *buf, u_int32_t len)
{
	u_int32_t crc;
	const u_char *c;

	crc = 0;
	for (c = buf; c < buf + len; c += SSH_BLOCKSIZE) {
		if (!CMP(S, c)) {
			crc_update(&crc, 1);
			crc_update(&crc, 0);
		} else {
			crc_update(&crc, 0);
			crc_update(&crc, 0);
		}
	}
	return crc == 0;
}
开发者ID:randombit,项目名称:hacrypto,代码行数:19,代码来源:deattack.c

示例5: main

int main(int argc, char* argv[])
{
  const size_t size = (argc > 1) ? atoi(argv[1]) : 32;
  cmpvec inputData;
  for (size_t i = 0; i < size; ++i) {
    inputData.push_back(CMP(0.1 + i, 0.2 * i));
  }

  cmpvec bf;
  ft_bf(size, inputData, bf);

  if (0) {
    cmpvec gsl;
    ft_gsl(size, inputData, gsl);
    print_diff(bf, gsl);
  }

  if(0) {
    cmpvec fftw;
    ft_fftw(size, inputData, fftw);
    print_diff(bf, fftw);
  }

  if(0) {
    cmpvec fftw_d;
    const int isz = size;
    ft_fftw_d(1, &isz, inputData, fftw_d);
    print_diff(bf, fftw_d);
  }

  if(1) {
    cmpvec fftw_d1;
    const int sz1[] = { 3, 5 };
    ft_fftw_d(2, &sz1[0], inputData, fftw_d1);

    cmpvec fftw_d2;
    const int sz2[] = { 5, 3  };
    ft_fftw_d(2, &sz2[0], inputData, fftw_d2);

    print_both(fftw_d1, fftw_d2);
  }

  return 0;
}
开发者ID:fatchat,项目名称:fft_pricing,代码行数:44,代码来源:fft_test.cpp

示例6: heap_push

void heap_push(heap* h, heap_type datum) {
  // resize if necessary, with a doubling strategy
  if ( h->count == h->allocated ) {
    h->allocated <<= 1;
    h->data = SAFEREALLOC(h->data, sizeof(heap_type) * h->allocated);    
  }
  
  // and insert element
  unsigned int index, parent;
  for ( index = h->count++,
	  parent = (index - 1) >> 1;
	index &&
	  !CMP(h->data[parent], datum);
	index = parent,
	  parent = (index - 1) >> 1)
    {
      h->data[index] = h->data[parent];
    }
  h->data[index] = datum;
}
开发者ID:beneills,项目名称:world,代码行数:20,代码来源:heap.c

示例7: qsort_chk

/* Verify anti-symmetry and transitivity for comparator CMP on sorted array
   of N SIZE-sized elements pointed to by BASE.  */
void
qsort_chk (void *base, size_t n, size_t size,
	   int (*cmp)(const void *, const void *))
{
#if 0
#define LIM(n) (n)
#else
  /* Limit overall time complexity to O(n log n).  */
#define LIM(n) ((n) <= 16 ? (n) : 12 + floor_log2 (n))
#endif
#define ELT(i) ((const char *) base + (i) * size)
#define CMP(i, j) cmp (ELT (i), ELT (j))
#define ERR2(i, j) qsort_chk_error (ELT (i), ELT (j), NULL, cmp)
#define ERR3(i, j, k) qsort_chk_error (ELT (i), ELT (j), ELT (k), cmp)
  size_t i1, i2, i, j;
  /* This outer loop iterates over maximum spans [i1, i2) such that
     elements within each span compare equal to each other.  */
  for (i1 = 0; i1 < n; i1 = i2)
    {
      /* Position i2 one past last element that compares equal to i1'th.  */
      for (i2 = i1 + 1; i2 < n; i2++)
	if (CMP (i1, i2))
	  break;
	else if (CMP (i2, i1))
	  return ERR2 (i1, i2);
      size_t lim1 = LIM (i2 - i1), lim2 = LIM (n - i2);
      /* Verify that other pairs within current span compare equal.  */
      for (i = i1 + 1; i + 1 < i2; i++)
	for (j = i + 1; j < i1 + lim1; j++)
	  if (CMP (i, j))
	    return ERR3 (i, i1, j);
	  else if (CMP (j, i))
	    return ERR2 (i, j);
      /* Verify that elements within this span compare less than
         elements beyond the span.  */
      for (i = i1; i < i2; i++)
	for (j = i2; j < i2 + lim2; j++)
	  if (CMP (i, j) >= 0)
	    return ERR3 (i, i1, j);
	  else if (CMP (j, i) <= 0)
	    return ERR2 (i, j);
    }
#undef ERR3
#undef ERR2
#undef CMP
#undef ELT
#undef LIM
}
开发者ID:vinriviere,项目名称:m68k-atari-mint-gcc,代码行数:50,代码来源:vec.c

示例8: tm_is_lessthan

static int tm_is_lessthan(struct tm *x, struct tm *y)
{
#define CMP(f)                                                                                                                     \
    if (x->f < y->f)                                                                                                               \
        return 1;                                                                                                                  \
    else if (x->f > y->f)                                                                                                          \
        return 0;
    CMP(tm_year);
    CMP(tm_mon);
    CMP(tm_mday);
    CMP(tm_hour);
    CMP(tm_min);
    CMP(tm_sec);
    return 0;
#undef CMP
}
开发者ID:ancuop,项目名称:h2o,代码行数:16,代码来源:file.c

示例9: _dbg_assert_msg_

void Jit::WriteExit(u32 destination, int exit_num)
{
	_dbg_assert_msg_(JIT, exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num");

	if (!Memory::IsValidAddress(destination)) {
		ERROR_LOG_REPORT(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc);
	}
	// If we need to verify coreState and rewind, we may not jump yet.
	if (js.afterOp & (JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE))
	{
		// CORE_RUNNING is <= CORE_NEXTFRAME.
		CMP(32, M((void*)&coreState), Imm32(CORE_NEXTFRAME));
		FixupBranch skipCheck = J_CC(CC_LE);
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		WriteSyscallExit();
		SetJumpTarget(skipCheck);

		js.afterOp = JitState::AFTER_NONE;
	}

	WriteDowncount();

	//If nobody has taken care of this yet (this can be removed when all branches are done)
	JitBlock *b = js.curBlock;
	b->exitAddress[exit_num] = destination;
	b->exitPtrs[exit_num] = GetWritableCodePtr();

	// Link opportunity!
	int block = blocks.GetBlockNumberFromStartAddress(destination);
	if (block >= 0 && jo.enableBlocklink) {
		// It exists! Joy of joy!
		JMP(blocks.GetBlock(block)->checkedEntry, true);
		b->linkStatus[exit_num] = true;
	} else {
		// No blocklinking.
		MOV(32, M(&mips_->pc), Imm32(destination));
		JMP(asm_.dispatcher, true);
	}
}
开发者ID:Versus9,项目名称:ppsspp,代码行数:39,代码来源:Jit.cpp

示例10: conf_sort

static int
conf_sort(const void *v1, const void *v2)
{
	const struct conf *c1 = v1;
	const struct conf *c2 = v2;

#define CMP(a, b, f) \
	if ((a)->f > (b)->f) return -1; \
	else if ((a)->f < (b)->f) return 1

	CMP(c1, c2, c_ss.ss_family);
	CMP(c1, c2, c_lmask);
	CMP(c1, c2, c_port);
	CMP(c1, c2, c_proto);
	CMP(c1, c2, c_family);
	CMP(c1, c2, c_rmask);
	CMP(c1, c2, c_uid);
#undef CMP
	return 0;
}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:20,代码来源:conf.c

示例11: hashset_add

int hashset_add(hashset_p set, const void *item, size_t bytes)
{
	slot_p slot = NULL, new_slot = NULL;

	slotlist_p slotlist = &set->slotlists[HASH(set, item, bytes) % set->slotlists_n];
	slot_p *pslot = &slotlist->list;

	int is_new = !(slot = *pslot);

	while (slot) {
		if (!CMP(set, &slot->data, item, bytes)) {
			return -1;
		}
		pslot = &slot->next;
		slot = *pslot;
	}

	*pslot = new_slot = (slot_p) malloc(bytes + sizeof(slot_p));
	if (!new_slot) {
		return -2;
	}
	new_slot->next = NULL;

	memcpy(&new_slot->data, item, bytes);

	if (!set->non_null) {
		set->non_null = slotlist;
	} else if (is_new) {
		set->non_null->pre = slotlist;
		slotlist->next = set->non_null;
		set->non_null = slotlist;
	}

	++set->size;

	return 0;
}
开发者ID:nicky-zs,项目名称:dbscan,代码行数:37,代码来源:hashset.c

示例12: TopK

	//统计出现次数最多的前K种水果
	void TopK(vector<string>& fruits)
	{
		//统计水果出现的次数
		map<string, int> fruitCount;
		size_t size = fruits.size();
		for (size_t i = 0; i < size; ++i)
		{
			fruitCount[fruits[i]]++;
		}

		//排序
		vector<map<string, int>::iterator> v; //将数据保存在可以随机访问的容器里。
		map<string, int>::iterator it = fruitCount.begin();
		while (it != fruitCount.end())
		{
			v.push_back(it);
			++it;
		}

		struct CMP
		{
			bool operator()(const map<string, int>::iterator l,
							const map<string, int>::iterator r) const
			{
				return (l->second > r->second);
			}
		};
		sort(v.begin(), v.end(), CMP());
		
		//输出排序结果
		for (size_t i = 0; i < v.size(); ++i)
		{
			cout << v[i]->first << "-" << v[i]->second << endl;
		}
		
	}
开发者ID:XHfight,项目名称:Data-Structure,代码行数:37,代码来源:Test.cpp

示例13: try_lcs

static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
	int line1, int count1, int line2, int count2)
{
	unsigned int b_next = b_ptr + 1;
	struct record *rec = index->records[TABLE_HASH(index, 2, b_ptr)];
	unsigned int as, ae, bs, be, np, rc;
	int should_break;

	for (; rec; rec = rec->next) {
		if (rec->cnt > index->cnt) {
			if (!index->has_common)
				index->has_common = CMP(index, 1, rec->ptr, 2, b_ptr);
			continue;
		}

		as = rec->ptr;
		if (!CMP(index, 1, as, 2, b_ptr))
			continue;

		index->has_common = 1;
		for (;;) {
			should_break = 0;
			np = NEXT_PTR(index, as);
			bs = b_ptr;
			ae = as;
			be = bs;
			rc = rec->cnt;

			while (line1 < (int)as && line2 < (int)bs
				&& CMP(index, 1, as - 1, 2, bs - 1)) {
				as--;
				bs--;
				if (1 < rc)
					rc = XDL_MIN(rc, CNT(index, as));
			}
			while ((int)ae < LINE_END(1) && (int)be < LINE_END(2)
				&& CMP(index, 1, ae + 1, 2, be + 1)) {
				ae++;
				be++;
				if (1 < rc)
					rc = XDL_MIN(rc, CNT(index, ae));
			}

			if (b_next <= be)
				b_next = be + 1;
			if (lcs->end1 - lcs->begin1 < ae - as || rc < index->cnt) {
				lcs->begin1 = as;
				lcs->begin2 = bs;
				lcs->end1 = ae;
				lcs->end2 = be;
				index->cnt = rc;
			}

			if (np == 0)
				break;

			while (np <= ae) {
				np = NEXT_PTR(index, np);
				if (np == 0) {
					should_break = 1;
					break;
				}
			}

			if (should_break)
				break;

			as = np;
		}
	}
	return b_next;
}
开发者ID:KillTheMule,项目名称:neovim,代码行数:72,代码来源:xhistogram.c

示例14: eval_3OP_Int

/* Process 3OP Integer instructions */
bool eval_3OP_Int(struct lilith* vm, struct Instruction* c)
{
	#ifdef DEBUG
	char Name[20] = "ILLEGAL_3OP";
	#endif

	switch(c->raw_XOP)
	{
		case 0x000: /* ADD */
		{
			#ifdef DEBUG
			strncpy(Name, "ADD", 19);
			#elif TRACE
			record_trace("ADD");
			#endif

			ADD(vm, c);
			break;
		}
		case 0x001: /* ADDU */
		{
			#ifdef DEBUG
			strncpy(Name, "ADDU", 19);
			#elif TRACE
			record_trace("ADDU");
			#endif

			ADDU(vm, c);
			break;
		}
		case 0x002: /* SUB */
		{
			#ifdef DEBUG
			strncpy(Name, "SUB", 19);
			#elif TRACE
			record_trace("SUB");
			#endif

			SUB(vm, c);
			break;
		}
		case 0x003: /* SUBU */
		{
			#ifdef DEBUG
			strncpy(Name, "SUBU", 19);
			#elif TRACE
			record_trace("SUBU");
			#endif

			SUBU(vm, c);
			break;
		}
		case 0x004: /* CMP */
		{
			#ifdef DEBUG
			strncpy(Name, "CMP", 19);
			#elif TRACE
			record_trace("CMP");
			#endif

			CMP(vm, c);
			break;
		}
		case 0x005: /* CMPU */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPU", 19);
			#elif TRACE
			record_trace("CMPU");
			#endif

			CMPU(vm, c);
			break;
		}
		case 0x006: /* MUL */
		{
			#ifdef DEBUG
			strncpy(Name, "MUL", 19);
			#elif TRACE
			record_trace("MUL");
			#endif

			MUL(vm, c);
			break;
		}
		case 0x007: /* MULH */
		{
			#ifdef DEBUG
			strncpy(Name, "MULH", 19);
			#elif TRACE
			record_trace("MULH");
			#endif

			MULH(vm, c);
			break;
		}
		case 0x008: /* MULU */
		{
			#ifdef DEBUG
//.........这里部分代码省略.........
开发者ID:oriansj,项目名称:stage0,代码行数:101,代码来源:vm_decode.c

示例15: JITDISABLE

void JitArm::fctiwx(UGeckoInstruction inst)
{
	INSTRUCTION_START
	JITDISABLE(bJITFloatingPointOff)
	u32 b = inst.FB;
	u32 d = inst.FD;

	ARMReg vB = fpr.R0(b);
	ARMReg vD = fpr.R0(d);
	ARMReg V0 = fpr.GetReg();
	ARMReg V1 = fpr.GetReg();
	ARMReg V2 = fpr.GetReg();

	ARMReg rA = gpr.GetReg();
	ARMReg fpscrReg = gpr.GetReg();

	FixupBranch DoneMax, DoneMin;
	LDR(fpscrReg, R9, PPCSTATE_OFF(fpscr));
	MOVI2R(rA, (u32)minmaxFloat);

	// Check if greater than max float
	{
		VLDR(V0, rA, 8); // Load Max
		VCMPE(vB, V0);
		VMRS(_PC); // Loads in to APSR
		FixupBranch noException = B_CC(CC_LE);
		VMOV(vD, V0); // Set to max
		SetFPException(fpscrReg, FPSCR_VXCVI);
		DoneMax = B();
		SetJumpTarget(noException);
	}
	// Check if less than min float
	{
		VLDR(V0, rA, 0);
		VCMPE(vB, V0);
		VMRS(_PC);
		FixupBranch noException = B_CC(CC_GE);
		VMOV(vD, V0);
		SetFPException(fpscrReg, FPSCR_VXCVI);
		DoneMin = B();
		SetJumpTarget(noException);
	}
	// Within ranges, convert to integer
	// Set rounding mode first
	// PPC <-> ARM rounding modes
	// 0, 1, 2, 3 <-> 0, 3, 1, 2
	ARMReg rB = gpr.GetReg();
	VMRS(rA);
	// Bits 22-23
	BIC(rA, rA, Operand2(3, 5));

	LDR(rB, R9, PPCSTATE_OFF(fpscr));
	AND(rB, rB, 0x3); // Get the FPSCR rounding bits
	CMP(rB, 1);
	SetCC(CC_EQ); // zero
		ORR(rA, rA, Operand2(3, 5));
	SetCC(CC_NEQ);
		CMP(rB, 2); // +inf
		SetCC(CC_EQ);
			ORR(rA, rA, Operand2(1, 5));
		SetCC(CC_NEQ);
			CMP(rB, 3); // -inf
			SetCC(CC_EQ);
				ORR(rA, rA, Operand2(2, 5));
	SetCC();
	VMSR(rA);
	ORR(rA, rA, Operand2(3, 5));
	VCVT(vD, vB, TO_INT | IS_SIGNED);
	VMSR(rA);
	gpr.Unlock(rB);
	VCMPE(vD, vB);
	VMRS(_PC);

	SetCC(CC_EQ);
		BIC(fpscrReg, fpscrReg, FRFIMask);
		FixupBranch DoneEqual = B();
	SetCC();
	SetFPException(fpscrReg, FPSCR_XX);
	ORR(fpscrReg, fpscrReg, FIMask);
	VABS(V1, vB);
	VABS(V2, vD);
	VCMPE(V2, V1);
	VMRS(_PC);
	SetCC(CC_GT);
		ORR(fpscrReg, fpscrReg, FRMask);
	SetCC();
	SetJumpTarget(DoneEqual);

	SetJumpTarget(DoneMax);
	SetJumpTarget(DoneMin);

	MOVI2R(rA, (u32)&doublenum);
	VLDR(V0, rA, 0);
	NEONXEmitter nemit(this);
	nemit.VORR(vD, vD, V0);

	if (inst.Rc) Helper_UpdateCR1(fpscrReg, rA);

	STR(fpscrReg, R9, PPCSTATE_OFF(fpscr));
	gpr.Unlock(rA);
//.........这里部分代码省略.........
开发者ID:Bigorneau,项目名称:dolphin,代码行数:101,代码来源:JitArm_FloatingPoint.cpp


注:本文中的CMP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。