static void __raise_pagefault ( struct mon_t *mon, struct segv_info_t *si ) { bit32u_t err_code = get_err_code ( mon, si ); mon->regs->sys.cr2 = si->cr2; Monitor_raise_interrupt ( mon, IVECTOR_PAGEFAULT ); Monitor_pushl ( mon->regs, err_code ); }
static int ret_ok(char *reply) { int err; if (reply == NULL) return -1; err = get_err_code(reply); if ((err>=100) && (err<300)) return 1; if (err>=300) return 0; SPD_FATAL("Internal error during communication."); }
void TS::set_gtest_status() { TS::FailureCode code = get_err_code(); if( code >= 0 ) return SUCCEED(); char seedstr[32]; sprintf(seedstr, "%08x%08x", (unsigned)(current_test_info.rng_seed>>32), (unsigned)(current_test_info.rng_seed)); string logs = ""; if( !output_buf[SUMMARY_IDX].empty() ) logs += "\n-----------------------------------\n\tSUM: " + output_buf[SUMMARY_IDX]; if( !output_buf[LOG_IDX].empty() ) logs += "\n-----------------------------------\n\tLOG:\n" + output_buf[LOG_IDX]; if( !output_buf[CONSOLE_IDX].empty() ) logs += "\n-----------------------------------\n\tCONSOLE: " + output_buf[CONSOLE_IDX]; logs += "\n-----------------------------------\n"; FAIL() << "\n\tfailure reason: " << str_from_code(code) << "\n\ttest case #" << current_test_info.test_case_idx << "\n\tseed: " << seedstr << logs; }
static void* spd_events_handler(void* conn) { char *reply; int reply_code; SPDConnection *connection = conn; while(1){ /* Read the reply/event (block if none is available) */ SPD_DBG("Getting reply in spd_events_handler"); reply = get_reply(connection); if (reply == NULL){ SPD_DBG("ERROR: BROKEN SOCKET"); reply_code = -1; }else{ SPD_DBG("<< : |%s|\n", reply); reply_code = get_err_code(reply); } if ((reply_code >= 700) && (reply_code < 800)){ int msg_id; int client_id; int err; SPD_DBG("Callback detected: %s", reply); /* This is an index mark */ /* Extract message id */ msg_id = get_param_int(reply, 1, &err); if (err < 0){ SPD_DBG("Bad reply from Speech Dispatcher: %s (code %d)", reply, err); break; } client_id = get_param_int(reply, 2, &err); if (err < 0){ SPD_DBG("Bad reply from Speech Dispatcher: %s (code %d)", reply, err); break; } /* Decide if we want to call a callback */ if ((reply_code == 701) && (connection->callback_begin)) connection->callback_begin(msg_id, client_id, SPD_EVENT_BEGIN); if ((reply_code == 702) && (connection->callback_end)) connection->callback_end(msg_id, client_id, SPD_EVENT_END); if ((reply_code == 703) && (connection->callback_cancel)) connection->callback_cancel(msg_id, client_id, SPD_EVENT_CANCEL); if ((reply_code == 704) && (connection->callback_pause)) connection->callback_pause(msg_id, client_id, SPD_EVENT_PAUSE); if ((reply_code == 705) && (connection->callback_resume)) connection->callback_resume(msg_id, client_id, SPD_EVENT_RESUME); if ((reply_code == 700) && (connection->callback_im)){ char* im; int err; im = get_param_str(reply, 3, &err); if ((err < 0) || (im == NULL)){ SPD_DBG("Broken reply from Speech Dispatcher: %s", reply); break; } /* Call the callback */ connection->callback_im(msg_id, client_id, SPD_EVENT_INDEX_MARK, im); xfree(im); } }else{ /* This is a protocol reply */ pthread_mutex_lock(connection->mutex_reply_ready); /* Prepare the reply to the reply buffer in connection */ if (reply != NULL){ connection->reply = strdup(reply); }else{ SPD_DBG("Connection reply is NULL"); connection->reply = NULL; break; } /* Signal the reply is available on the condition variable */ /* this order is correct and necessary */ pthread_cond_signal(connection->cond_reply_ready); pthread_mutex_lock(connection->mutex_reply_ack); pthread_mutex_unlock(connection->mutex_reply_ready); /* Wait until it has bean read */ pthread_cond_wait(connection->cond_reply_ack, connection->mutex_reply_ack); pthread_mutex_unlock(connection->mutex_reply_ack); xfree(reply); /* Continue */ } } /* In case of broken socket, we must still signal reply ready */ if (connection->reply == NULL){ SPD_DBG("Signalling reply ready after communication failure"); pthread_mutex_unlock(connection->mutex_reply_ready); pthread_mutex_unlock(connection->mutex_reply_ack); if (connection->stream != NULL) fclose(connection->stream); connection->stream = NULL; pthread_cond_signal(connection->cond_reply_ready); pthread_exit(0); } return 0; /* to please gcc */ }