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


C++ GET_BIT函数代码示例

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


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

示例1: sgen_run_generator

void sgen_run_generator(struct sgen_generator *g, struct codec *c, sample_t *buf, ssize_t frames)
{
	sample_t s;
	double t;
	ssize_t i, k, samples;
	switch (g->type) {
	case SGEN_TYPE_DELTA:
		if (g->offset >= 0) {
			if (g->offset < frames)
				for (i = 0; i < c->channels; ++i)
					if (GET_BIT(g->channel_selector, i))
						buf[g->offset * c->channels + i] += 1.0;
			g->offset -= frames;
		}
		break;
	case SGEN_TYPE_SINE:
		samples = frames * c->channels;
		for (i = 0; i < samples; i += c->channels) {
			t = (double) g->pos / c->fs;
			if (g->v != 0.0)
				s = sin(g->freq0 / g->v * (exp(t * g->v) - 1.0));
			else
				s = sin(g->freq0 * t);
			for (k = 0; k < c->channels; ++k)
				if (GET_BIT(g->channel_selector, k))
					buf[i + k] += s;
			++g->pos;
		}
		break;
	}
}
开发者ID:bmc0,项目名称:dsp,代码行数:31,代码来源:sgen.c

示例2: app_preload

/*
 * Boot module scope
 */
int
app_preload(struct app_t *app, int argc, char **argv)
{
	struct module_t *module = app->data;
	struct app_opt_t *app_opt;

	if(NULL == module)
		return E_MOD;

	app_opt = app->opts;
	log(app->ctx,1,"app preload: %s\n", module->name);

	/* Must be boot type */
	if(!GET_BIT(module->type, M_BOOT))
		return E_CONF;

	if(!GET_BIT(module->type, M_EMBED))
		log(app->ctx, 1, "Warn: app module not embedded!\n");

	app->ctx->boot->module = module;

	if(module->preload(app->ctx, app->ctx->boot))
		return E_CONF;

	/* Now register app and we are ready to go */
	if(!register_app(app->ctx, app))
		return E_CONF;

	return E_NONE;
}
开发者ID:melkior,项目名称:sipware,代码行数:33,代码来源:app.c

示例3: calculate_heuristics

/**
 * Calculates the heuristic score for the AI
 */
heuristic_t calculate_heuristics(int isItSelfTurn) {
    // Turn bonus
    heuristic_t score = (isItSelfTurn << 3) - (isItSelfTurn << 1) - 3; //isItSelfTurn*6-3

    // Material + king bonus
    score += population_score();

    // Runaway man
    /*score += ((0x00000010 & (gamestate.self & (~gamestate.kings))) && !(0x00000001 & gamestate.occupied)) * 47;
    score -= ((0x01000000 & (gamestate.other & (~gamestate.kings))) && !(0x30000000 & gamestate.occupied)) * 47;
    score += ((0x00000020 & (gamestate.self & (~gamestate.kings))) && !(0x00000003 & gamestate.occupied)) * 47;
    score -= ((0x02000000 & (gamestate.other & (~gamestate.kings))) && !(0x60000000 & gamestate.occupied)) * 47;
    score += ((0x00000040 & (gamestate.self & (~gamestate.kings))) && !(0x00000006 & gamestate.occupied)) * 47;
    score -= ((0x04000000 & (gamestate.other & (~gamestate.kings))) && !(0xC0000000 & gamestate.occupied)) * 47;
    score += ((0x00000080 & (gamestate.self & (~gamestate.kings))) && !(0x0000000C & gamestate.occupied)) * 47;
    score -= ((0x08000000 & (gamestate.other & (~gamestate.kings))) && !(0x80000000 & gamestate.occupied)) * 47;
    score += ((0x00000100 & (gamestate.self & (~gamestate.kings))) && !(0x00000011 & gamestate.occupied)) * 44;
    score -= ((0x00100000 & (gamestate.other & (~gamestate.kings))) && !(0x31000000 & gamestate.occupied)) * 44;
    score += ((0x00000200 & (gamestate.self & (~gamestate.kings))) && !(0x00000067 & gamestate.occupied)) * 44;
    score -= ((0x00200000 & (gamestate.other & (~gamestate.kings))) && !(0x73000000 & gamestate.occupied)) * 44;
    score += ((0x00000400 & (gamestate.self & (~gamestate.kings))) && !(0x000000CE & gamestate.occupied)) * 44;
    score -= ((0x00400000 & (gamestate.other & (~gamestate.kings))) && !(0xE6000000 & gamestate.occupied)) * 44;
    score += ((0x00000800 & (gamestate.self & (~gamestate.kings))) && !(0x0000008C & gamestate.occupied)) * 44;
    score -= ((0x00800000 & (gamestate.other & (~gamestate.kings))) && !(0x88000000 & gamestate.occupied)) * 44;*/

    // Back row bonus
    score += population_count(0xF0000000 & gamestate.occupied) * 7;
    score -= population_count(0x0000000F & gamestate.occupied) * 7;

    // Dog hole penalty
    score += (GET_BIT(gamestate.other, 27) && GET_BIT(gamestate.self, 31)) * 10;
    score -= (GET_BIT(gamestate.self, 4) && GET_BIT(gamestate.other, 0)) * 10;

    return score;
}
开发者ID:emiltayl,项目名称:Aimesbot-checkers,代码行数:38,代码来源:heuristics.c

