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


C++ set_number函数代码示例

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


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

示例1: test_program

// The test program (function is called in an endless loop)
// Used to display all digits
// Activated when both buttons are pressed during system startup
// Button 0 switches between continous running mode (where
// digits just get incremented every 250ms) and selective mode where
// Button 1 is used to increment the digits
void test_program(void)
{
	update_buttons();
	
	if(g_buttons[0] && !g_last_buttons[0])
		g_last_blink_state = 1 - g_last_blink_state;
	
	if(g_last_blink_state == 0)
	{
		if(g_buttons[1] && !g_last_buttons[1])
		{
			g_last_blink_action = g_ticks;
			g_blink_numbers = (g_blink_numbers + 1) % 10;
		}
	}
	else if(time_since(g_last_blink_action) > 25)
	{	
		g_last_blink_action = g_ticks;
		g_blink_numbers = (g_blink_numbers + 1) % 10;
	}
	
	set_number(pins_d1, g_blink_numbers);
	set_number(pins_d2, g_blink_numbers);
	set_number(pins_d3, g_blink_numbers);
	set_number(pins_d4, g_blink_numbers);
}
开发者ID:MGraefe,项目名称:nixie-clock,代码行数:32,代码来源:nixie.c

示例2: kplib_curr_taskinfo

/*
 * use gdb to get field offset of struct task_struct, for example:
 *
 * gdb vmlinux
 * (gdb)p &(((struct task_struct *)0).prio)
 */
static int kplib_curr_taskinfo(ktap_state_t *ks)
{
	int offset = kp_arg_checknumber(ks, 1);
	int fetch_bytes  = kp_arg_checkoptnumber(ks, 2, 4); /* fetch 4 bytes */

	if (offset >= sizeof(struct task_struct)) {
		set_nil(ks->top++);
		kp_error(ks, "access out of bound value of task_struct\n");
		return 1;
	}

#define RET_VALUE ((unsigned long)current + offset)

	switch (fetch_bytes) {
	case 4:
		set_number(ks->top, *(unsigned int *)RET_VALUE);
		break;
	case 8:
		set_number(ks->top, *(unsigned long *)RET_VALUE);
		break;
	default:
		kp_error(ks, "unsupported fetch bytes in curr_task_info\n");
		set_nil(ks->top);
		break;
	}

#undef RET_VALUE

	incr_top(ks);
	return 1;
}
开发者ID:feng-tao,项目名称:ktap,代码行数:37,代码来源:lib_base.c

示例3: write_output

void write_output(uint8_t a, uint8_t b)
{
	set_number(pins_d1, a > 99 ? 0xF : (a / 10));
	set_number(pins_d2, a > 99 ? 0xF : (a % 10));
	set_number(pins_d3, b > 99 ? 0xF : (b / 10));
	set_number(pins_d4, b > 99 ? 0xF : (b % 10));
}
开发者ID:MGraefe,项目名称:nixie-clock,代码行数:7,代码来源:nixie.c

示例4: test_serde

  void test_serde() {
    // dynamic create message.
    MessageHelper helper;
    FileDescriptorProto file_proto;
    file_proto.set_name("test.proo");
    DescriptorProto *message_proto = file_proto.add_message_type();
    message_proto->set_name("Pair");
    auto field = message_proto->add_field();
    field->set_name("key");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_STRING);
    field->set_number(1);

    field = message_proto->add_field();
    field->set_name("value");
    field->set_label(FieldDescriptorProto_Label_LABEL_REQUIRED);
    field->set_type(FieldDescriptorProto_Type_TYPE_BYTES);
    field->set_number(2);
    helper.registerDynamicMessage(file_proto);
    auto src = helper.createMessage("Pair");
    auto ref = src->GetReflection();
    string key("scott");
    string value("tiger");
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("key"), key);
    ref->SetString(src.get(), src->GetDescriptor()->FindFieldByName("value"), value);

    // test serde
    check_serde_str(src.get(), helper.createMessage("Pair").get());
    check_serde_array(src.get(), helper.createMessage("Pair").get());
    check_serstr_dearray(src.get(), helper.createMessage("Pair").get());
    check_serarray_destr(src.get(), helper.createMessage("Pair").get());
  }
开发者ID:XiaominZhang,项目名称:raf,代码行数:32,代码来源:pair_serde_test.cpp

示例5: QDialog

HandCloseWindow::HandCloseWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::HandCloseWindow)
{
	ui->setupUi(this);
	QObject::connect(&timer, SIGNAL(timeout()),this,SLOT(set_number()));
}
开发者ID:Amxx,项目名称:MDMA,代码行数:7,代码来源:handclosewindow.cpp

示例6: kplib_gettimeofday_us

static int kplib_gettimeofday_us(ktap_state *ks)
{
	set_number(ks->top, gettimeofday_us());
	incr_top(ks);

	return 1;
}
开发者ID:WinLinKer,项目名称:ktap,代码行数:7,代码来源:lib_base.c

示例7: kplib_in_iowait

