本文整理汇总了C++中DIAG函数的典型用法代码示例。如果您正苦于以下问题:C++ DIAG函数的具体用法?C++ DIAG怎么用?C++ DIAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DIAG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settings_restore
int settings_restore(settings_location location) {
int i;
lock();
EEFS_ERROR err;
DIAG(" %d\n", 0);
int addr = SETTINGS_START_ADDRESS + location * sizeof (settings);
for (i = 0; i < ADC_NUMBER_OF_INPUTS; i++) {
err = eefs_object_restore(addr + i, &settings[i], sizeof (settings_t));
DIAG("iperiod: %d", settings[i].integration_period);
if (err != EEFS_OK) {
DIAG("error loading settings");
settings_set_default();
unlock();
return 1;
}
}
actual_settings = settings;
DIAG("");
// err = eefs_object_restore(addr + i, &actual_settings, sizeof(settings_t*));
// if(err != EEFS_OK){
// actual_settings = settings;
// DIAG("error loading actual setting");
// }
unlock();
return 0;
}
示例2: set_desktop_widget
/* HR 270801
* Attach a desktop to a window
*/
global
void set_desktop_widget(XA_WINDOW *wind,
XA_TREE *desktop) /* HR tree --> widget */
{
XA_TREE *nt = xcalloc(1,sizeof(XA_TREE),103); /* HR: use calloc */
XA_WIDGET *wi = get_widget(wind, XAW_TOOLBAR); /* HR */
XA_WIDGET_LOCATION loc;
DIAG((D_widg,nil,"set_desktop_widget(wind=%d):[email protected]%lx\n", wind->handle, nt));
if (!nt)
{
DIAG((D_widg,nil," - unable to allocate widget.\n"));
return;
}
*nt = *desktop; /* HR desktop widget.tree */
loc.relative_type = LT;
loc.r = wind->r;
loc.r.y += MENU_H + 1;
loc.r.w -= MENU_H + 1;
wi->display = display_object_widget;
wi->click = click_desktop_widget;
wi->dclick = click_desktop_widget;
wi->drag = click_desktop_widget;
wi->loc = loc;
wi->state = NONE;
wi->stuff = nt;
wi->start = 0;
}
示例3: stream
static int stream()
{
unsigned iter = 0;
int id_buf[16];
int fp = dev->getDeviceHandle();
int ifirst = MAXINT;
int nbuf = 0;
int rc = ioctl(fp, RTM_T_START_STREAM_MAX, &transfer_buffers);
if (rc != 0){
perror("ioctl RTM_T_START_STREAM failed");
exit(errno);
}
while (iter < MAXITER){
DIAG("CALLING read\n");
int nread = read(fp, id_buf, NELEMS*sizeof(int));
int ibuf;
DIAG(" read returned %d\n", nread);
if (nread > 0){
for (ibuf = 0; ibuf < nread/sizeof(int); ++ibuf){
int nwrite = sizeof(int)*1;
if (id_buf[ibuf] <= ifirst ){
ifirst = id_buf[ibuf];
if (RECYCLE == 0){
++CYCLE;
}else{
if (++CYCLE >= RECYCLE){
CYCLE=0;
}
}
}
DIAG("CALLING process\n");
process(id_buf[ibuf], ++nbuf);
dbg(2, "write [%d] %d\n", ibuf, id_buf[ibuf]);
DIAG("CALLING write\n");
if (write(fp, id_buf+ibuf, nwrite) != nwrite ){
perror("write failed");
return -1;
}
}
}else{
perror("read error");
return nread;
}
iter = ++iter&MAXITER_MASK;
}
DIAG("all done\n");
return 0;
}
示例4: validate
bool validate(int M, vector<string>& nodes, int T, vector<string>& tags) {
if (M != nodes.size()) {
DIAG("ERROR: Specified node count is not same as actual node count !" << endl);
return false;
}
if (T * M != tags.size()) {
DIAG("ERROR: Specified total tag count is not same as expected tag count, NodeCount * TagCount !" << endl);
return false;
}
return true;
}
示例5: system_read_input
double system_read_input(system_flags_t* flag)
{
if(xSemaphoreTake(syslock, 1000) == pdFALSE){
DIAG("Cannot obtain sysmutex");
return 0;
}
/* get lock before doing a measurement. It guarantees that no settings changes
* are done while using the adc. */
double value, temperature;
*flag = 0;
if(is_temp_mode){
temperature = tmp245_read_temp_double();
value = temperature;
} else{
value = gain * adc_read_value(channel, (int*)flag) + offset;
if(resln == ADC_RESOLUTION_6_5){
if(fabs(value - acc_value) <= wn_delta){
acc_value = acc_value + (value - acc_value)/RESLN_6_5_FILTER_SIZE;
value = acc_value;
}else{
*flag |= SYS_FLAG_FILTER_OUT_WINDOW;
acc_value = value;
}
}
}
/* release semaphore when done. */
xSemaphoreGive(syslock);
assert(!isnan(value));
assert(!isinf(value));
return value;
}
示例6: stab_types_eq
bool stab_types_eq(struct stab *st, size_t a, size_t b) {
// todo: when cache in place, just check a == b
struct stab_type *at = STAB_TYPE(st, a), *bt = STAB_TYPE(st, b);
if (at->ty.tag != bt->ty.tag) {
return false;
} else {
switch (at->ty.tag) {
case TYPE_BOOLEAN:
case TYPE_CHAR:
case TYPE_INTEGER:
case TYPE_REAL:
case TYPE_STRING:
return true;
case TYPE_ARRAY:
return (at->ty.array.upper == bt->ty.array.upper
&& at->ty.array.lower == bt->ty.array.lower
&& at->ty.array.elt_type == bt->ty.array.elt_type);
case TYPE_FUNCTION:
case TYPE_RECORD:
return a == b;
case TYPE_POINTER:
return stab_types_eq(st, at->ty.pointer, bt->ty.pointer);
case TYPE_REF:
default:
DIAG("bad type for comparison!\n");
abort();
}
}
}
示例7: pointersize
void pointersize(int size)
{
if (prm_nasm && skipsize)
return;
/* if (needpointer)
*/ switch (size) {
case 10:
fprintf(outputFile,"TBYTE ");
break;
case 8:
fprintf(outputFile,"QWORD ");
break;
case 6:
if (!uses_float) {
fprintf(outputFile,"FWORD ");
break;
}
case 4:
fprintf(outputFile,"DWORD ");
break;
case 2:
fprintf(outputFile,"WORD ");
break;
case 1:
fprintf(outputFile,"BYTE ");
break;
default:
DIAG("Bad pointer");
}
if (!prm_nasm)
fprintf(outputFile,"PTR ");
}
示例8: rtopxy
global
void *form_save(int d, RECT r, void *area)
{
MFDB Mscreen={0};
MFDB Mpreserve;
G_i pnt[8];
r.x-=d, r.y-=d, r.w+=2*d, r.h+=2*d;
rtopxy(pnt, &r);
ritopxy(pnt+4,0,0,r.w,r.h);
DIAG((D_menu,nil,"form_save %d/%d,%d/%d\n",r.x,r.y,r.w,r.h));
Mpreserve.fd_w = r.w;
Mpreserve.fd_h = r.h;
Mpreserve.fd_wdwidth = (r.w + 15) / 16;
Mpreserve.fd_nplanes = screen.planes;
Mpreserve.fd_stand = 0;
if (area == nil)
area = xmalloc(calc_back(&r,screen.planes),210);
if (area)
{
Mpreserve.fd_addr = area;
vro_cpyfm(C.vh, S_ONLY, pnt, &Mscreen, &Mpreserve);
}
return area;
}
示例9: seg_number_of_tribs
int seg_number_of_tribs(int r, int c, SEGMENT *streams, SEGMENT *dirs)
{
int trib = 0;
int i, j;
int streams_cell = 0;
int dirs_cell = 0;
for (i = 1; i < 9; ++i) {
if (NOT_IN_REGION(i))
continue;
j = DIAG(i);
Segment_get(streams, &streams_cell, NR(i), NC(i));
Segment_get(dirs, &dirs_cell, NR(i), NC(i));
if (streams_cell && dirs_cell == j)
trib++;
}
if (trib > 5)
G_fatal_error(_("Error finding nodes. "
"Stream and direction maps probably do not match."));
if (trib > 3)
G_warning(_("Stream network may be too dense"));
return trib;
}
示例10: seg_trib_nums
int seg_trib_nums(int r, int c, SEGMENT *streams, SEGMENT *dirs)
{ /* calculate number of tributaries */
int trib_num = 0;
int i, j;
int next_r, next_c;
int streams_cell, streams_next_cell, dirs_next_cell;
Segment_get(streams, &streams_cell, r, c);
for (i = 1; i < 9; ++i) {
if (NOT_IN_REGION(i))
continue;
j = DIAG(i);
next_r = NR(i);
next_c = NC(i);
Segment_get(streams, &streams_next_cell, next_r, next_c);
Segment_get(dirs, &dirs_next_cell, next_r, next_c);
if (streams_next_cell > 0 && dirs_next_cell == j)
trib_num++;
}
if (trib_num > 1)
for (i = 1; i < 9; ++i) {
if (NOT_IN_REGION(i))
continue;
j = DIAG(i);
next_r = NR(i);
next_c = NC(i);
Segment_get(streams, &streams_next_cell, next_r, next_c);
Segment_get(dirs, &dirs_next_cell, next_r, next_c);
if (streams_next_cell == streams_cell && dirs_next_cell == j)
trib_num--;
}
if (trib_num > 5)
G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match"));
if (trib_num > 3)
G_warning(_("Stream network may be too dense"));
return trib_num;
} /* end trib_num */
示例11: putlen
void putlen(int l)
/*
* append the length field to an instruction.
*/
{
if (l!= 10 && l != 8 && l != 6 && l != 4 && l != 1 && l != 2 && l != 0)
DIAG("illegal length field.");
}
示例12: stab_resolve_complex_type
static size_t stab_resolve_complex_type(struct stab *st, char *name, struct ast_type *ty) {
struct stab_type *t = M(struct stab_type);
t->defn = NULL;
t->name = name;
t->ty.tag = ty->tag;
t->magic = 0;
switch (ty->tag) {
case TYPE_POINTER:
t->ty.pointer = stab_resolve_type(st, strdup(name), ty->pointer);
t->size = ABI_POINTER_SIZE; // XHAZARD
t->align = ABI_POINTER_ALIGN; // XHAZARD
break;
case TYPE_RECORD:
t->ty.record.fields = list_empty(CB free_stab_record_field);
LFOREACH(struct ast_record_field *field, ty->record)
// todo: check that field name is unique
list_add(t->ty.record.fields, YOLO stab_record_field(field->name, stab_resolve_type(st, strdup(field->name), field->type)));
ENDLFOREACH;
break;
case TYPE_ARRAY:
t->ty.array.lower = atoi(ty->array.lower);
t->ty.array.upper = atoi(ty->array.upper);
t->ty.array.elt_type = stab_resolve_type(st, strdup("<array elts>"), ty->array.elt_type);
t->size = STAB_TYPE(st, t->ty.array.elt_type)->size * (t->ty.array.upper - t->ty.array.lower);
break;
case TYPE_FUNCTION:
t->ty.func.type = ty->func.type;
t->ty.func.retty = stab_resolve_type(st, strdup("<func ret>"), ty->func.retty);
t->ty.func.args = list_empty(CB dummy_free);
t->ty.func.ret_assigned = false;
t->magic = 0;
LFOREACH(struct ast_decls *decl, ty->func.args)
LFOREACH(char *name, decl->names)
size_t id = stab_resolve_type(st, strdup(name), decl->type);
list_add(t->ty.func.args, YOLO stab_add_var(st, strdup(name), id, NULL, NULL, false));
ENDLFOREACH;
ENDLFOREACH;
t->size = ABI_CLOSURE_SIZE; // XHAZARD
t->align = ABI_CLOSURE_ALIGN; // XHAZARD
break;
default:
DIAG("resolve_complex_type given simple type!\n");
abort();
return -1;
}
return ptrvec_push(st->types, YOLO t);
}
示例13: process
static void process(int ibuf, int nbuf){
if (VERBOSE){
fprintf(stderr, "%02d\n", ibuf);
}
char buf[80];
sprintf(buf, "%s/%06d/", OUTROOT, CYCLE);
mkdir(buf, 0777);
sprintf(buf, "%s/%06d/%d.%02d", OUTROOT, CYCLE, dev->getDevnum(), ibuf);
if (NO_OVERWRITE){
struct stat stat_buf;
int rc = stat(buf, &stat_buf);
DIAG("stat:rc %d errno %d\n", rc, errno);
if (rc == 0){
err("OVERRUN: NO_OVERWRITE SET and \"%s\" exists",
buf);
exit(1);
}else if (errno != ENOENT){
err("OVERRUN: NO_OVERWRITE SET and \"%s\" exists",
buf);
perror("buf");
exit(errno);
}else{
; /* ENOENT - that's good! */
}
}
int outfp = open(buf, O_MODE, PERM);
if (outfp == -1){
perror(buf);
_exit(errno);
}
write(outfp, dev->getHostBufferMapping(ibuf), maxlen);
strcat(buf, ".id");
int out_meta = open(buf, O_MODE, PERM);
write_meta(out_meta, ibuf, nbuf);
close(out_meta);
close(outfp); /* close data last - we monitor this one */
if (PUT_DATA){
char *cp = strstr(buf, ".id");
if (cp){
*cp = '\0';
}
}
puts(buf);
if (USLEEP){
usleep(USLEEP);
}
}
示例14: DIAG
/* HR 021101: new function to make the code orthogonal.
*/
static
G_i *transform_icon_bitmap(XA_CLIENT *client, CICONBLK *icon, G_i *map, long len, int planes)
{
MFDB src, dst;
G_i *new_data = map, *tmp = nil;
long icon_len = len * planes,
new_len = len * screen.planes;
DIAG((D_s,client,"icon_len %ld, new_len %ld\n", icon_len, new_len));
if (planes < screen.planes)
{
DIAG((D_x,client,"XA_calloc 3 %ld\n", new_len));
new_data = XA_calloc(&client->base, 1, new_len, 3, client->rsct); /* HR: and put in a list. */
if (new_data == nil) /* HR 021101: check */
return map;
memcpy(new_data, map, icon_len);
}
src.fd_w = icon->monoblk.ic.w; /* Transform MFDB's */
src.fd_h = icon->monoblk.ic.h;
src.fd_wdwidth = (src.fd_w + 15) / 16; /* HR: round up */
src.fd_stand = 1;
src.fd_r1 = src.fd_r2 = src.fd_r3 = 0;
src.fd_nplanes = screen.planes; /* HR */
dst = src;
dst.fd_addr = new_data;
dst.fd_stand = 0;
DIAG((D_x,client,"XA_calloc %d*%ld\n", 1, new_len));
tmp = XA_calloc(nil, 1, new_len, 0, 0);
if (tmp) /* HR 021101: check */
{
memcpy(tmp, new_data, new_len);
src.fd_addr = tmp;
transform_gem_bitmap_data(src, dst, planes, screen.planes);
/* vr_trnfm( C.vh, &src, &dst ); */
free(tmp);
}
return new_data;
}
示例15: EventLoop
static void
EventLoop (void)
{
EventType event;
SDWord timeout;
UInt32 timer_next;
Word error;
do
{
timeout = evtWaitForever;
timer_next = 0;
if (needRedisplay)
timeout = 0;
else if (game.timer_running)
{
UInt32 now = TimGetTicks ();
int sec = (now - game.timer_start) / sysTicksPerSecond;
timer_next = ((sec + 1) * sysTicksPerSecond + game.timer_start);
timeout = timer_next - now;
}
EvtGetEvent (&event, timeout);
DIAG (("Event %d\n", event.eType));
if (timer_next && TimGetTicks () <= timer_next)
DamageCount ();
if (needRedisplay && event.eType == nilEvent)
FrmUpdateForm (mainForm, frmRedrawUpdateCode);
if (event.eType == nilEvent)
continue;
/* Give the system a chance to handle the event. */
if (! SysHandleEvent (&event))
{
if (!MenuHandleEvent (0, &event, &error))
{
/* Give the application a chance to handle the event. */
if (!ApplicationHandleEvent (&event))
{
/* Let the form object provide default handling of the event. */
FrmDispatchEvent (&event);
}
}
}
}
while (event.eType != appStopEvent);
// ** SPECIAL NOTE **
// In order for the Emulator to exit
// cleanly when the File|Quit menu option is
// selected, the running application
// must exit. The emulator will generate an
// ÒappStopEventÓ when Quit is selected.
}