示例4: compress_effect_run

void compress_effect_run(struct effect *e, ssize_t *frames, sample_t *ibuf, sample_t *obuf)
{
    ssize_t i, k, samples = *frames * e->ostream.channels;
    sample_t s, gain_target;
    struct compress_state *state = (struct compress_state *) e->data;
    for (i = 0; i < samples; i += e->ostream.channels) {
        s = 0;
        for (k = 0; k < e->ostream.channels; ++k)
            if (GET_BIT(e->channel_selector, k))
                s = MAXIMUM(fabs(ibuf[i + k]), s);
        if (s > state->thresh)
            gain_target = pow(10, (state->thresh_db - (20 * log10(s))) * state->ratio / 20);
        else
            gain_target = 1.0;
        if (state->gain > gain_target) {
            state->gain *= state->attack;
            if (state->gain < gain_target)
                state->gain = gain_target;
        }
        else if (state->gain < gain_target) {
            state->gain *= state->release;
            if (state->gain > gain_target)
                state->gain = gain_target;
        }
        for (k = 0; k < e->ostream.channels; ++k) {
            if (GET_BIT(e->channel_selector, k))
                obuf[i + k] = ibuf[i + k] * state->gain;
            else
                obuf[i + k] = ibuf[i + k];
        }
    }
}
开发者ID:kernelOfTruth,项目名称:dsp,代码行数:32,代码来源:compress.c

示例5: controlBrakePostfire

void controlBrakePostfire(int hasEventFlags, int craneKnownFlags, 
        int cranePresentFlags) {

    switch(state) {
        case READY : {
            if(GET_BIT(craneKnownFlags, TRIGGERBIT)) {
                if(GET_BIT(cranePresentFlags, TRIGGERBIT)) {
                    state = RUNNING;
                }
            }
        } break;

        case RUNNING : {
            if(GET_BIT(hasEventFlags, SHUTDOWNBIT)) {
                initControlBrake();
                break;
            }

            if(GET_BIT(craneKnownFlags, EMSTOPMERGERBIT)) {
                if(GET_BIT(cranePresentFlags, EMSTOPMERGERBIT)) {
                    initControlBrake();
                }
            }
        } break;
    }
}
开发者ID:ivanjeukens,项目名称:verifier-ptolemy,代码行数:26,代码来源:controlbrake.c

示例6: key_pressed

int key_pressed(r,c) {
	if (!GET_BIT(PINC, r)) {
		if (!GET_BIT(PORTC, c))
		return 1;
	}
	return 0;
}
开发者ID:eputh,项目名称:Play-Music,代码行数:7,代码来源:keypad.c

示例7: captureLine

Board captureLine(Board b, int moveIndex, int player, short dX, short dY) {
	Board bc = b;
	while ( 1 ) {
		// Left side out of bounds
		if( dX < 0 && moveIndex % 8 == 0) {
			return b;
		}
		// Right side out of bounds
		if ( dX > 0 && moveIndex % 8 == 7) {
			return b;
		}
		moveIndex += dX + dY * 8;
		// Upper edge & lower edge out of bounds
		if ( moveIndex < 0 || moveIndex > 63 ) {
			return b;
		}
		else if ( ! GET_BIT(b.mask, moveIndex) ) {
			return b;
		}
		else if ( GET_BIT(b.owner, moveIndex) ^ player){
			bc.owner = TOGGLE_BIT(bc.owner, moveIndex);
		}
		else {
			return bc;
		}
	}
	return b; // Never reached, included for compiler warnings
}
开发者ID:juckele,项目名称:othello,代码行数:28,代码来源:othello.c