/*
 * This built-in function mainly purpose scripts/schedule/schedtimes.kp
 */
static int kplib_in_iowait(ktap_state *ks)
{
	set_number(ks->top, current->in_iowait);
	incr_top(ks);

	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:10,代码来源:lib_base.c

示例8: kplib_gettimeofday_s

static int kplib_gettimeofday_s(ktap_state *ks)
{
	set_number(ks->top, gettimeofday_ns() / NSEC_PER_SEC);
	incr_top(ks);

	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:7,代码来源:lib_base.c

示例9: kp_cdata_init

/* Init its cdata type, but not its actual value */
static void kp_cdata_init(ktap_state_t *ks, ktap_val_t *val, void *addr, int len,
			  csymbol_id id)
{
	ffi_type type = csym_type(id_to_csym(ks, id));

	switch (type) {
	case FFI_PTR:
		set_cdata(val, kp_cdata_new_ptr(ks, addr, len, id, 0));
		break;
	case FFI_STRUCT:
	case FFI_UNION:
		set_cdata(val, kp_cdata_new_record(ks, addr, id));
		break;
	case FFI_UINT8:
	case FFI_INT8:
	case FFI_UINT16:
	case FFI_INT16:
	case FFI_UINT32:
	case FFI_INT32:
	case FFI_UINT64:
	case FFI_INT64:
		/* set all these value into ktap_number(long) */
		set_number(val, 0);
		break;
	default:
		set_cdata(val, kp_cdata_new(ks, id));
		break;
	}
}
开发者ID:ktap,项目名称:ktap,代码行数:30,代码来源:cdata.c

示例10: kplib_tid

static int kplib_tid(ktap_state *ks)
{
	pid_t pid = task_pid_vnr(current);

	set_number(ks->top, (int)pid);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:8,代码来源:lib_base.c

示例11: QDialog

MaskWindow::MaskWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::MaskWindow)
{
	ui->setupUi(this);
	if(!Configuration::config().user_mask.empty()) ui->pushButton->setText("Reconfigure mask");
	QObject::connect(&timer, SIGNAL(timeout()),this,SLOT(set_number()));
}
开发者ID:Amxx,项目名称:MDMA,代码行数:8,代码来源:maskwindow.cpp

示例12: kplib_in_interrupt

static int kplib_in_interrupt(ktap_state *ks)
{
	int ret = in_interrupt();

	set_number(ks->top, ret);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:8,代码来源:lib_base.c

示例13: kplib_avg

static int kplib_avg(ktap_state *ks)
{
	ktap_value *v = kp_arg(ks, 1);
	ktap_stat_data *sd;

	if (is_nil(v)) {
		set_number(ks->top, 0);
		incr_top(ks);
		return 1;	
	}

	kp_arg_check(ks, 1, KTAP_TYPE_STATDATA);
	sd = sdvalue(v);

	set_number(ks->top, sd->sum / sd->count);
	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:18,代码来源:lib_base.c

示例14: ktap_lib_min

static int ktap_lib_min(ktap_state *ks)
{
    ktap_value *v = kp_arg(ks, 1);
    ktap_stat_data *sd;

    if (is_nil(v)) {
        set_number(ks->top, 0);
        incr_top(ks);
        return 1;
    }

    kp_arg_check(ks, 1, KTAP_TSTATDATA);
    sd = sdvalue(v);

    set_number(ks->top, sd->min);
    incr_top(ks);
    return 1;
}
开发者ID:atmark-techno,项目名称:linux-3.14-at,代码行数:18,代码来源:lib_base.c

示例15: kplib_curr_taskinfo

/*
 * use gdb to get field offset of struct task_struct, for example:
 *
 * gdb vmlinux
 * (gdb)p &(((struct task_struct *)0).prio)
 */
static int kplib_curr_taskinfo(ktap_state *ks)
{
	int offset;
	int fetch_bytes;

	kp_arg_check(ks, 1, KTAP_TYPE_NUMBER);

	offset = nvalue(kp_arg(ks, 1));
	
	if (kp_arg_nr(ks) == 1)
		fetch_bytes = 4; /* default fetch 4 bytes*/
	else {
		kp_arg_check(ks, 2, KTAP_TYPE_NUMBER);
		fetch_bytes = nvalue(kp_arg(ks, 2));
	}

	if (offset >= sizeof(struct task_struct)) {
		set_nil(ks->top++);
		kp_error(ks, "access out of bound value of task_struct\n");
		return 1;
	}

#define RET_VALUE ((unsigned long)current + offset)

	switch (fetch_bytes) {
	case 4:
		set_number(ks->top, *(unsigned int *)RET_VALUE);
		break;
	case 8:
		set_number(ks->top, *(unsigned long *)RET_VALUE);
		break;
	default:
		kp_error(ks, "unsupported fetch bytes in curr_task_info\n");
		set_nil(ks->top);
		break;
	}

#undef RET_VALUE

	incr_top(ks);
	return 1;
}
开发者ID:cofyc,项目名称:ktap,代码行数:48,代码来源:lib_base.c


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