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


C++ sassert函数代码示例

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


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

示例1: fpga_read

/* Read data starting at address 'addr' (not including the 'write' bit).
 * Returns 0 on success, 1 on failure. Stops quietly if 'addr' goes out of
 * bounds. */
void
fpga_read (uint8_t addr_hi, uint8_t addr_lo, uint8_t *data, uint8_t n)
{
    uint8_t i = 0;
    if (addr_hi & 0x80) return;

    pnCSFPGA(PORT) = 0;

    /* Transmit the address */
    SPDR = addr_hi | 0x80;
    while (!(SPSR & 1<<SPIF));
    sassert (!(SPSR & 1<<WCOL));

    SPDR = addr_lo;
    while (!(SPSR & 1<<SPIF));
    sassert (!(SPSR & 1<<WCOL));

    /* Dummy pause */
    SPDR = 0;
    while (!(SPSR & 1<<SPIF));
    sassert (!(SPSR & 1<<WCOL));

    for (i = 0; i < n; ++i) {
        SPDR = 0;
        while (!(SPSR & 1<<SPIF));
        sassert (!(SPSR & 1<<WCOL));
        data[i] = SPDR;
    }

    pnCSFPGA(PORT) = 1;
}
开发者ID:cpavlina,项目名称:200a,代码行数:34,代码来源:fpga.c

示例2: image8to16trans

//---------------------------------------------------------------------------------
void image8to16trans(sImage* img, u8 transparentColor) {
//---------------------------------------------------------------------------------
	int i;
	u8 c;

	sassert(img->bpp == 8, "image must be 8 bpp");
	sassert(img->palette != NULL, "image must have a palette set");

	u16* temp = (u16*)malloc(img->height*img->width*2);

	for(i = 0; i < img->height * img->width; i++) {

		c = img->image.data8[i];

		if(c != transparentColor)
			temp[i] = img->palette[c] | (1<<15);
		else
			temp[i] = img->palette[c];
	}

	free (img->image.data8);
	free (img->palette);

	img->palette = NULL;

	img->bpp = 16;
	img->image.data16 = temp;
}
开发者ID:MrGabigoo,项目名称:libnds,代码行数:29,代码来源:image.c

示例3: fpga_write

/* Write data starting at address 'addr' (not including the 'write' bit).
 * Returns 0 on success, 1 on failure. Stops quietly if 'addr' goes out of
 * bounds. */
void
fpga_write (uint8_t addr_hi, uint8_t addr_lo, const uint8_t *data, uint8_t n)
{
    uint8_t i = 0;
    if (addr_hi & 0x80) return;

    pnCSFPGA(PORT) = 0;

    /* Transmit the address */
    SPDR = addr_hi;
    while (!(SPSR & 1<<SPIF));
    sassert (!(SPSR & 1<<WCOL));

    SPDR = addr_lo;
    while (!(SPSR & 1<<SPIF));
    sassert (!(SPSR & 1<<WCOL));

    for (i = 0; i < n; ++i) {
        SPDR = data[i];
        while (!(SPSR & 1<<SPIF));
        sassert (!(SPSR & 1<<WCOL));
    }

    pnCSFPGA(PORT) = 1;
}
开发者ID:cpavlina,项目名称:200a,代码行数:28,代码来源:fpga.c

示例4: ch_calN_offset

//# CALibrate1:OFFSET   ident(1)
//# CALibrate2:OFFSET   ident(2)
void ch_calN_offset (bool arg_valid, uint8_t ident)
{
    (void) arg_valid;
    inst_t *inst;

    if (arg_valid) {
        if (ident == 1) {
            INST_1.offset = CMD_ARG_NUM;
        } else if (ident == 2) {
            INST_2.offset = CMD_ARG_NUM;
        } else {
            sassert (0);
            return;
        }

    } else {

        if (ident == 1) {
            inst = &INST_1;
        } else if (ident == 2) {
            inst = &INST_2;
        } else {
            sassert (0);
            return;
        }

        inst_cal_offset (inst, true);
    }
}
开发者ID:cpavlina,项目名称:200a,代码行数:31,代码来源:ch-meas.c

示例5: loadFile

void loadFile(const char* filename, u8 * data, uint32 len) {
	{
		struct stat results;
		stat(filename, &results);// == 0
		file_size = results.st_size;

		if(file_size >= 1024*1024*2) {
			char tmp[128];
			siprintf(tmp,"Error!\n File is too large to load.\n Please don't be stupid.\n"
					"File: %s",filename);
			sassert(file_size < 1024*1024*2,"Error!\n File is too large to load.\n Please use segment loader.\n");
		}
	}

	FILE * fp = fopen(filename,"rb");

	if(fp == NULL) {
		char tmp[128];
		siprintf(tmp,"File failed to load!\nFile: %s",filename);
		sassert(fp != NULL,tmp);
	}

	uint32 toRead = file_size;
	if(len < file_size) toRead = len;
	size_t sz = fread(data,1,toRead,fp);
	sassert(sz == toRead,"Reading Failed!");
	fclose(fp);
}
开发者ID:projectpokemon,项目名称:PPSE-DS,代码行数:28,代码来源:Toolkit.cpp