示例8: convCmp_bitMask

/* returns 0 if bmsk and src dont match, 1 if they do */
int
convCmp_bitMask(Byte bmsk, Byte src, int istart, int iend)
{
    int ret = 1;
    if (!iend) {
        /* if there's only one index number to check (iend = 0) */
	if (GET_BIT(bmsk, 0) != GET_BIT(src, istart)) {
	    return 0;
	}
        else {
            return 1;
	}
    }
    /* if there's a group of index numbers to check */
    else {
	int i, x;
        for (i = istart, x = 0; i < iend; i++, x++) {
            if (GET_BIT(src, i) != GET_BIT(bmsk, x)) {
                ret = 0;
                break;
            }
        }
    }
    return ret;
}
开发者ID:jeffrom,项目名称:junoboss,代码行数:26,代码来源:bithex.c

示例9: pressed

_Bool pressed(int col, int row)
{
	CLR_BIT(PORTC, col);
	_Bool buttonPressed = !GET_BIT(PINC, col) && !GET_BIT(PINC, row);
	
	return !GET_BIT(PINC, col) && !GET_BIT(PINC, row);
}
开发者ID:ellenmliu,项目名称:CS145,代码行数:7,代码来源:avr.c

示例10: app_boot

/*
 * Boot.
 * Squat app/module is using it
 */
struct ctx_t *
app_boot(struct ctx_t *cur, void *a, void *args)
{
	app_getopt *opts = args;
	struct app_t *app = a;
	struct cfg_t *cfg;

	if(NULL == cur)
	{
		if(app->ctx)
			log(app->ctx, 1, "Alredy got app->ctx!\n");

		app->ctx = ctx_new(CTX_STDERR|CTX_BOOT);

		if (NULL == app->ctx)
			return NULL;
	}
	else
		app->ctx = cur;

	cfg = app->ctx->cfg;
	set_early_log(app->ctx);

	/* Ok we really really need this very early */
	if(NULL == sys_create(app->ctx, "api", T_HASH))
		return NULL;

	/*if(NULL == sys_create(app->ctx, "parser", T_STORE))
		return NULL;*/

	log(app->ctx, 0, "app boot: %s\n", app->name);

	/*
	 * Default handler is sig_run
	 * sig_run is responsible of traversing ctx/scope
	 * and run all handlers that are registered
	 */
	/*signal(SIGINT, sig_run);
	signal(SIGHUP, sig_run);
	signal(SIGTERM, sig_run);
	signal(SIGSEGV, sig_run);
	signal(SIGBUS, sig_run);*/

	/* reset to default boot options */
	if(GET_BIT(app->type, APP_DAEMON))
		cfg->basic->daemon = 1;

	if(GET_BIT(app->type, APP_LOG))
		cfg->basic->prio = 1;

	/* cfg */
	cfg->basic->argc = opts->argc;
	cfg->basic->argv = opts->argv;

	optind = 1;
	return app->ctx;
}
开发者ID:melkior,项目名称:sipware,代码行数:61,代码来源:app.c

示例11: rewrite_source

static void rewrite_source(struct radeon_compiler * c,
		struct rc_instruction * inst, unsigned src)
{
	struct rc_swizzle_split split;
	unsigned int tempreg = rc_find_free_temporary(c);
	unsigned int usemask;

