本文整理汇总了C++中ISERR函数的典型用法代码示例。如果您正苦于以下问题:C++ ISERR函数的具体用法?C++ ISERR怎么用?C++ ISERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ISERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preclone_sigs_setup
//******************************************************************************
//*preclone stuff (if too much, will go away in another source file)
//*fds mapping:
//* - 0 connexion socket
//* - 1 connexion socket
//* - 2 parent stderr
//* - 3 epoll
//* - 4 signalfd fd
//* - 5 parent unix socket for receiving connexion socket
//******************************************************************************
static void preclone_sigs_setup(void)
{
//cannot change SIGKILL, neither SIGSTOP
ul mask=(~0);
l r=rt_sigprocmask(SIG_BLOCK,&mask,0,sizeof(mask));
if(ISERR(r)){
PERR("FATAL:child:preclone:%d:error blocking mostly all signals (%ld)\n",
preclone_slot,r);
exit(-1);
}
mask=SIGBIT(SIGTERM);
i sigs_fd=(i)signalfd4(-1,&mask,sizeof(mask),SFD_NONBLOCK);
if(ISERR(r)){
PERR("FATAL:child:preclone:%d:error setting up fd for signals (%d)\n",
preclone_slot,sigs_fd);
exit(-1);
}
if(sigs_fd!=4){//moving signalfd fd to 4, if required
r=dup2(sigs_fd,4);
if(ISERR(r)){
PERR("FATAL:child:preclone:%d:unable to move signalfd fd (%ld)\n",
preclone_slot,r);
exit(-1);
}
do r=close(sigs_fd); while(r==-EINTR);
}
}
示例2: srv_sock_create
static void srv_sock_create(void)
{
//TCP on IPv4... erk!
srv_sock=(i)socket(PF_INET,SOCK_STREAM|SOCK_NONBLOCK,0);
if(ISERR(srv_sock)){
PERR("FATAL:unable to create the server listening socket:%d\n",srv_sock);
kill(0,SIGTERM);
exit(-1);
}
l bool_true=1;
l r=setsockopt(srv_sock,SOL_SOCKET,SO_REUSEADDR,&bool_true,sizeof(bool_true));
if(ISERR(r)){
PERR("FATAL:unable to turn on socket rebinding option:%ld\n",r);
kill(0,SIGTERM);
exit(-1);
}
r=bind(srv_sock,&srv_addr,sizeof(srv_addr));
if(ISERR(r)){
PERR("FATAL:unable to bind address/port on server listening socket:%ld\n",r);
kill(0,SIGTERM);
exit(-1);
}
r=listen(srv_sock,0);
if(ISERR(r)){
PERR("FATAL:unable to flag server listening socket:%ld\n",r);
kill(0,SIGTERM);
exit(-1);
}
}
示例3: ep_p_new
//based on the ep type, we may need to book enough room to put a worst case
//scenario of a concatenated sub-p with the ep p rem
static s8 ep_p_new(struct ep *ep,void *p_str,u64 p_sz)
{
//We will do some p concatenation for the following p types. Then book room
//for the worst case scenario.
u64 str_sz=ep->type=='?'||ep->type=='@'?ep->full_p_sz:p_sz;
l addr;
u64 map_sz;
if(!ep->ps){//first allocation
map_sz=sizeof(*ep->ps)+str_sz+1;//count the 0 terminating char
addr=mmap(map_sz,RD|WR,PRIVATE|ANONYMOUS);
if(!addr||ISERR(addr)) return ERR_NOMEM;
ep->last=0;
}else{
u64 new_p_sz=sizeof(*ep->ps)+str_sz+1;//count the 0 terminating char
map_sz=ep->sz+new_p_sz;
addr=mremap(ep->ps,ep->sz,map_sz);
if(!addr||ISERR(addr)) return ERR_NOMEM;//ep is unmapped elsewhere
struct p *p_last=(struct p*)((u8*)(ep->ps)+ep->last);
ep->last+=sizeof(*p_last)+p_last->sz+1;//count the 0 terminating char
}
ep->ps=(struct p*)addr;
ep->sz=map_sz;
struct p *p=(struct p*)((u8*)(ep->ps)+ep->last);
p->sz=str_sz;
memcpy(&p->str[0],p_str,p_sz);//copy only p_sz chars
p->str[p_sz]=0;//set the 0 terminating char
return OK;
}
示例4: channel_update
static void channel_update (channel_t *c)
{
DEBUG(" %s %x/%x/%x (%d) %s", c->which, c->status, c->flags, c->events, count_epoll, __FUNCTION__);
ASSERT(!ISLISTED(c));
channel_patch(c);
channel_patch(c->peer);
if (ISSHUT(c) && ISSHUT(c->peer))
return tunnel_release(c->tunnel);
if (ISERR(c))
return tunnel_abort(c->tunnel, "Peer error: %s", c->which);
if (ISERR(c->peer))
return tunnel_abort(c->tunnel, "Peer error: %s", c->which);
uint32_t evt = channel_events(c);
if (c->events & BOTH) {
c->events = evt;
c->flags = SETACT(c->flags) & ~FLAG_ACTIVITY;
PREPEND_STRUCT(ACTIVE_STRUCT_NAME(channel_t),c);
} else
channel_rearm(c, evt);
DEBUG(" %s %x/%x/%x DONE (%d) %s", c->which, c->status, c->flags, c->events, count_epoll, __FUNCTION__);
channel_update_listed(c->peer);
}
示例5: dir_parse
//XXX:carefull, the dentry type is not supported by all fs
static void dir_parse(i parent_fd)
{
++depth;
u8 dirents[DIRENTS_BUF_SZ];
while(1){
l r=getdents64(parent_fd,dirents,DIRENTS_BUF_SZ);
if(ISERR(r)){
PERR("ERROR(%ld):getdents error\n",r);
exit(-1);
}
if(!r) break;
l j=0;
while(j<r){
struct dirent64 *d=(struct dirent64*)(dirents+j);
dout(d);
if(d->type==DT_DIR&&!is_current(d->name)&&!is_parent(d->name)){
i dir_fd;
do
dir_fd=(i)openat(parent_fd,d->name,RDONLY|NONBLOCK);
while(dir_fd==-EINTR);
if(ISERR(dir_fd))
PERR("ERROR(%d):unable to open subdir:%s\n",dir_fd,d->name);
else{
dir_parse(dir_fd);
l r1;
do r1=close(dir_fd); while(r1==-EINTR);
}
}
j+=d->rec_len;
}
}
depth--;
}
示例6: dce_mode_program
s8 dce_mode_program(s32 output_name)
{
struct output *o=®istry[output_name].output;
void *sysname=(void*)udev_device_get_sysname(o->d);
//----------------------------------------------------------------------------
//alloc a properly sized double buffered frame buffer
o->fb.align=PAGE_SZ;//align on a cpu memory page
u64 sz=2*(o->current->h*o->current->v*alga_pixel_fmts_sz[o->pixel_fmt]);
o->fb.sz=sz;
ul req=IOWR('d',SI_MEM_ALLOC,o->fb);
l r=ioctl(o->fd,req,(l)&o->fb);
if(ISERR(r)){
PERR("output:%s:dce:unable to allocate proper vram for a frame buffer of"
" size %llu bytes\n",sysname,o->fb.sz);
goto err;
}
LOG("output:%s:dce:double buffered frame buffer of %llu bytes allocated\n",
sysname,sz);
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//program synchronously the video mode
struct si_dce_dp_set dp_set;
dp_set.idx=o->blk_idx;
dp_set.primary=o->fb.gpu_addr;
dp_set.secondary=o->fb.gpu_addr+sz/2;
dp_set.pixel_fmt=o->pixel_fmt;
dp_set.timing=*(o->current);
dp_set.pitch=o->current->h;
req=IOW('d',SI_DCE_DP_SET,dp_set);
r=ioctl(o->fd,req,(l)&dp_set);
if(ISERR(r)){
PERR("output:%s:dce:%ux%[email protected]%u: unable to program\n",sysname,o->current->h,
o->current->v,v_refresh(o->current));
goto err_free_fb;
}
//----------------------------------------------------------------------------
LOG("output:%s:dce:%ux%[email protected]%u:programmed successfully\n",sysname,o->current->h,
o->current->v,v_refresh(o->current));
return LWL_OK;
err_free_fb:
req=IOW('d',SI_MEM_FREE,o->fb.gpu_addr);
r=ioctl(o->fd,req,&o->fb.gpu_addr);
if(ISERR(r))
PERR("output:%s:dce:unable to free frame buffer memory (LEAK!)\n",sysname);
err:
return LWL_ERR;
}
示例7: preclone_spawn
static i preclone_spawn(s16 slot)
{
atomic_u8_set(preclones_states+slot,PRECLONE_BUSY);
i sockets[2];
preclone_ctl_socket(sockets);
l r=clone(SIGCHLD,0,0,0,0);
if(ISERR(r)){
PERR("FATAL:error precloning process slot %d with error %ld\n",slot,r);
return -1;
}
if(r==0) goto preclone_entry_setup;
preclones[slot].sock=sockets[1];
do r=close(sockets[0]); while(r==-EINTR);
preclones[slot].pid=(i)r;
return 0;
preclone_entry_setup:
preclone_slot=slot;
do r=close(sockets[1]); while(r==-EINTR);//close parent unix socket
preclone_parent_sock=sockets[0];
do r=close(0); while(r==-EINTR);//for the connexion socket
do r=close(1); while(r==-EINTR);//for the connexion socket
//keep stderr
do r=close(sigs_fd); while(r==-EINTR);//don't care of parent signal
do r=close(epfd); while(r==-EINTR);//don't use parent epoll
preclone_entry();
return -1;
}
示例8: clone_spawn
static void clone_spawn(void)
{
l r;
if(ps_n<ps_max){
r=clone(SIGCHLD,0,0,0,0);
if(ISERR(r)){
PERR("FATAL:error cloning %ld\n",r);
kill(0,SIGTERM);
exit(-1);
}
if(r==0) goto clone_entry_setup;
++ps_n;
}
return;
clone_entry_setup:
do r=close(0); while(r==-EINTR);//for the connexion socket
do r=close(1); while(r==-EINTR);//for the connexion socket
//keep stderr
do r=close(sigs_fd); while(r==-EINTR);//don't care of parent signal
do r=close(epfd); while(r==-EINTR);//don't use parent epoll
clone_entry();
return;
}
示例9: convert_e2prom_args
int convert_e2prom_args(const char *e2prom_args, unsigned int *device_code,
unsigned int *addr, unsigned int *value)
{
int i=0, err = 0;
int pos[3]={0};
int data[3]={0};
char temp[3];
for(; i<2; i++)
{
pos[i] += 1;
pos[i+1] = find_symble(e2prom_args, pos[i]);
ISERR(pos[i+1], "args format error\n");
get_string_from_string(temp, e2prom_args, pos[i], pos[i+1]-pos[i]);
// BRIGHT_DBG("temp = %s\n", temp);
err = sscanf(temp, "%d", data+i);
// BRIGHT_DBG("data[%d] hex = %x\n", i, data[i]);
}
get_string_from_string(temp, e2prom_args, pos[2]+1, VALUE_BYTES);
// BRIGHT_DBG("temp = %s\n", temp);
err = sscanf(temp, "%x", data+2);
// BRIGHT_DBG("data[%d] hex = %x\n", 2, data[2]);
*device_code = data[0];
*addr = data[1];
*value = data[2];
return 0;
}
示例10: NFA
/*
- complicatedFind - find a match for the main NFA (with complications)
^ static int complicatedFind(struct vars *, struct cnfa *, struct colormap *);
*/
static int
complicatedFind(
struct vars *const v,
struct cnfa *const cnfa,
struct colormap *const cm)
{
struct dfa *s, *d;
chr *cold = NULL; /* silence gcc 4 warning */
int ret;
s = newDFA(v, &v->g->search, cm, &v->dfa1);
NOERR();
d = newDFA(v, cnfa, cm, &v->dfa2);
if (ISERR()) {
assert(d == NULL);
freeDFA(s);
return v->err;
}
ret = complicatedFindLoop(v, cnfa, cm, d, s, &cold);
freeDFA(d);
freeDFA(s);
NOERR();
if (v->g->cflags®_EXPECT) {
assert(v->details != NULL);
if (cold != NULL) {
v->details->rm_extend.rm_so = OFF(cold);
} else {
v->details->rm_extend.rm_so = OFF(v->stop);
}
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
}
return ret;
}
示例11: altdissect
/*
* altdissect - determine alternative subexpression matches (uncomplicated)
*/
static int /* regexec return code */
altdissect(struct vars * v,
struct subre * t,
chr *begin, /* beginning of relevant substring */
chr *end) /* end of same */
{
struct dfa *d;
int i;
assert(t != NULL);
assert(t->op == '|');
for (i = 0; t != NULL; t = t->right, i++)
{
MDEBUG(("trying %dth\n", i));
assert(t->left != NULL && t->left->cnfa.nstates > 0);
d = newdfa(v, &t->left->cnfa, &v->g->cmap, &v->dfa1);
if (ISERR())
return v->err;
if (longest(v, d, begin, end, (int *) NULL) == end)
{
MDEBUG(("success\n"));
freedfa(d);
return dissect(v, t->left, begin, end);
}
freedfa(d);
}
return REG_ASSERT; /* none of them matched?!? */
}
示例12: sigs_setup
static void sigs_setup(void)
{//synchronous treatement of signals with signalfd
//cannot change SIGKILL, neither SIGSTOP
ul mask=(~0);
l r=rt_sigprocmask(SIG_BLOCK,&mask,0,sizeof(mask));
if(ISERR(r)){
PERR("FATAL:error blocking mostly all signals (%ld)\n",r);
exit(-1);
}
mask=SIGBIT(SIGTERM)|SIGBIT(SIGCHLD);
sigs_fd=(i)signalfd4(-1,&mask,sizeof(mask),SFD_NONBLOCK);
if(ISERR(sigs_fd)){
PERR("FATAL:error setting up fd for signals (%d)\n",sigs_fd);
exit(-1);
}
}
示例13: epoll_sigs_setup
static void epoll_sigs_setup(void)
{
epfd=(i)epoll_create1(0);
if(ISERR(epfd)){
PERR("FATAL:unable to create epoll fd (%d)\n",epfd);
exit(-1);
}
struct epoll_event ep_evt;
memset(&ep_evt,0,sizeof(ep_evt));
ep_evt.events=EPOLLET|EPOLLIN;
ep_evt.data.fd=sigs_fd;
l r=epoll_ctl(epfd,EPOLL_CTL_ADD,sigs_fd,&ep_evt);
if(ISERR(r)){
PERR("FATAL:unable to register signal fd to epoll (%ld)\n",r);
exit(-1);
}
}
示例14: matches
/*
- complicatedAlternationDissect - determine alternative subexpression matches (w.
- complications)
^ static int complicatedAlternationDissect(struct vars *, struct subre *, chr *, chr *);
*/
static int /* regexec return code */
complicatedAlternationDissect(
struct vars *const v,
struct subre *t,
chr *const begin, /* beginning of relevant substring */
chr *const end) /* end of same */
{
int er;
#define UNTRIED 0 /* not yet tried at all */
#define TRYING 1 /* top matched, trying submatches */
#define TRIED 2 /* top didn't match or submatches exhausted */
#ifndef COMPILER_DOES_TAILCALL_OPTIMIZATION
if (0) {
doRight:
t = t->right;
}
#endif
if (t == NULL) {
return REG_NOMATCH;
}
assert(t->op == '|');
if (v->mem[t->retry] == TRIED) {
goto doRight;
}
MDEBUG(("cAlt n%d\n", t->retry));
assert(t->left != NULL);
if (v->mem[t->retry] == UNTRIED) {
struct dfa *d = newDFA(v, &t->left->cnfa, &v->g->cmap, DOMALLOC);
if (ISERR()) {
return v->err;
}
if (longest(v, d, begin, end, NULL) != end) {
freeDFA(d);
v->mem[t->retry] = TRIED;
goto doRight;
}
freeDFA(d);
MDEBUG(("cAlt matched\n"));
v->mem[t->retry] = TRYING;
}
er = complicatedDissect(v, t->left, begin, end);
if (er != REG_NOMATCH) {
return er;
}
v->mem[t->retry] = TRIED;
#ifndef COMPILER_DOES_TAILCALL_OPTIMIZATION
goto doRight;
#else
doRight:
return complicatedAlternationDissect(v, t->right, begin, end);
#endif
}
示例15: dce_dpm_on
void dce_dpm_on(struct output *o)
{
void *sysname=(void*)udev_device_get_sysname(o->d);
ul req=IOR('d',SI_DCE_DP_DPM,o->blk_idx);
l r=ioctl(o->fd,req,&o->blk_idx);
if(ISERR(r)) PERR("output:%s:dce:unable to swich dpm to on\n",sysname);
else LOG("output:%s:dce:dpm on successfully\n",sysname);
}