本文整理汇总了C++中IF_DEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ IF_DEBUG函数的具体用法?C++ IF_DEBUG怎么用?C++ IF_DEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IF_DEBUG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stats_mean_fitness_outcross_progeny_n
/*///////////////////////////////////////////////////////////////*/
KScalar stats_mean_fitness_outcross_progeny_n (KConfig_n KN)
/*
** Compute mean fitness of outcross progeny
*/
{
const char* thisfunction = "stats_mean_fitness_outcross_progeny_n";
KScalar wmean;
IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s\n", thisfunction);
if (KN->O == 0.0) {
IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s: O==0.0, outcross wmean=0.0\n",
thisfunction);
wmean = 0.0;
} else {
//void* a = alloc_KArray_n();
//void* vm = alloc_KVector_n();
//void* vf = alloc_KVector_n();
KVector_n vm;
KVector_n vf;
apply_gametes_n(KN, vm, vf, KN->x1);
{
KArray_n a;
apply_zygotes_n(KN, a, vm, vf);
wmean = mean_fitness_n(KN, a);
}
//free_KVector_n(vf);
//free_KVector_n(vm);
//free_KArray_n(a);
}
return wmean;
}
示例2: push_scanned_block
void
push_scanned_block (bdescr *bd, gen_workspace *ws)
{
ASSERT(bd != NULL);
ASSERT(bd->link == NULL);
ASSERT(bd->gen == ws->gen);
ASSERT(bd->u.scan == bd->free);
if (bd->start + bd->blocks * BLOCK_SIZE_W - bd->free > WORK_UNIT_WORDS)
{
// a partially full block: put it on the part_list list.
bd->link = ws->part_list;
ws->part_list = bd;
ws->n_part_blocks += bd->blocks;
IF_DEBUG(sanity,
ASSERT(countBlocks(ws->part_list) == ws->n_part_blocks));
}
else
{
// put the scan block on the ws->scavd_list.
bd->link = ws->scavd_list;
ws->scavd_list = bd;
ws->n_scavd_blocks += bd->blocks;
IF_DEBUG(sanity,
ASSERT(countBlocks(ws->scavd_list) == ws->n_scavd_blocks));
}
}
示例3: stats_mean_fitness_self_progeny_n
/*///////////////////////////////////////////////////////////////*/
KScalar stats_mean_fitness_self_progeny_n (KConfig_n KN)
/*
** Compute mean fitness of self progeny. To do this with the
** KN->x1,x2 type of data structures, we have to generate
** self progeny to a temporary KArray_n, then examine the
** genotypes in that array for fitness.
**
** If there were no selfed progeny produced, then we of course
** have zero mean fitness due to selfed progeny.
*/
{
const char* thisfunction = "stats_mean_fitness_self_progeny_n";
KScalar wmean;
IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s\n", thisfunction);
if (KN->S == 0.0) {
IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s: S==0.0, self wmean=0.0\n",
thisfunction);
wmean = 0.0;
} else {
//void* a = alloc_KArray_n();
KArray_n a;
apply_self_progeny_n(KN, a, KN->x1);
wmean = mean_fitness_n(KN, a);
//free_KArray_n(a);
}
return wmean;
}
示例4: initiate_model_state_n
/*///////////////////////////////////////////////////////////////*/
void initiate_model_state_n (KConfig_n KN)
{
const char* thisfunction = "initiate_model_state_n";
initiate_mut_term_n(KN);
initiate_fitness_precomputed_n(KN);
KN->generation = 0;
if (!KN->option_nolethal) {
if (KN->fit_s[0] == 1.0) {
IF_DEBUG(DEBUG_LETHALS)
fprintf(stderr, "%s: mutation class 0 is lethal, so KN->is_lethal[0]=1\n",
thisfunction);
KN->is_lethal[0] = 1;
KN->createlethal[0] = 0;
}
if (KN->fit_s[1] == 1.0) {
IF_DEBUG(DEBUG_LETHALS)
fprintf(stderr, "%s: mutation class 1 is lethal, so KN->is_lethal[1]=1\n",
thisfunction);
KN->is_lethal[1] = 1;
KN->createlethal[1] = 0;
}
IF_DEBUG(DEBUG_LETHALS)
fprintf(stderr, "%s: KN->is_lethal[0]=%d\n", thisfunction, KN->is_lethal[0]);
IF_DEBUG(DEBUG_LETHALS)
fprintf(stderr, "%s: KN->is_lethal[1]=%d\n", thisfunction, KN->is_lethal[1]);
IF_DEBUG(DEBUG_LETHALS)
fprintf(stderr, "%s: if either of these are non-zero, expect normalization problems\n",
thisfunction);
}
}
示例5: main
int main (int argc, char *argv[])
{
int i, j, b;
bdescr *a[ARRSIZE];
srand(SEED);
hs_init(&argc, &argv);
// repeatedly sweep though the array, allocating new random-sized
// objects and deallocating the old ones.
for (i=0; i < LOOPS; i++)
{
for (j=0; j < ARRSIZE; j++)
{
if (i > 0)
{
IF_DEBUG(block_alloc, debugBelch("A%d: freeing %p, %d blocks @ %p\n", j, a[j], a[j]->blocks, a[j]->start));
freeGroup_lock(a[j]);
DEBUG_ONLY(checkFreeListSanity());
}
b = (rand() % MAXALLOC) + 1;
a[j] = allocGroup_lock(b);
IF_DEBUG(block_alloc, debugBelch("A%d: allocated %p, %d blocks @ %p\n", j, a[j], b, a[j]->start));
// allocating zero blocks isn't allowed
DEBUG_ONLY(checkFreeListSanity());
}
}
for (j=0; j < ARRSIZE; j++)
{
freeGroup_lock(a[j]);
}
// this time, sweep forwards allocating new blocks, and then
// backwards deallocating them.
for (i=0; i < LOOPS; i++)
{
for (j=0; j < ARRSIZE; j++)
{
b = (rand() % MAXALLOC) + 1;
a[j] = allocGroup_lock(b);
IF_DEBUG(block_alloc, debugBelch("B%d,%d: allocated %p, %d blocks @ %p\n", i, j, a[j], b, a[j]->start));
DEBUG_ONLY(checkFreeListSanity());
}
for (j=ARRSIZE-1; j >= 0; j--)
{
IF_DEBUG(block_alloc, debugBelch("B%d,%d: freeing %p, %d blocks @ %p\n", i, j, a[j], a[j]->blocks, a[j]->start));
freeGroup_lock(a[j]);
DEBUG_ONLY(checkFreeListSanity());
}
}
DEBUG_ONLY(checkFreeListSanity());
hs_exit(); // will do a memory leak test
exit(0);
}
示例6: assert
isl_set *nfm_constraint_from_set(isl_ctx *ctx,
nfm_constraint *constraints)
{
isl_printer *p;
assert(ctx);
assert(constraints);
IF_DEBUG(fprintf(stdout, " Transforming a constraint into ISL set.\n"));
p = isl_printer_to_str(ctx);
p = isl_printer_print_pw_qpolynomial(p, constraints->constraint);
char *str = isl_printer_get_str(p);
IF_DEBUG(fprintf(stdout, " The input Qpolynomianl constraint: %s\n", str));
assert(str);
/* Translate the qpolynomial into a map. */
char *set_str = (char *) malloc((strlen(str)+10)*sizeof(char));
strcpy(set_str, str);
IF_DEBUG2(fprintf(stdout, " set_str=%s\n", set_str));
size_t pos_arrow = strcspn(str, ">");
set_str[pos_arrow-1] = ' ';
set_str[pos_arrow] = ':';
IF_DEBUG2(fprintf(stdout, " set_str=%s\n", set_str));
size_t pos_colon = strcspn(&(str[pos_arrow+1]), ":");
if (strchr(&(str[pos_arrow+1]), ':') != NULL)
{
set_str[pos_arrow+1+pos_colon] = ' ';
IF_DEBUG2(fprintf(stdout, " set_str=%s\n", set_str));
if (constraints->eq == 1)
strcpy(&(set_str[pos_arrow+1+pos_colon]), " = 0 and ");
else
strcpy(&(set_str[pos_arrow+1+pos_colon]), " >= 0 and ");
IF_DEBUG2(fprintf(stdout, " set_str=%s\n", set_str));
strncpy(&(set_str[pos_arrow+pos_colon+10]), &(str[pos_arrow+1+pos_colon+1]), strlen(str) - pos_arrow - pos_colon);
IF_DEBUG2(fprintf(stdout, " set_str=%s\n", set_str));
}
else
{
size_t pos_bracket = strcspn(str, "}");
set_str[pos_bracket] = ' ';
if (constraints->eq == 1)
strcat(&(set_str[pos_bracket]), " = 0 }");
else
strcat(&(set_str[pos_bracket]), " >= 0 }");
}
IF_DEBUG(fprintf(stdout, " The Qpolynomial translated into a set is: %s\n", set_str));
isl_set *set = isl_set_read_from_str(ctx, set_str);
isl_printer_free(p);
return set;
}
示例7: spl_to_playlist_t
void spl_to_playlist_t(LIBMTP_mtpdevice_t* device, PTPObjectInfo *oi,
const uint32_t id, LIBMTP_playlist_t * const pl)
{
// Fill in playlist metadata
// Use the Filename as the playlist name, dropping the ".spl" extension
pl->name = malloc(sizeof(char)*(strlen(oi->Filename) -4 +1));
memcpy(pl->name, oi->Filename, strlen(oi->Filename) -4);
// Set terminating character
pl->name[strlen(oi->Filename) - 4] = 0;
pl->playlist_id = id;
pl->parent_id = oi->ParentObject;
pl->storage_id = oi->StorageID;
pl->tracks = NULL;
pl->no_tracks = 0;
IF_DEBUG() printf("pl->name='%s'\n",pl->name);
// open a temporary file
char tmpname[] = "/tmp/mtp-spl2pl-XXXXXX";
int fd = mkstemp(tmpname);
if(fd < 0) {
printf("failed to make temp file for %s.spl -> %s, errno=%s\n", pl->name, tmpname, strerror(errno));
return;
}
// make sure the file will be deleted afterwards
if(unlink(tmpname) < 0)
printf("failed to delete temp file for %s.spl -> %s, errno=%s\n", pl->name, tmpname, strerror(errno));
int ret = LIBMTP_Get_File_To_File_Descriptor(device, pl->playlist_id, fd, NULL, NULL);
if( ret < 0 ) {
// FIXME add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_Playlist: Could not get .spl playlist file.");
close(fd);
printf("FIXME closed\n");
}
text_t* p = read_into_spl_text_t(device, fd);
close(fd);
// FIXME cache these somewhere else so we don't keep calling this!
LIBMTP_folder_t *folders;
LIBMTP_file_t *files;
folders = LIBMTP_Get_Folder_List(device);
files = LIBMTP_Get_Filelisting_With_Callback(device, NULL, NULL);
// convert the playlist listing to track ids
pl->no_tracks = trackno_spl_text_t(p);
IF_DEBUG() printf("%u track%s found\n", pl->no_tracks, pl->no_tracks==1?"":"s");
pl->tracks = malloc(sizeof(uint32_t)*(pl->no_tracks));
tracks_from_spl_text_t(p, pl->tracks, folders, files);
free_spl_text_t(p);
// debug: add a break since this is the top level function call
IF_DEBUG() printf("------------\n\n");
}
示例8: update_reg_vif
/*
* Update the register vif in the multicast routing daemon and the
* kernel because the interface used initially to get its local address
* is DOWN. register_vifi is the index to the Register vif which needs
* to be updated. As a result the Register vif has a new uv_lcl_addr and
* is UP (virtually :))
*/
int
update_reg_vif( mifi_t register_vifi )
{
register struct uvif *v;
register mifi_t vifi;
/* Find the first useable vif with solid physical background */
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | MIFF_REGISTER))
continue;
/* Found. Stop the bogus Register vif first */
stop_vif(register_vifi);
add_phaddr(v, &uvifs[vifi].uv_linklocal->pa_addr,
&uvifs[vifi].uv_linklocal->pa_subnetmask,
&uvifs[vifi].uv_linklocal->pa_prefix);
start_vif(register_vifi);
IF_DEBUG(DEBUG_PIM_REGISTER | DEBUG_IF)
log_msg(LOG_NOTICE, 0, "%s has come up; vif #%u now in service",
uvifs[register_vifi].uv_name, register_vifi);
return 0;
}
vifs_down = TRUE;
log_msg(LOG_WARNING, 0, "Cannot start Register vif: %s",
uvifs[vifi].uv_name);
return(-1);
}
示例9: start_all_vifs
void start_all_vifs()
{
mifi_t vifi;
struct uvif *v;
u_int action;
/* Start first the NON-REGISTER vifs */
for (action = 0; ; action = MIFF_REGISTER) {
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
/*
* If starting non-registers but the vif is a register
* or if starting registers, but the interface is not
* a register, then just continue.
*/
if ((v->uv_flags & MIFF_REGISTER) ^ action)
continue;
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN)) {
IF_DEBUG(DEBUG_IF)
log_msg(LOG_DEBUG, 0,
"%s is %s; vif #%u out of service",
v->uv_name,
v->uv_flags & VIFF_DISABLED ? "DISABLED" : "DOWN",
vifi);
continue;
}
start_vif(vifi);
}
if (action == MIFF_REGISTER)
break;
}
}
示例10: stgMallocBytes
void *
stgMallocBytes (size_t n, char *msg)
{
void *space;
if ((space = malloc(n)) == NULL) {
/* Quoting POSIX.1-2008 (which says more or less the same as ISO C99):
*
* "Upon successful completion with size not equal to 0, malloc() shall
* return a pointer to the allocated space. If size is 0, either a null
* pointer or a unique pointer that can be successfully passed to free()
* shall be returned. Otherwise, it shall return a null pointer and set
* errno to indicate the error."
*
* Consequently, a NULL pointer being returned by `malloc()` for a 0-size
* allocation is *not* to be considered an error.
*/
if (n == 0) return NULL;
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */
rtsConfig.mallocFailHook((W_) n, msg);
stg_exit(EXIT_INTERNAL_ERROR);
}
IF_DEBUG(sanity, memset(space, 0xbb, n));
return space;
}
示例11: P3
void c_foreach P3(int, flags, int, idx1, int, idx2) {
IF_DEBUG(stack_in_use_as_temporary++);
if (flags & 4) {
CHECK_TYPES(sp, T_MAPPING, 2, F_FOREACH);
push_refed_array(mapping_indices(sp->u.map));
(++sp)->type = T_NUMBER;
sp->u.lvalue = (sp-1)->u.arr->item;
sp->subtype = (sp-1)->u.arr->size;
(++sp)->type = T_LVALUE;
if (flags & 2)
sp->u.lvalue = ¤t_object->variables[idx1 + variable_index_offset];
else
sp->u.lvalue = fp + idx1;
} else
if (sp->type == T_STRING) {
(++sp)->type = T_NUMBER;
sp->u.lvalue_byte = (unsigned char *)((sp-1)->u.string);
sp->subtype = SVALUE_STRLEN(sp - 1);
} else {
CHECK_TYPES(sp, T_ARRAY, 2, F_FOREACH);
(++sp)->type = T_NUMBER;
sp->u.lvalue = (sp-1)->u.arr->item;
sp->subtype = (sp-1)->u.arr->size;
}
(++sp)->type = T_LVALUE;
if (flags & 1)
sp->u.lvalue = ¤t_object->variables[idx2 + variable_index_offset];
else
sp->u.lvalue = fp + idx2;
}
示例12: beam_catches_init
void beam_catches_init(void)
{
int i;
bccix[0].tabsize = DEFAULT_TABSIZE;
bccix[0].free_list = -1;
bccix[0].high_mark = 0;
bccix[0].beam_catches = erts_alloc(ERTS_ALC_T_CODE,
sizeof(beam_catch_t)*DEFAULT_TABSIZE);
IF_DEBUG(bccix[0].is_staging = 0);
for (i=1; i<ERTS_NUM_CODE_IX; i++) {
bccix[i] = bccix[i-1];
}
/* For initial load: */
IF_DEBUG(bccix[erts_staging_code_ix()].is_staging = 1);
}
示例13: DECL_NEW_REG
/**
* \file profile.hpp
* \author Benjamin Segovia <[email protected]>
*/
#include "ir/profile.hpp"
#include "ir/function.hpp"
#include "sys/platform.hpp"
namespace gbe {
namespace ir {
namespace ocl
{
const char *specialRegMean[] = {
"local_id_0", "local_id_1", "local_id_2",
"group_id_0", "group_id_1", "group_id_2",
"num_groups_0", "num_groups_1", "num_groups_2",
"local_size_0", "local_size_1", "local_size_2",
"global_size_0", "global_size_1", "global_size_2",
"global_offset_0", "global_offset_1", "global_offset_2",
"stack_pointer",
"block_ip",
"barrier_id", "thread_number",
"work_dimension", "sampler_info",
"emask", "notemask", "barriermask", "retVal"
};
#if GBE_DEBUG
#define DECL_NEW_REG(FAMILY, REG) \
r = fn.newRegister(FAMILY_DWORD); \
GBE_ASSERT(r == REG);
#else
#define DECL_NEW_REG(FAMILY, REG) \
fn.newRegister(FAMILY_DWORD);
#endif /* GBE_DEBUG */
static void init(Function &fn) {
IF_DEBUG(Register r);
DECL_NEW_REG(FAMILY_DWORD, lid0);
DECL_NEW_REG(FAMILY_DWORD, lid1);
DECL_NEW_REG(FAMILY_DWORD, lid2);
DECL_NEW_REG(FAMILY_DWORD, groupid0);
DECL_NEW_REG(FAMILY_DWORD, groupid1);
DECL_NEW_REG(FAMILY_DWORD, groupid2);
DECL_NEW_REG(FAMILY_DWORD, numgroup0);
DECL_NEW_REG(FAMILY_DWORD, numgroup1);
DECL_NEW_REG(FAMILY_DWORD, numgroup2);
DECL_NEW_REG(FAMILY_DWORD, lsize0);
DECL_NEW_REG(FAMILY_DWORD, lsize1);
DECL_NEW_REG(FAMILY_DWORD, lsize2);
DECL_NEW_REG(FAMILY_DWORD, gsize0);
DECL_NEW_REG(FAMILY_DWORD, gsize1);
DECL_NEW_REG(FAMILY_DWORD, gsize2);
DECL_NEW_REG(FAMILY_DWORD, goffset0);
DECL_NEW_REG(FAMILY_DWORD, goffset1);
DECL_NEW_REG(FAMILY_DWORD, goffset2);
DECL_NEW_REG(FAMILY_DWORD, stackptr);
DECL_NEW_REG(FAMILY_WORD, blockip);
DECL_NEW_REG(FAMILY_DWORD, barrierid);
DECL_NEW_REG(FAMILY_DWORD, threadn);
DECL_NEW_REG(FAMILY_DWORD, workdim);
DECL_NEW_REG(FAMILY_WORD, samplerinfo);
DECL_NEW_REG(FAMILY_WORD, emask);
DECL_NEW_REG(FAMILY_WORD, notemask);
DECL_NEW_REG(FAMILY_WORD, barriermask);
DECL_NEW_REG(FAMILY_WORD, retVal);
}
示例14: Types_RegisterTypedef
int Types_RegisterTypedef(const char *Name, size_t NameLen, const tType *Type)
{
DEBUG_NL("(Name=%.*s, Type=", (int)NameLen, Name);
IF_DEBUG( Types_Print(stdout, Type) );
DEBUG_S(")\n");
tTypedef **pnp = &gpTypedefs;
for( tTypedef *td = gpTypedefs; td; pnp = &td->Next, td = td->Next )
{
int cmp = strncmp(td->Name, Name, NameLen);
if( cmp > 0 )
break;
if( cmp == 0 && strlen(td->Name) == NameLen )
{
if( Types_Compare(td->Base, Type) != 0 ) {
// Error! Incompatible redefinition
return -1;
}
// Compatible redefinition
return 1;
}
}
tTypedef *td = malloc( sizeof(tTypedef) + NameLen + 1 );
td->Name = (char*)(td + 1);
memcpy(td+1, Name, NameLen);
((char*)(td+1))[NameLen] = 0;
td->Base = Type;
td->Next = *pnp;
*pnp = td;
return 0;
}
示例15: timer_age_queue
/*
* elapsed_time seconds have passed; perform all the events that should
* happen.
*/
void timer_age_queue(int elapsed_time)
{
struct timeout_q *ptr;
#ifdef CALLOUT_DEBUG
IF_DEBUG(DEBUG_TIMEOUT)
logit(LOG_DEBUG, 0, "aging queue (elapsed time %d):", elapsed_time);
print_Q();
#endif
for (ptr = Q; Q; ptr = Q) {
if (ptr->time > elapsed_time) {
ptr->time -= elapsed_time;
break;
}
/* ptr has expired, push Q */
Q = ptr->next;
elapsed_time -= ptr->time;
if (ptr->func)
ptr->func(ptr->data);
free(ptr);
}
}