	usemask = 0;
	for(unsigned int chan = 0; chan < 4; ++chan) {
		if (GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan) != RC_SWIZZLE_UNUSED)
			usemask |= 1 << chan;
	}

	c->SwizzleCaps->Split(inst->U.I.SrcReg[src], usemask, &split);

	for(unsigned int phase = 0; phase < split.NumPhases; ++phase) {
		struct rc_instruction * mov = rc_insert_new_instruction(c, inst->Prev);
		unsigned int phase_refmask;
		unsigned int masked_negate;

		mov->U.I.Opcode = RC_OPCODE_MOV;
		mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
		mov->U.I.DstReg.Index = tempreg;
		mov->U.I.DstReg.WriteMask = split.Phase[phase];
		mov->U.I.SrcReg[0] = inst->U.I.SrcReg[src];
		mov->U.I.PreSub = inst->U.I.PreSub;

		phase_refmask = 0;
		for(unsigned int chan = 0; chan < 4; ++chan) {
			if (!GET_BIT(split.Phase[phase], chan))
				SET_SWZ(mov->U.I.SrcReg[0].Swizzle, chan, RC_SWIZZLE_UNUSED);
			else
				phase_refmask |= 1 << GET_SWZ(mov->U.I.SrcReg[0].Swizzle, chan);
		}

		phase_refmask &= RC_MASK_XYZW;

		masked_negate = split.Phase[phase] & mov->U.I.SrcReg[0].Negate;
		if (masked_negate == 0)
			mov->U.I.SrcReg[0].Negate = 0;
		else if (masked_negate == split.Phase[phase])
			mov->U.I.SrcReg[0].Negate = RC_MASK_XYZW;

	}

	inst->U.I.SrcReg[src].File = RC_FILE_TEMPORARY;
	inst->U.I.SrcReg[src].Index = tempreg;
	inst->U.I.SrcReg[src].Swizzle = 0;
	inst->U.I.SrcReg[src].Negate = RC_MASK_NONE;
	inst->U.I.SrcReg[src].Abs = 0;
	for(unsigned int chan = 0; chan < 4; ++chan) {
		SET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan,
				GET_BIT(usemask, chan) ? chan : RC_SWIZZLE_UNUSED);
	}
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:55,代码来源:radeon_dataflow_swizzles.c

示例12: perm_to_str

void perm_to_str(int perm, char str[4])
{
    strcpy(str, "rwx");

    if(GET_BIT(perm, 2) == 0)
        str[0] = '-';

    if(GET_BIT(perm, 1) == 0)
        str[1] = '-';

    if(GET_BIT(perm, 0) == 0)
        str[2] = '-';
}
开发者ID:HackLinux,项目名称:ARM-emulator,代码行数:13,代码来源:segment.c

示例13: read_pagemap

int read_pagemap(char * path_buf, unsigned long virt_addr){
   printf("Big endian? %d\n", is_bigendian());
   f = fopen(path_buf, "rb");
   if(!f){
      printf("Error! Cannot open %s\n", path_buf);
      return -1;
   }
   
   //Shifting by virt-addr-offset number of bytes
   //and multiplying by the size of an address (the size of an entry in pagemap file)
   file_offset = virt_addr / getpagesize() * PAGEMAP_ENTRY;
   printf("Vaddr: 0x%lx, Page_size: %d, Entry_size: %d\n", virt_addr, getpagesize(), PAGEMAP_ENTRY);
   printf("Reading %s at 0x%llx\n", path_buf, (unsigned long long) file_offset);
   status = fseek(f, file_offset, SEEK_SET);
   if(status){
      perror("Failed to do fseek!");
      return -1;
   }
   errno = 0;
   read_val = 0;
   unsigned char c_buf[PAGEMAP_ENTRY];
   for(i=0; i < PAGEMAP_ENTRY; i++){
      c = getc(f);
      if(c==EOF){
         printf("\nReached end of the file\n");
         return 0;
      }
      if(is_bigendian())
           c_buf[i] = c;
      else
           c_buf[PAGEMAP_ENTRY - i - 1] = c;
      printf("[%d]0x%x ", i, c);
   }
   for(i=0; i < PAGEMAP_ENTRY; i++){
      //printf("%d ",c_buf[i]);
      read_val = (read_val << 8) + c_buf[i];
   }
   printf("\n");
   printf("Result: 0x%llx\n", (unsigned long long) read_val);
   //if(GET_BIT(read_val, 63))
   if(GET_BIT(read_val, 63))
      printf("PFN: 0x%llx\n",(unsigned long long) GET_PFN(read_val));
   else
      printf("Page not present\n");
   if(GET_BIT(read_val, 62))
      printf("Page swapped\n");
   fclose(f);
   return 0;
}
开发者ID:weehowe-z,项目名称:Backup,代码行数:49,代码来源:pagemap.c

示例14: plot_rfi