示例6: before_block_exec

int before_block_exec(CPUState *env, TranslationBlock *tb) {
    uint64_t count = rr_get_guest_instr_count();
    if (!snipping && count+tb->icount > start_count) {
        sassert((oldlog = fopen(rr_nondet_log->name, "r")), 8);
        sassert(fread(&orig_last_prog_point, sizeof(RR_prog_point), 1, oldlog) == 1, 9);
        printf("Original ending prog point: ");
        rr_spit_prog_point(orig_last_prog_point);

        actual_start_count = count;
        printf("Saving snapshot at instr count %lu...\n", count);

        // Force running state
        global_state_store_running();
        printf("writing snapshot:\t%s\n", snp_name);
        QIOChannelFile* ioc =
            qio_channel_file_new_path(snp_name, O_WRONLY | O_CREAT, 0660, NULL);
        QEMUFile* snp = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
        qemu_savevm_state(snp, NULL);
        qemu_fclose(snp);

        printf("Beginning cut-and-paste process at prog point:\n");
        rr_spit_prog_point(rr_prog_point());
        printf("Writing entries to %s...\n", nondet_name);
        newlog = fopen(nondet_name, "w");
        sassert(newlog, 10);
        // We'll fix this up later.
        RR_prog_point prog_point = {0};
        fwrite(&prog_point.guest_instr_count,
                sizeof(prog_point.guest_instr_count), 1, newlog);

        fseek(oldlog, ftell(rr_nondet_log->fp), SEEK_SET);

        // If there are items in the queue, then start copying the log
        // from there
        RR_log_entry *item = rr_get_queue_head();
        if (item != NULL) fseek(oldlog, item->header.file_pos, SEEK_SET);

        while (prog_point.guest_instr_count < end_count && !feof(oldlog)) {
            prog_point = copy_entry();
        }
        if (!feof(oldlog)) { // prog_point is the first one AFTER what we want
            printf("Reached end of old nondet log.\n");
        } else {
            printf("Past desired ending point for log.\n");
        }

        snipping = true;
        printf("Continuing with replay.\n");
    }

    if (snipping && !done && count > end_count) {
        end_snip();

        rr_end_replay_requested = 1;
    }

    return 0;
}
开发者ID:mewbak,项目名称:panda,代码行数:58,代码来源:scissors.c

示例7: TextWriter

		StreamWriter::StreamWriter(Stream* stream)
			: TextWriter(null)
		{
			sassert(stream != null, String::Format("stream; %s", FrameworkResources::ArgumentNull_Generic));

			sassert(stream->CanWrite(), FrameworkResources::NotSupported_UnwritableStream);

			Init(stream, DefaultBufferSize);
		}
开发者ID:Halofreak1990,项目名称:XFXFramework,代码行数:9,代码来源:StreamWriter.cpp

示例8: scaleAdd

	void scaleAdd(int dest, int const(&c)[3], int scale, int add)
	{
		entries[dest].r = (add + c[0] * scale) / 64;
		entries[dest].g = (add + c[1] * scale) / 64;
		entries[dest].b = (add + c[2] * scale) / 64;
		
		sassert(entries[dest].r < 64);
		sassert(entries[dest].g < 64);
		sassert(entries[dest].b < 64);
	}
开发者ID:HuangYuSan,项目名称:liero,代码行数:10,代码来源:palette.hpp

示例9: test_sparse_used

void test_sparse_used() {
    uint b = 14;
    Hyperloglog *hll = create_hll(b, 0);
    sassert(hll->sparsed_used == 0);
    free(hll);
    hll = create_hll(b, 1);
    sassert(1 == hll->sparsed_used);
    sassert(0 == hll->last_index);
    sassert(1024 == hll->max_values);
    free(hll);
}
开发者ID:havrlant,项目名称:cardinality,代码行数:11,代码来源:hyperloglog.spec.c

示例10: logc

void logc(char c) {
	if(!reqPorts) {
		/* request io-ports for qemu and bochs */
		sassert(reqport(0xe9) >= 0);
		sassert(reqport(0x3f8) >= 0);
		sassert(reqport(0x3fd) >= 0);
		reqPorts = true;
	}
	while((inbyte(0x3f8 + 5) & 0x20) == 0)
		;
	outbyte(0x3f8,c);
}
开发者ID:Nils-TUD,项目名称:Escape,代码行数:12,代码来源:log.c

示例11: test_estimate_cardinality

void test_estimate_cardinality() {
    uint b = 10;
    Hyperloglog *hll = mock_hll(b);
    sassert(3 == estimate_cardinality(hll));
    hll->M[54] = 20;
    sassert(4 == estimate_cardinality(hll));

    for (int i = 100; i < 150; i++) {
        hll->M[i] = i % 20;
    }

    sassert(52 == estimate_cardinality(hll));
    free(hll);
}
开发者ID:havrlant,项目名称:cardinality,代码行数:14,代码来源:hyperloglog.spec.c

