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


C++ NELEMS函数代码示例

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


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

示例1: spiSend

void RFM70::setModeRX(void) {
	uint8_t val;

	// Flush RX FIFO
	spiSend(0, (uint8_t *) RFM70_cmd_flush_rx, NELEMS(RFM70_cmd_flush_rx));
	// Read Status
	val = readRegVal(RFM70_REG_STATUS);
	// Reset IRQ bits
	uint8_t data[] = {RFM70_CMD_WRITE_REG | RFM70_REG_STATUS, val};
	spiSend(0, data, 2);
	// RFM chip disable
	digitalWrite(_ce, LOW);
	// set PRIM_RX bit to 1
	val = readRegVal(RFM70_REG_CONFIG);
	val |= RFM70_PIN_PRIM_RX;
	data[0] = RFM70_CMD_WRITE_REG | RFM70_REG_CONFIG;
	data[1] = val;
	spiSend(0, data, 2);
	// RFM chip enable
	digitalWrite(_ce, HIGH);
}
开发者ID:chendong2012,项目名称:cells,代码行数:21,代码来源:rfm70.cpp

示例2: recv_stop

static void
recv_stop(Event_Type et, Object *obj, Any_Type reg_arg, Any_Type call_arg) {
    Call *c = (Call *) obj;
    int index;

    assert(et == EV_CALL_RECV_STOP && object_is_call(c));
    assert(c->basic.time_recv_start > 0);

    basic.call_xfer_sum += timer_now() - c->basic.time_recv_start;

    basic.hdr_bytes_received += c->reply.header_bytes;
    basic.reply_bytes_received += c->reply.content_bytes;
    basic.footer_bytes_received += c->reply.footer_bytes;

    index = (c->reply.status / 100);
    assert((unsigned) index < NELEMS(basic.num_replies));
    ++basic.num_replies[index];
    ++num_replies;

    ++c->conn->basic.num_calls_completed;
}
开发者ID:codeb2cc,项目名称:httperf,代码行数:21,代码来源:basic.c

示例3: Atom_free

void Atom_free(const char *str)
{
	unsigned long h;
	unsigned long hash_number;
	struct atom *p;
	struct atom *c;
	int Len;

	assert(str);

	Len = strlen(str);

	//Cercare atomo con la stringa
	hash_number = Atom_CalculateHash(str, Len);
	h = hash_number % NELEMS(buckets);
#ifdef DEBUG
	fprintf(stderr, "Hash number for string %s => %ld\n", str, hash_number);
	fprintf(stderr, "Hash value for string %s => %ld\n", str, h);
#endif

	c = buckets[h];
	p = NULL;
	/* Se due stringhe hanno un hash_number uguale, significa che corrispondono
	 * */
	while( c && (hash_number != c->hash_number) )
	{
		p = c;
		c = c->link;
	}

	if( p == NULL )
	{
		buckets[h] = c->link;
	}
	else
	{
		p->link = c->link;
	}
    FREE(c);
}
开发者ID:jubstuff,项目名称:LASD,代码行数:40,代码来源:atom_hash.c

示例4: set_debug_level

static void
set_debug_level(void)
{
    char *ccspDbg;
    int i;
    struct {
        char *name;
        int level;
    } levelTab[] = {
        {"debug",       CCSP_TRACE_LEVEL_DEBUG, },
        {"info",        CCSP_TRACE_LEVEL_INFO, },
        {"notice",      CCSP_TRACE_LEVEL_NOTICE, },
        {"warning",     CCSP_TRACE_LEVEL_WARNING, },
        {"error",       CCSP_TRACE_LEVEL_ERROR, },
        {"critical",    CCSP_TRACE_LEVEL_CRITICAL, },
        {"alert",       CCSP_TRACE_LEVEL_ALERT, },
        {"emergency",   CCSP_TRACE_LEVEL_EMERGENCY, },
    };

            pComponentName = "CCSP_SNMNP_Plugin";

    ccspDbg = getenv("CCSPDBG");
    if (!ccspDbg)
        return;

    for (i = 0; i < NELEMS(levelTab); i++)
    {
        if (AnscEqualString(ccspDbg, levelTab[i].name, TRUE))
        {
            AnscSetTraceLevel(levelTab[i].level);
            //pComponentName = "CCSP_SNMNP_Plugin";

            AnscTraceWarning(("setting debug level to \"%s\"\n", levelTab[i].name));
            break;
        }
    }

    return;
}
开发者ID:rdkcmf,项目名称:rdkb-CcspSnmpPa,代码行数:39,代码来源:CcspSnmpPlugin.c