static void plot_rfi(rfi * plotrfi, float top, int numint, int numchan,
                     float T, float lof, float hif)
{
   int ii;
   float period, perioderr, dy = 0.035, *temparr;
   float tr[6] = { -0.5, 1.0, 0.0, -0.5, 0.0, 1.0 };
   char temp[40];

   if (plotrfi->freq_avg == 0.0)
      period = 0.0;
   else
      period = 1000.0 / plotrfi->freq_avg;
   if (plotrfi->freq_var == 0.0)        /* Why are these zero? */
      perioderr = 0.0;
   else
      perioderr = 1000.0 * sqrt(plotrfi->freq_var) /
          (plotrfi->freq_avg * plotrfi->freq_avg);
   cpgsvp(0.0, 1.0, 0.0, 1.0);
   cpgswin(0.0, 1.0, 0.0, 1.0);
   cpgnice_output_2(temp, plotrfi->freq_avg, sqrt(plotrfi->freq_var), 0);
   cpgptxt(0.03, top - 0.6 * dy, 0.0, 0.0, temp);
   cpgnice_output_2(temp, period, perioderr, 0);
   cpgptxt(0.12, top - 0.6 * dy, 0.0, 0.0, temp);
   sprintf(temp, "%-5.2f", plotrfi->sigma_avg);
   cpgptxt(0.21, top - 0.6 * dy, 0.0, 0.0, temp);
   sprintf(temp, "%d", plotrfi->numobs);
   cpgptxt(0.27, top - 0.6 * dy, 0.0, 0.0, temp);
   ii = (numint > numchan) ? numint : numchan;
   temparr = gen_fvect(ii);
   for (ii = 0; ii < numchan; ii++)
      temparr[ii] = GET_BIT(plotrfi->chans, ii);
   cpgsvp(0.33, 0.64, top - dy, top);
   cpgswin(0.0, numchan, 0.0, 1.0);
   cpgimag(temparr, numchan, 1, 1, numchan, 1, 1, 0.0, 1.0, tr);
   cpgswin(0.0, numchan, 0.0, 1.0);
   cpgbox("BST", 0.0, 0, "BC", 0.0, 0);
   cpgswin(lof, hif, 0.0, 1.0);
   cpgbox("CST", 0.0, 0, "", 0.0, 0);
   for (ii = 0; ii < numint; ii++)
      temparr[ii] = GET_BIT(plotrfi->times, ii);
   cpgsvp(0.65, 0.96, top - dy, top);
   cpgswin(0.0, numint, 0.0, 1.0);
   cpgimag(temparr, numint, 1, 1, numint, 1, 1, 0.0, 1.0, tr);
   cpgswin(0.0, numint, 0.0, 1.0);
   cpgbox("BST", 0.0, 0, "BC", 0.0, 0);
   cpgswin(0.0, T, 0.0, 1.0);
   cpgbox("CST", 0.0, 0, "", 0.0, 0);
   vect_free(temparr);
}
开发者ID:ChrisLaidler,项目名称:presto,代码行数:49,代码来源:rfifind_plot.c

示例15: preprocess_it

int preprocess_it(Instruction *out, Emulator *emul)
{
	char msk = (char) out->ext.plages[0].value;
	int mask=0, sign=0, thn=out->ext.plages[1].value, els=0;
	int i, k;
	char cond0 = GET_BIT(thn, 0);


	for (k = 0; k < 4; k++) // trouve le premier bit à 1
	{
		if(GET_BIT(msk, k) == (1 << k) )
			break;
	}



	for (i = 3; i > k; i--)
	{
		if( GET_BIT(msk, i) == (cond0 << i) )
		{
			strcat(out->name_out, "T");
			sign += (sign << 1) + 1;
		}
		else
		{
			strcat(out->name_out, "E");
			sign <<= 1;
		}
	}

	strcat(out->name_out, " ");
	strcat(out->name_out, emul->dic->states_tab[thn]);


	mask = (1 << (4 - k)) - 1; // mask au format de la fonction process_state
	sign += (sign << 1) + 1; // la première condition est forcément Then

	// printf("k = %u\tmask = %s\n", k, int_to_bin(mask, 4));

	if( (thn & 1) == 0 )
		els = thn + 1;
	else
		els = thn - 1;

	set_it_state(&emul->it_state, mask, sign, thn, els);

	return 0;
}
开发者ID:HackLinux,项目名称:ARM-emulator,代码行数:48,代码来源:preprocess.c


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