示例12: before_block_exec

int before_block_exec(CPUState *env, TranslationBlock *tb) {
    uint64_t count = rr_prog_point.guest_instr_count;
    if (!snipping && count+tb->num_guest_insns > start_count) {
        sassert((oldlog = fopen(rr_nondet_log->name, "r")));
        sassert(fread(&orig_last_prog_point, sizeof(RR_prog_point), 1, oldlog) == 1);
        printf("Original ending prog point: ");
        rr_spit_prog_point(orig_last_prog_point);

        actual_start_count = count;
        printf("Saving snapshot at instr count %lu...\n", count);
        do_savevm_rr(get_monitor(), snp_name);

        printf("Beginning cut-and-paste process at prog point:\n");
        rr_spit_prog_point(rr_prog_point);
        printf("Writing entries to %s...\n", nondet_name);
        newlog = fopen(nondet_name, "w");
        sassert(newlog);
        // We'll fix this up later.
        RR_prog_point prog_point = {0, 0, 0};
        fwrite(&prog_point, sizeof(RR_prog_point), 1, newlog);

        fseek(oldlog, ftell(rr_nondet_log->fp), SEEK_SET);

        RR_log_entry *item = rr_get_queue_head();
        while (item != NULL && item->header.prog_point.guest_instr_count < end_count) {
            write_entry(item);
            item = item->next;
        }
        while (prog_point.guest_instr_count < end_count && !feof(oldlog)) {
            prog_point = copy_entry();
        } 
        if (!feof(oldlog)) { // prog_point is the first one AFTER what we want
            printf("Reached end of old nondet log.\n");
        } else {
            printf("Past desired ending point for log.\n");
        }

        snipping = true;
        printf("Continuing with replay.\n");
    }

    if (snipping && !done && count > end_count) {
        end_snip();

        init_timer_alarm();
        rr_do_end_replay(0);
    }

    return 0;
}
开发者ID:Debug-Orz,项目名称:panda,代码行数:50,代码来源:scissors.c

示例13: test_sparse_estimate_cardinality

void test_sparse_estimate_cardinality() {
    uint b = 10;
    Hyperloglog *hll = mock_sparse_hll(b);
    sassert(3 == estimate_cardinality(hll));
    update_sparse_list(hll, 54, 20);
    sassert(4 == estimate_cardinality(hll));

    for (int i = 100; i < 150; i++) {
        update_sparse_list(hll, i, i % 20);
    }

    sassert(52 == estimate_cardinality(hll));
    free(hll);
}
开发者ID:havrlant,项目名称:cardinality,代码行数:14,代码来源:hyperloglog.spec.c

示例14: remove

	void remove(SpecKeyT const& k)
	{
		T* idx = lookup(k);
		
		if(idx)
		{
			sassert(idx->is_filled());
			idx->make_deleted();
			sassert(!idx->is_filled());
			--elems;
			++deleted;
			maybe_shrink();
		}
	}
开发者ID:coyun,项目名称:gvl,代码行数:14,代码来源:generic_hash_set.hpp

示例15: dcontext_prepare

int
dcontext_prepare(struct dcontext *dctx)
{
    sassert(dctx);
    sassert(dctx->d_savefile);
    
    CURL *c = dctx->d_handle = curl_easy_init();

    curl_easy_reset(c);

    curl_easy_setopt(c, CURLOPT_FAILONERROR, 1L);
    curl_easy_setopt(c, CURLOPT_CONNECTTIMEOUT, 10L);
    curl_easy_setopt(c, CURLOPT_FILETIME, 1L);
    curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(c, CURLOPT_LOW_SPEED_LIMIT, 1024L);
    curl_easy_setopt(c, CURLOPT_LOW_SPEED_TIME, 10L);
    curl_easy_setopt(c, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);    

    
    curl_easy_setopt(c, CURLOPT_URL, dctx->d_url);

    curl_easy_setopt(c, CURLOPT_ERRORBUFFER, &dctx->d_ebuffer[0]);


    /* no progress for now */
    curl_easy_setopt(c, CURLOPT_NOPROGRESS, 1L);
#if 0
    curl_easy_setopt(c, CURLOPT_NOPROGRESS, 0L);
    curl_easy_setopt(c, CURLOPT_PROGRESSFUNCTION, dcontext_progress_func);
    curl_easy_setopt(c, CURLOPT_PROGRESSDATA, dctx);
#endif

    /* no header function for now */
#if 0
    curl_easy_setopt(c, CURLOPT_HEADERFUNCTION, dcontext_header_func);
    curl_easy_setopt(c, CURLOPT_WRITEHEADER, dctx);
#endif
    
    if ((dctx->d_savefp = fopen(dctx->d_savefile, "wb")) == NULL) {
        goto error;
    }

    curl_easy_setopt(c, CURLOPT_WRITEDATA, dctx->d_savefp);

    return 0;
    
error:
    fprintf(stderr, "failed: %s\n", strerror(errno));
    return -1;
}
开发者ID:yami,项目名称:pacfind,代码行数:50,代码来源:download.c


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