示例5: OnUnhandledException

	LONG WINAPI OnUnhandledException(PEXCEPTION_POINTERS pExceptionInfo)
	{
		if (!bPassOn) // exception occurred while closing, force kill the server
			ExitProcess(1);

		bPassOn = false;

		MINIDUMP_EXCEPTION_INFORMATION ei;
		ei.ExceptionPointers = pExceptionInfo;
		ei.ThreadId = GetCurrentThreadId();
		ei.ClientPointers = FALSE;

		DWORD dwProcessId = GetCurrentProcessId();
		SYSTEMTIME stLocalTime;
		GetLocalTime(&stLocalTime);
		wchar_t CrashDumpW[1024];
		swprintf_s(CrashDumpW, NELEMS(CrashDumpW), 
				L"%s\\%s-%s-%s-%04X-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp", 
				g_CrashDirectory.c_str(), L"Phasor", PHASOR_HALO_BUILD,
				PHASOR_MAJOR_VERSION_STR, 
				PHASOR_INTERNAL_VERSION, stLocalTime.wYear, stLocalTime.wMonth,
				stLocalTime.wDay, stLocalTime.wHour, stLocalTime.wMinute, 
				stLocalTime.wSecond, dwProcessId, ei.ThreadId);

		HANDLE hFile = CreateFileW(CrashDumpW, GENERIC_READ | GENERIC_WRITE,
			NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

#ifdef BUILD_DEBUG
		MINIDUMP_TYPE dwDumpType = MiniDumpWithFullMemory;
#else
		MINIDUMP_TYPE dwDumpType = MiniDumpScanMemory;
#endif

		MiniDumpWriteDump(GetCurrentProcess(), dwProcessId, hFile, 
			dwDumpType, &ei, NULL, NULL);
		CloseHandle(hFile);

		return EXCEPTION_EXECUTE_HANDLER;
	}
开发者ID:ChadSki,项目名称:Phasor,代码行数:39,代码来源:CrashHandler.cpp

示例6: AllocateLightingPreviewtextures

void AllocateLightingPreviewtextures(void)
{
	static bool bHaveAllocated=false;
	if (! bHaveAllocated )
	{
		bHaveAllocated = true;
		MaterialSystemInterface()->BeginRenderTargetAllocation();
		for(int idx=0;idx<NELEMS(sg_ExtraFP16Targets);idx++)
			sg_ExtraFP16Targets[idx].Init(
				materials->CreateNamedRenderTargetTextureEx2(
					s_rt_names[idx],
					512, 512, RT_SIZE_DEFAULT, s_rt_formats[idx],
					MATERIAL_RT_DEPTH_SHARED, 
					TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
					CREATERENDERTARGETFLAGS_HDR )
				);
		
		// End block in which all render targets should be allocated (kicking off an Alt-Tab type
		// behavior)
		MaterialSystemInterface()->EndRenderTargetAllocation();
	}
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:22,代码来源:material.cpp

示例7: MarineProfileList

void CASW_Briefing::AutoSelectFullSquadForSingleplayer( int nFirstSelectedProfileIndex )
{
	if ( !MarineProfileList() )
		return;

	CASW_Marine_Profile* pFirstSelectedProfile = MarineProfileList()->GetProfile( nFirstSelectedProfileIndex );
	if ( !pFirstSelectedProfile )
		return;

	ASW_Marine_Class nMarineClasses[]=
	{
		MARINE_CLASS_NCO, 
		MARINE_CLASS_SPECIAL_WEAPONS,
		MARINE_CLASS_MEDIC,
		MARINE_CLASS_TECH
	};

	// select one of each class
	for ( int i = 0; i < NELEMS( nMarineClasses ); i++ )
	{
		if ( nMarineClasses[ i ] == pFirstSelectedProfile->GetMarineClass() )
			continue;

		CASW_Marine_Profile* pProfile = NULL;
		for ( int p = 0; p < MarineProfileList()->m_NumProfiles; p++ )
		{
			pProfile = MarineProfileList()->GetProfile( p );
			if ( pProfile && pProfile->GetMarineClass() == nMarineClasses[i] )
			{
				break;
			}
		}

		if ( !pProfile )
			continue;

		SelectMarine( 0, pProfile->m_ProfileIndex, -1 );
	}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:39,代码来源:asw_briefing.cpp

示例8: elf_x86_x86_map_reloc_info_to_type

static unsigned int
elf_x86_x86_map_reloc_info_to_type(elf_reloc_entry *reloc,
                                   yasm_symrec **ssyms)
{
    if (reloc->wrt) {
        size_t i;
        for (i=0; i<NELEMS(elf_x86_x86_ssyms); i++) {
            if (reloc->wrt == ssyms[i] &&
                reloc->valsize == elf_x86_x86_ssyms[i].size) {
                /* Force TLS type; this is required by the linker. */
                if (elf_x86_x86_ssyms[i].sym_rel & ELF_SSYM_THREAD_LOCAL) {
                    elf_symtab_entry *esym;

                    esym = yasm_symrec_get_data(reloc->reloc.sym,
                                                &elf_symrec_data);
                    if (esym)
                        esym->type = STT_TLS;
                }
                return (unsigned char) elf_x86_x86_ssyms[i].reloc;
            }
        }
        yasm_internal_error(N_("Unsupported WRT"));
    } else if (reloc->rtype_rel) {
        switch (reloc->valsize) {
            case 8: return (unsigned char) R_386_PC8;
            case 16: return (unsigned char) R_386_PC16;
            case 32: return (unsigned char) R_386_PC32;
            default: yasm_internal_error(N_("Unsupported relocation size"));
        }
    } else {
        switch (reloc->valsize) {
            case 8: return (unsigned char) R_386_8;
            case 16: return (unsigned char) R_386_16;
            case 32: return (unsigned char) R_386_32;
            default: yasm_internal_error(N_("Unsupported relocation size"));
        }
    }
    return 0;
}
开发者ID:Mirocow,项目名称:balancer,代码行数:39,代码来源:elf-x86-x86.c

示例9: test_rename

static error test_rename(atom_set_t *d)
{
  error err;
  int   i;

  printf("test: rename\n");

  for (i = 0; i < NELEMS(newnames); i++)
  {
    atom_t idx;

    printf("adding '%s'... ", data[i]);

    err = atom_new(d, (const unsigned char *) data[i],
                   strlen(data[i]) + 1, &idx);
    if (err && err != error_ATOM_NAME_EXISTS)
      return err;

    if (err == error_ATOM_NAME_EXISTS)
      printf("already exists ");

    printf("as %d\n", idx);

    printf("renaming index %d to '%s'... ", idx, newnames[i]);

    err = atom_set(d, idx, (const unsigned char *) newnames[i],
                   strlen(newnames[i]) + 1);
    if (err == error_ATOM_NAME_EXISTS)
      printf("already exists!");
    else if (err)
      return err;
    else
      printf("ok");

    printf("\n");
  }

  return error_OK;
}
开发者ID:dpt,项目名称:PrivateEye,代码行数:39,代码来源:test.c

示例10: uninstall_cfw

int uninstall_cfw(void)
{
	int ret;

	sceIoRemove("flash1:/config.se");

	int i; for(i=0; i<NELEMS(g_file_lists); ++i) {
		printf("Removing %s...", g_file_lists[i].dst);
		ret = sceIoRemove(g_file_lists[i].dst);

		if(ret == 0 || ret == 0x80010002) {
			printf("OK\n");
		} else {
			printf("failed(0x%08X)\n", ret);
		}
	}

	// per model uninstall goes here:
	switch(psp_model) {
		case PSP_GO:
			break;
		case PSP_4000:
			break;
		case PSP_3000:
			break;
		case PSP_2000:
			break;
		case PSP_1000:
			break;
	}

	if(is_permanent_patch_installed()) {
		printf("Uninstalling permanent patch...");
		uninstall_permanent_patch();
		printf("OK\n");
	}

	return 0;
}
开发者ID:AnnaKozlowska,项目名称:procfw,代码行数:39,代码来源:main.c

示例11: test_add_tags

static error test_add_tags(State *state)
{
  error err;
  int   i;

  for (i = 0; i < NELEMS(tagnames); i++)
  {
    printf("adding '%s'...", tagnames[i]);
    err = tagdb_add(state->db, tagnames[i], &state->tags[i]);
    if (err)
      goto Failure;

    printf("is tag %d\n", state->tags[i]);
  }

  return error_OK;


Failure:

  return err;
}
开发者ID:dpt,项目名称:PrivateEye,代码行数:22,代码来源:test.c

示例12: simulate_files

int simulate_files(int creat)
{
	size_t i;
	char *files[] =
	    { "config0.cfg", "config1.cfg", "config2.cfg", "config3.cfg",
		"rr109.img", "rx100.img", "rx107.img", "rm957.img", "messages"
	};

	for (i = 0; i < NELEMS(files); i++) {
		if (creat)
			touch(files[i]);
		else
			erase(files[i]);
	}

	if (creat)
		symlink("config2.cfg", STARTUP_CONFIG);
	else
		erase(STARTUP_CONFIG);

	return 0;
}
开发者ID:troglobit,项目名称:libite,代码行数:22,代码来源:dir.c

示例13: mrb_wslay_event_on_msg_recv_callback

static void
mrb_wslay_event_on_msg_recv_callback(wslay_event_context_ptr ctx,
  const struct wslay_event_on_msg_recv_arg *arg, void *user_data)
{
  mrb_wslay_user_data *data = (mrb_wslay_user_data *) user_data;
  mrb_state *mrb = data->mrb;

  int ai = mrb_gc_arena_save(mrb);
  struct mrb_jmpbuf *prev_jmp = mrb->jmp;
  struct mrb_jmpbuf c_jmp;

  MRB_TRY(&c_jmp) {
    mrb->jmp = &c_jmp;

    mrb_value argv[4];
    argv[0] = mrb_fixnum_value(arg->rsv);
    argv[1] = MRB_GET_OPCODE(mrb_fixnum_value(arg->opcode));
    argv[2] = mrb_str_new(mrb, (const char *) arg->msg, arg->msg_length);
    argv[3] = MRB_GET_STATUSCODE(mrb_fixnum_value(arg->status_code));

    mrb_value on_msg_recv_arg = mrb_obj_new(mrb,
      mrb_class_get_under(mrb,
        mrb_module_get_under(mrb,
          mrb_module_get(mrb, "Wslay"), "Event"), "OnMsgRecvArg"), NELEMS(argv), argv);

    mrb_assert(mrb_type(data->on_msg_recv_callback) == MRB_TT_PROC);
    mrb_yield(mrb, data->on_msg_recv_callback, on_msg_recv_arg);

    mrb_gc_arena_restore(mrb, ai);

    mrb->jmp = prev_jmp;
  } MRB_CATCH(&c_jmp) {
    mrb->jmp = prev_jmp;
    wslay_event_set_error(ctx, WSLAY_ERR_CALLBACK_FAILURE);
    mrb_gc_arena_restore(mrb, ai);
    MRB_THROW(mrb->jmp);
  } MRB_END_EXC(&c_jmp);
}
开发者ID:Asmod4n,项目名称:mruby-wslay,代码行数:38,代码来源:mrb_wslay.c

示例14: readAccelerometer

String Accelerometer::processor() {
  String output;
  for (int axis=0; axis<3; axis++) {
    average_delta_a[axis]  = 0;
  }
  
  for (int i=0; i<iterations; i++) {
    readAccelerometer();
    for (int axis=0; axis<3; axis++) {
      //delta_a[axis][i]=current_acceleration[axis] - previous_acceleration[axis];
      //average_delta_a[axis] += delta_a[axis][i];
      average_delta_a[axis] += current_acceleration[axis] - previous_acceleration[axis];
    }
    delay(delta);
  }

  for (int axis=0; axis<3; axis++) {
    average_delta_a[axis] = average_delta_a[axis] / iterations;
    
    if (abs(average_delta_a[axis]) > mThreshold
      && (millis() - previous_event_time[axis]) > mEventThreshold) {
      if (previous_event[axis] > 0 && average_delta_a[axis] < 0) { // turning point
        output = axes[axis][0];
      } else if (previous_event[axis] < 0 && average_delta_a[axis] > 0) { // turning point 
        output = axes[axis][1];
      }
      previous_event_time[axis] = millis(); // update last event
      previous_event[axis] = average_delta_a[axis]; // store this last acceleration value
    }
    
  }
  
  // store previous acceleration
  for (int i=0; i<NELEMS(current_acceleration); i++) {
    previous_acceleration[i] = current_acceleration[i];
  }
  return output;
}
开发者ID:DecodedCo,项目名称:accelerometer-library,代码行数:38,代码来源:Accelerometer.cpp

示例15: test_enumerate_ids_by_tags

static error test_enumerate_ids_by_tags(State *state)
{
  error err;
  int   cont;
  char  buf[256];

  {
    static const tagdb_tag want[] = { 0, 1 };

    printf("ids tagged with '%s' and '%s'...\n",
           tagnames[want[0]], tagnames[want[1]]);

    cont = 0;
    do
    {
      err = tagdb_enumerate_ids_by_tags(state->db, want, NELEMS(want),
                                              &cont, buf, sizeof(buf));
      if (err)
        goto Failure;

      if (cont)
      {
        printf("- ");
        printdigest(buf);
        printf("\n");
      }
    }
    while (cont);
  }

  return error_OK;


Failure:

  return err;
}
开发者ID:dpt,项目名称:PrivateEye,代码行数:37,代码来源:test.c


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