本文整理汇总了C++中do_error函数的典型用法代码示例。如果您正苦于以下问题:C++ do_error函数的具体用法?C++ do_error怎么用?C++ do_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_progress_rpt
void
init_progress_rpt (void)
{
/*
* allocate the done vector
*/
if ((prog_rpt_done = (__uint64_t *)
malloc(sizeof(__uint64_t)*glob_agcount)) == NULL ) {
do_error(_("cannot malloc pointer to done vector\n"));
}
bzero(prog_rpt_done, sizeof(__uint64_t)*glob_agcount);
/*
* Setup comm block, start the thread
*/
pthread_mutex_init(&global_msgs.mutex, NULL);
global_msgs.count = glob_agcount;
global_msgs.interval = report_interval;
global_msgs.done = prog_rpt_done;
global_msgs.total = &prog_rpt_total;
if (pthread_create (&report_thread, NULL,
progress_rpt_thread, (void *)&global_msgs))
do_error(_("unable to create progress report thread\n"));
return;
}
示例2: save_city
void
save_city (char *cname)
{
char *s, *s2, *s3, *s4;
int l;
if ((l = strlen (cname)) < 2)
return;
if ((s = (char *) malloc (lc_save_dir_len + l + 16)) == 0)
malloc_failure ();
if ((s2 = (char *) malloc (lc_save_dir_len + l + 32)) == 0)
malloc_failure ();
if ((s3 = (char *) malloc ((lc_save_dir_len + l) * 2 + 32)) == 0)
malloc_failure ();
if ((s4 = (char *) malloc ((lc_save_dir_len + l) * 2 + 32)) == 0)
malloc_failure ();
sprintf (s, "%s%c%s", lc_save_dir, PATH_SLASH, cname);
sprintf (s2, "%s%c%s", lc_save_dir, PATH_SLASH, "tmp-save");
sprintf (s3, "gzip -f %s", s2);
sprintf (s4, "mv %s.gz %s", s2, s);
save_city_raw (s2);
if (system (s3) != 0)
do_error ("gzip failed while in save_city");
if (system (s4) != 0)
do_error ("mv failed while in save_city");
free (s);
free (s2);
free (s3);
free (s4);
}
示例3: do_page_out
/* 将被替换页面的内容写回辅存 */
void do_page_out(Ptr_PageTableItem ptr_pageTabIt)
{
unsigned int writeNum;
if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt, ftell(ptr_auxMem));
#endif
do_error(ERROR_FILE_SEEK_FAILED);
exit(1);
}
if ((writeNum = fwrite(actMem + ptr_pageTabIt->blockNum * PAGE_SIZE,
sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
printf("DEBUG: writeNum=%u\n", writeNum);
printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
do_error(ERROR_FILE_WRITE_FAILED);
exit(1);
}
printf("写回成功:物理块%u-->>辅存地址%03X\n", ptr_pageTabIt->auxAddr, ptr_pageTabIt->blockNum);
}
示例4: do_page_in
/* 将辅存内容写入实存 */
void do_page_in(Ptr_PageTableItem ptr_pageTabIt, unsigned int blockNum)
{
unsigned int readNum;
//打开辅存文件ptr_auxMem,从文件开头(SEEK_SET)处偏移ptr_pageTabIt->auxAddr(该页表在辅存中的位置)开始读取数据
if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
#endif
do_error(ERROR_FILE_SEEK_FAILED);
exit(1);
}
//从之前打开的ptr_auxMem文件流中读取数据,写入到实存中指定块的位置(actMem + blockNum * PAGE_SIZE)
//读写字节的大小(sizeof(BYTE)) 读写4个字节(PAGE_SIZE)
//初始化时并没有设置辅存中的数据,所以辅存为空,读取会失败
if ((readNum = fread(actMem + blockNum * PAGE_SIZE,
sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
printf("DEBUG: blockNum=%u\treadNum=%u\n", blockNum, readNum);
printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
do_error(ERROR_FILE_READ_FAILED);
exit(1);
}
printf("调页成功:辅存地址%u-->>物理块%u\n", ptr_pageTabIt->auxAddr, blockNum);
}
示例5: do_list_all
void do_list_all(int cli_fd, struct be_msg *rmsg)
{
struct be_group *group = NULL;
struct be_vc *curr;
struct be_msg smsg;
for(group = &group_head; group != NULL; group = group->next) {
for(curr = group->head; curr != NULL; curr = curr->next) {
smsg.msgtype = OK;
smsg.nas_idx = curr->nas_idx;
smsg.uid = curr->uid;
memcpy(&smsg.pvc, &curr->pvc, sizeof(struct sockaddr_atmpvc));
memcpy(&smsg.name, group->name, MAX_GROUPNAME_LEN);
// brcm begin
smsg.mode = curr->mode;
// brcm end
if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
do_error(LOG_ERR,"do_list_all() couldn't send VC info: %s",strerror(errno));
}
}
if(smsg.msgtype == OK)
smsg.msgtype = LIST_END;
else
smsg.msgtype = GROUP_NOT_FOUND;
if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
do_error(LOG_ERR,"do_list_all() couldn't send LIST_END message: %s",strerror(errno));
}
示例6: write_primary_sb
void
write_primary_sb(xfs_sb_t *sbp, int size)
{
xfs_dsb_t *buf;
if (no_modify)
return;
buf = memalign(libxfs_device_alignment(), size);
if (buf == NULL) {
do_error(_("failed to memalign superblock buffer\n"));
return;
}
memset(buf, 0, size);
if (lseek64(x.dfd, 0LL, SEEK_SET) != 0LL) {
free(buf);
do_error(_("couldn't seek to offset 0 in filesystem\n"));
}
libxfs_sb_to_disk(buf, sbp, XFS_SB_ALL_BITS);
if (write(x.dfd, buf, size) != size) {
free(buf);
do_error(_("primary superblock write failed!\n"));
}
free(buf);
}
示例7: do_page_out
/* 将被替换页面的内容写回辅存 */
void do_page_out(Ptr_PageTableItem ptr_pageTabIt)
{
unsigned int writeNum;
//同上,从辅存中相应页面的地址开始读写
if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt, ftell(ptr_auxMem));
#endif
do_error(ERROR_FILE_SEEK_FAILED);
exit(1);
}
//fwrite()与fread()的区别是,fwrite()执行完之后必须关闭流fclose(),而fread()不关闭会将流移动到上次读写结束的地址
if ((writeNum = fwrite(actMem + ptr_pageTabIt->blockNum * PAGE_SIZE,
sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
printf("DEBUG: writeNum=%u\n", writeNum);
printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
do_error(ERROR_FILE_WRITE_FAILED);
exit(1);
}
printf("写回成功:物理块%u-->>辅存地址%03X\n", ptr_pageTabIt->auxAddr, ptr_pageTabIt->blockNum);
/********************************************************************************************************/
//fclose(ptr_auxMem); main函数里面关闭了
/********************************************************************************************************/
}
示例8: do_list_group
void do_list_group(int cli_fd, struct be_msg *rmsg)
{
struct be_group *group;
struct be_vc *curr;
struct be_msg smsg;
smsg.msgtype = GROUP_NOT_FOUND;
for(group = &group_head; group != NULL; group = group->next)
if(!strncmp(rmsg->name,group->name,MAX_GROUPNAME_LEN))
break;
if(group) {
for(curr = group->head; curr != NULL; curr = curr->next) {
smsg.msgtype = OK;
smsg.nas_idx = curr->nas_idx;
smsg.uid = curr->uid;
memcpy(&smsg.pvc, &curr->pvc, sizeof(struct sockaddr_atmpvc));
memcpy(&smsg.name, &group->name, MAX_GROUPNAME_LEN);
if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
do_error(LOG_ERR,"do_list_group() couldn't send OK message: %s",strerror(errno));
}
smsg.msgtype = LIST_END;
}
if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )
do_error(LOG_ERR,"do_list_group() couldn't send LIST_END message: %s",strerror(errno));
}
示例9: ocfs2_validate_gd_parent
static int ocfs2_validate_gd_parent(struct super_block *sb,
struct ocfs2_dinode *di,
struct buffer_head *bh,
int clean_error)
{
unsigned int max_bits;
struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
if (di->i_blkno != gd->bg_parent_dinode) {
do_error("Group descriptor #%llu has bad parent "
"pointer (%llu, expected %llu)",
(unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
(unsigned long long)le64_to_cpu(di->i_blkno));
return -EINVAL;
}
max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
if (le16_to_cpu(gd->bg_bits) > max_bits) {
do_error("Group descriptor #%llu has bit count of %u",
(unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_bits));
return -EINVAL;
}
if (le16_to_cpu(gd->bg_chain) >=
le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
do_error("Group descriptor #%llu has bad chain %u",
(unsigned long long)bh->b_blocknr,
le16_to_cpu(gd->bg_chain));
return -EINVAL;
}
return 0;
}
示例10: new_connection
void new_connection(TCPsocket sock) {
TCPsocket tmp;
struct socket_node *socket;
IPaddress *ip;
/* accept the connection temporarily */
tmp = SDLNet_TCP_Accept(sock);
if (!tmp)
do_error(SDLNet_GetError());
/* are we full or game already started? */
if (get_active_players() + 1 > NUM_PLAYERS || current_turn)
SDLNet_TCP_Close(tmp);
else {
/* nope! */
socket = new_socket(SOCKET_CLIENT);
socket->sock = tmp;
if (SDLNet_TCP_AddSocket(sockset, tmp) < 0)
do_error(SDLNet_GetError());
ip = SDLNet_TCP_GetPeerAddress(tmp);
if (!ip)
do_error(SDLNet_GetError());
if (SDLNet_ResolveIP(ip))
strcpy(socket->host, SDLNet_ResolveIP(ip));
else
sprintf(socket->host, "Unknown IP");
join_player(socket); /* add player to game */
}
}
示例11: do_print_virtual
void do_print_virtual(){
int i,j,k,readNum,p;
printf("打印辅存内容:\n");
BYTE temp[VIRTUAL_MEMORY_SIZE];
if (fseek(ptr_auxMem, 0, SEEK_SET) < 0)
{
do_error(ERROR_FILE_SEEK_FAILED);
exit(1);
}
if ((readNum = fread(temp,
sizeof(BYTE), VIRTUAL_MEMORY_SIZE, ptr_auxMem)) < VIRTUAL_MEMORY_SIZE)
{
do_error(ERROR_FILE_READ_FAILED);
exit(1);
}
printf("1级页号\t2级页号\t辅存\t内容\t\n");
for(i=0,k=0;i<ROOT_PAGE_SUM;i++)
{
for(p=0;p<CHILD_PAGE_SUM;p++)
{
printf("%d\t%d\t%d\t",i,p,k);
for(j=0;j<PAGE_SIZE;j++){
printf("%02x ",temp[k++]);
}
printf("\n");
}
}
}
示例12: incore_ino_init
void
incore_ino_init(xfs_mount_t *mp)
{
int i;
int agcount = mp->m_sb.sb_agcount;
if ((inode_tree_ptrs = malloc(agcount *
sizeof(avltree_desc_t *))) == NULL)
do_error(_("couldn't malloc inode tree descriptor table\n"));
if ((inode_uncertain_tree_ptrs = malloc(agcount *
sizeof(avltree_desc_t *))) == NULL)
do_error(
_("couldn't malloc uncertain ino tree descriptor table\n"));
for (i = 0; i < agcount; i++) {
if ((inode_tree_ptrs[i] =
malloc(sizeof(avltree_desc_t))) == NULL)
do_error(_("couldn't malloc inode tree descriptor\n"));
if ((inode_uncertain_tree_ptrs[i] =
malloc(sizeof(avltree_desc_t))) == NULL)
do_error(
_("couldn't malloc uncertain ino tree descriptor\n"));
}
for (i = 0; i < agcount; i++) {
avl_init_tree(inode_tree_ptrs[i], &avl_ino_tree_ops);
avl_init_tree(inode_uncertain_tree_ptrs[i], &avl_ino_tree_ops);
}
if ((last_rec = malloc(sizeof(ino_tree_node_t *) * agcount)) == NULL)
do_error(_("couldn't malloc uncertain inode cache area\n"));
memset(last_rec, 0, sizeof(ino_tree_node_t *) * agcount);
full_ino_ex_data = 0;
}
示例13: do_page_in
/* 将辅存内容写入实存 */
void do_page_in(Ptr_PageTableItem ptr_pageTabIt, unsigned int blockNum)
{
unsigned int readNum;
if (fseek(ptr_auxMem, ptr_pageTabIt->auxAddr, SEEK_SET) < 0)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
#endif
do_error(ERROR_FILE_SEEK_FAILED);
exit(1);
}
if ((readNum = fread(actMem + blockNum * PAGE_SIZE,
sizeof(BYTE), PAGE_SIZE, ptr_auxMem)) < PAGE_SIZE)
{
#ifdef DEBUG
printf("DEBUG: auxAddr=%u\tftell=%u\n", ptr_pageTabIt->auxAddr, ftell(ptr_auxMem));
printf("DEBUG: blockNum=%u\treadNum=%u\n", blockNum, readNum);
printf("DEGUB: feof=%d\tferror=%d\n", feof(ptr_auxMem), ferror(ptr_auxMem));
#endif
do_error(ERROR_FILE_READ_FAILED);
exit(1);
}
printf("调页成功:辅存地址%u-->>物理块%u\n", ptr_pageTabIt->auxAddr, blockNum);
}
示例14: print_final_rpt
__uint64_t
print_final_rpt(void)
{
int i;
struct tm *tmp;
time_t now;
__uint64_t *donep;
__uint64_t sum;
msg_block_t *msgp = &global_msgs;
char msgbuf[DURATION_BUF_SIZE];
if (!ag_stride)
return 0;
if (pthread_mutex_lock(&global_msgs.mutex))
do_error(_("print_final_rpt: cannot lock progress mutex\n"));
bzero(&msgbuf, sizeof(msgbuf));
now = time (NULL);
tmp = localtime ((const time_t *) &now);
/*
* Sum the work
*/
sum = 0;
donep = msgp->done;
for (i = 0; i < msgp->count; i++) {
sum += *donep++;
}
if (report_interval) {
switch(msgp->format->format) {
case FMT1:
sprintf (msgbuf, _(*msgp->format->fmt),
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
_(msgp->format->msg), sum,
*msgp->total, _(*msgp->format->type));
break;
case FMT2:
sprintf (msgbuf, _(*msgp->format->fmt),
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
_(msgp->format->msg), sum,
_(*msgp->format->type));
break;
}
do_log(_("%s"), msgbuf);
}
if (pthread_mutex_unlock(&global_msgs.mutex))
do_error(_("print_final_rpt: cannot unlock progress mutex\n"));
return(sum);
}
示例15: init_net
void init_net() {
if (SDLNet_Init() < 0)
do_error("Failed initializing SDL_net (\"%s\")", SDLNet_GetError());
sockset = SDLNet_AllocSocketSet(NUM_PLAYERS);
if (!sockset)
do_error(SDLNet_GetError());
online = 0;
server = 0;
}