STATIC int
xxreadtoken() {
      register c;

      if (tokpushback) {
	    tokpushback = 0;
	    return lasttoken;
      }
      if (needprompt) {
	    putprompt(ps2val());
	    needprompt = 0;
      }
      startlinno = plinno;
      for (;;) {	/* until token or start of word found */
	    c = pgetc_macro();
	    if (c == ' ' || c == '\t')
		  continue;		/* quick check for white space first */
	    switch (c) {
	    case ' ': case '\t':
		  continue;
	    case '#':
		  while ((c = pgetc()) != '\n' && c != PEOF);
		  pungetc();
		  continue;
	    case '\\':
		  if (pgetc() == '\n') {
			startlinno = ++plinno;
			if (doprompt)
			      putprompt(ps2val());
			continue;
		  }
		  pungetc();
		  goto breakloop;
	    case '\n':
		  plinno++;
		  needprompt = doprompt;
		  RETURN(TNL);
	    case PEOF:
		  RETURN(TEOF);
	    case '&':
		  if (pgetc() == '&')
			RETURN(TAND);
		  pungetc();
		  RETURN(TBACKGND);
	    case '|':
		  if (pgetc() == '|')
			RETURN(TOR);
		  pungetc();
		  RETURN(TPIPE);
	    case ';':
		  if (pgetc() == ';')
			RETURN(TENDCASE);
		  pungetc();
		  RETURN(TSEMI);
	    case '(':
		  RETURN(TLP);
	    case ')':
		  RETURN(TRP);
	    default:
		  goto breakloop;
	    }
      }
breakloop:
      return readtoken1(c, BASESYNTAX, (char *)NULL, 0);
#undef RETURN
}
Exemple #2
0
void sceDisplayGetAccumulatedHcount() {
	// Just do an estimate
	u32 accumHCount = CoreTiming::GetTicks() / (CoreTiming::GetClockFrequencyMHz() * 1000000 / 60 / 272);
	DEBUG_LOG(HLE,"%i=sceDisplayGetAccumulatedHcount()", accumHCount);
	RETURN(accumHCount);
}
Exemple #3
0
static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
			     struct lu_attr *attr,
			     struct dt_allocation_hint *hint,
			     struct dt_object_format *dof, struct thandle *th)
{
	struct osp_thread_info	*osi = osp_env_info(env);
	struct osp_device	*d = lu2osp_dev(dt->do_lu.lo_dev);
	struct osp_object	*o = dt2osp_obj(dt);
	int			rc = 0;
	struct lu_fid		*fid = &osi->osi_fid;
	ENTRY;

	if (o->opo_reserved) {
		/* regular case, fid is assigned holding trunsaction open */
		 osp_object_assign_fid(env, d, o);
	}

	memcpy(fid, lu_object_fid(&dt->do_lu), sizeof(*fid));

	LASSERTF(fid_is_sane(fid), "fid for osp_obj %p is insane"DFID"!\n",
		 osp_obj, PFID(fid));

	if (!o->opo_reserved) {
		/* special case, id was assigned outside of transaction
		 * see comments in osp_declare_attr_set */
		spin_lock(&d->opd_pre_lock);
		osp_update_last_fid(d, fid);
		spin_unlock(&d->opd_pre_lock);
	}

	CDEBUG(D_INODE, "fid for osp_obj %p is "DFID"!\n", osp_obj, PFID(fid));

	/* If the precreate ends, it means it will be ready to rollover to
	 * the new sequence soon, all the creation should be synchronized,
	 * otherwise during replay, the replay fid will be inconsistent with
	 * last_used/create fid */
	if (osp_precreate_end_seq(env, d) && osp_is_fid_client(d))
		th->th_sync = 1;

	/*
	 * it's OK if the import is inactive by this moment - id was created
	 * by OST earlier, we just need to maintain it consistently on the disk
	 * once import is reconnected, OSP will claim this and other objects
	 * used and OST either keep them, if they exist or recreate
	 */

	/* we might have lost precreated objects */
	if (unlikely(d->opd_gap_count) > 0) {
		spin_lock(&d->opd_pre_lock);
		if (d->opd_gap_count > 0) {
			int count = d->opd_gap_count;

			ostid_set_id(&osi->osi_oi,
				     fid_oid(&d->opd_gap_start_fid));
			d->opd_gap_count = 0;
			spin_unlock(&d->opd_pre_lock);

			CDEBUG(D_HA, "Writting gap "DFID"+%d in llog\n",
			       PFID(&d->opd_gap_start_fid), count);
			/* real gap handling is disabled intil ORI-692 will be
			 * fixed, now we only report gaps */
		} else {
			spin_unlock(&d->opd_pre_lock);
		}
	}

	/* new object, the very first ->attr_set()
	 * initializing attributes needs no logging */
	o->opo_new = 1;

	/* Only need update last_used oid file, seq file will only be update
	 * during seq rollover */
	osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off,
			   &d->opd_last_used_fid.f_oid, d->opd_index);

	rc = dt_record_write(env, d->opd_last_used_oid_file, &osi->osi_lb,
			     &osi->osi_off, th);

	CDEBUG(D_HA, "%s: Wrote last used FID: "DFID", index %d: %d\n",
	       d->opd_obd->obd_name, PFID(fid), d->opd_index, rc);

	RETURN(rc);
}
Exemple #4
0
void * dnsprchild(struct clientparam* param) {
 unsigned long ip = 0;
 unsigned char *bbuf;
 unsigned char *buf, *s1, *s2;
 char * host = NULL;
 unsigned char c;
 SASIZETYPE size;
 int res, i;
 int len;
 unsigned type=0;
 unsigned ttl;
 unsigned char addr[16];
#ifdef _WIN32
	unsigned long ul = 1;
#endif


 if(!(bbuf = myalloc(BUFSIZE+2))){
	param->srv->fds.events = POLLIN;
	RETURN (21);
 }
 buf = bbuf+2;
 size = sizeof(param->sincr);
 i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)&param->sincr, &size); 
 size = sizeof(param->sinsl);
 getsockname(param->srv->srvsock, (struct sockaddr *)&param->sincl, &size);
#ifdef _WIN32
	if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
		RETURN(818);
	}
	ioctlsocket(param->clisock, FIONBIO, &ul);
	if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
	if(so._bind(param->clisock,(struct sockaddr *)&param->sincl,sizeof(param->sincl))) {
		RETURN(822);
	}

#else
	param->clisock = param->srv->srvsock;
#endif
 param->srv->fds.events = POLLIN;

 if(i < 0) {
	RETURN(813);
 }
 buf[BUFSIZE - 1] = 0;
 if(i<=13 || i>1000){
	RETURN (814);
 }
 param->operation = DNSRESOLVE;
 if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
 
 if(buf[4]!=0 || buf[5]!=1) RETURN(816);
 for(len = 12; len<i; len+=(c+1)){
	c = buf[len];
	if(!c)break;
	buf[len] = '.';
 }
 if(len > (i-4)) {RETURN(817);}

 host = mystrdup((char *)buf+13);
 if(!host) {RETURN(21);}

 for(s2 = buf + 12; (s1 = (unsigned char *)strchr((char *)s2 + 1, '.')); s2 = s1)*s2 = (unsigned char)((s1 - s2) - 1); 
 *s2 = (len - (int)(s2 - buf)) - 1;

 type = ((unsigned)buf[len+1])*256 + (unsigned)buf[len+2];
 if((type==0x01 || type==0x1c) && !param->srv->singlepacket){
 	ip = udpresolve((type==0x1c)?AF_INET6:AF_INET, (unsigned char *)host, addr, &ttl, param, 0);
 }

 len+=5;

 if(ip){
	buf[2] = 0x85;
	buf[3] = 0x80;
	buf[6] = 0;
	buf[7] = 1;
	buf[8] = buf[9] = buf[10] = buf[11] = 0;
 	memset(buf+len, 0, 16);
	buf[len] = 0xc0;
	buf[len+1] = 0x0c;
	buf[len+3] = type;
	buf[len+5] = 1;
	ttl = htonl(ttl);
	memcpy(buf + len + 6, &ttl, 4);
	buf[len+11] = type==1? 4:16;
	memcpy(buf+len+12,(void *)&addr,type==1? 4:16);
	len+=(type==1?16:28);
 }
 else if(type == 0x0c) {
	unsigned a, b, c, d;
	sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
	ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
	if(*SAFAMILY(&param->sincl) == AF_INET &&  ip == *(unsigned long*)SAADDR(&param->sincl)){
		buf[2] = 0x85;
		buf[3] = 0x80;
		buf[6] = 0;
		buf[7] = 1;
		buf[8] = buf[9] = buf[10] = buf[11] = 0;
	 	memset(buf+len, 0, 20);
		buf[len] = 0xc0;
		buf[len+1] = 0x0c;
		buf[len+3] = 0x0c;
		buf[len+5] = 1;
		ttl = htonl(3600);
		memcpy(buf + len + 6, &ttl, 4);
		buf[len+11] = 7;
		buf[len+12] = 6;
		memcpy(buf+len+13,(void *)"3proxy",6);
		len+=20;
	}
	else ip = 0;
 }
 if(!ip && numservers){
	if((param->remsock=so._socket(SASOCK(&nservers[0].addr), nservers[0].usetcp? SOCK_STREAM:SOCK_DGRAM, nservers[0].usetcp?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {
		RETURN(818);
	}
	memset(&param->sinsl, 0, sizeof(param->sinsl));
	*SAFAMILY(&param->sinsl) = *SAFAMILY(&nservers[0].addr);
	if(so._bind(param->remsock,(struct sockaddr *)&param->sinsl,sizeof(param->sinsl))) {
		RETURN(819);
	}
	memcpy(&param->sinsr, &nservers[0].addr, sizeof(param->sinsr));
	if(nservers[0].usetcp) {
		if(so._connect(param->remsock,(struct sockaddr *)&param->sinsr,sizeof(param->sinsr))) RETURN(830);
		buf-=2;
		*(unsigned short*)buf = htons(i);
		i+=2;
	}
	else {
#ifdef _WIN32
/*		ioctlsocket(param->remsock, FIONBIO, &ul); */
#else
/*		fcntl(param->remsock,F_SETFL,O_NONBLOCK);  */
#endif
	}

	if(socksendto(param->remsock, (struct sockaddr *)&param->sinsr, buf, i, conf.timeouts[SINGLEBYTE_L]*1000) != i){
		RETURN(820);
	}
	param->statscli64 += i;
	param->nwrites++;
	len = sockrecvfrom(param->remsock, (struct sockaddr *)&param->sinsr, buf, BUFSIZE, 15000);
	if(len <= 13) {
		RETURN(821);
	}
	param->statssrv64 += len;
	param->nreads++;
	if(nservers[0].usetcp) {
		unsigned short us;
		us = ntohs(*(unsigned short *)buf);
		if(us > 4096) RETURN(833);
		buf += 2;
		len -= 2;
		if(len < us) len += sockgetlinebuf(param, SERVER, buf+len, us - len, 0, conf.timeouts[SINGLEBYTE_L]);
		if(len != us) RETURN(832);
	}
	if(buf[6] || buf[7]){
		if(socksendto(param->clisock, (struct sockaddr *)&param->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000) != len){
			RETURN(822);
		}
		RETURN(0);
	}

 }
 if(!ip) {
	buf[2] = 0x85;
	buf[3] = 0x83;
 }
 res = socksendto(param->clisock, (struct sockaddr *)&param->sincr, buf, len, conf.timeouts[SINGLEBYTE_L]*1000); 
 if(res != len){RETURN(819);}
 if(!ip) {RETURN(888);}

CLEANRET:

 if(param->res!=813){
	sprintf((char *)buf, "%04x/%s/", 
			(unsigned)type,
			host?host:"");
	if(ip && type == 0x01 || type == 0x1c){
		myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, buf+strlen(buf), 64);
	}
	(*param->srv->logfunc)(param, buf);
 }
 if(bbuf)myfree(bbuf);
 if(host)myfree(host);
#ifndef _WIN32
 param->clisock = INVALID_SOCKET;
#endif
 freeparam(param);
 return (NULL);
}
Exemple #5
0
void sceDisplayIsVblank() {
	DEBUG_LOG(HLE,"%i=sceDisplayIsVblank()",isVblank);
	RETURN(isVblank);
}
Exemple #6
0
/// qpencode_file()
// Encodes a whole file using the quoted-printable format defined in
// RFC 2045 (page 19)
long qpencode_file(FILE *in, FILE *out)
{
  unsigned char inbuffer[QPENC_BUF+1]; // we read out data in ~4096 byte chunks
  unsigned char outbuffer[QPENC_BUF+5];// the output buffer should not be more than
                                       // the input buffer with an additional space
                                       // for 5 chars which could be used during
                                       // encoding.

  unsigned char *iptr;
  unsigned char *optr = outbuffer;
  unsigned char c;
  int last = -1;
  long encoded_chars = 0;
  int line_len = 0;
  BOOL eof_reached = FALSE;
  size_t read;

  ENTER();

  while(eof_reached == FALSE)
  {
    // read in 4096 byte chunks
    read = fread(inbuffer, 1, QPENC_BUF, in);

    // on a short item count we check for a potential
    // error and return immediatly.
    if(read != QPENC_BUF)
    {
      if(feof(in) != 0)
      {
        D(DBF_MIME, "EOF file at %ld", ftell(in));

        eof_reached = TRUE; // we found an EOF

        // if the last read was zero we can exit immediatly
        if(read == 0)
          break;
      }
      else
      {
        E(DBF_MIME, "error on reading data!");

        // an error occurred, lets return -1
        RETURN(-1);
        return -1;
      }
    }

    // let us now parse through the inbuffer and encode it according
    // to RFC 2045
    iptr = inbuffer;

    while(read)
    {
      // decrease the read number and increase
      // out input buffer pointer
      c = *iptr++;
      read--;

      if(c == '\n')
      {
        // check if the previous char is a linear whitespace and
        // if so we have to put a soft break right before the
        // newline
        if(last != -1 && (last == ' ' || last == '\t'))
        {
          *optr++ = '=';
          *optr++ = '\n';
        }

        *optr++ = '\n';

        // reset the line_len counter
        line_len = 0;
        last = -1;
      }
        // we encode the current char if:
        // 1) it is an unsafe safe
        // 2) it is an upcoming "From " at the start of a line
      else if(!is_qpsafe(c) ||
              (last == -1 && c == 'F' && strncmp((char *)iptr, "rom ", 4) == 0))
      {

        // before we can encode the data we have to check
        // whether there is enough space left on the line
        // or if we have to put it on the next line
        if(line_len+3 >= QP_LINELEN-1) // one space for the trailing '='
        {
          *optr++ = '=';
          *optr++ = '\n';

          // reset the line_len counter
          line_len = 0;
        }

        // now put out the encoded char
        *optr++ = '=';
        *optr++ = basis_hex[(c >> 4) & 0xF];
        *optr++ = basis_hex[c & 0xF];

        // increase the line_len counter
        line_len += 3;

        // count the number of encoded chars
        encoded_chars++;
      }
      else
      {
        // so this char seems to be safe to be directly placed
        // in the output buffer without any encoding. We just
        // have to check whether this line is going to be longer
        // than the limit
        if(line_len+1 >= QP_LINELEN-1) // one space for the trailing '='
        {
          *optr++ = '=';
          *optr++ = '\n';

          // reset the line_len counter
          line_len = 0;
        }

        *optr++ = c;

        // increase the line_len counter
        line_len++;
      }

      // let us now check if our outbuffer is filled up so that we can write
      // out the data to our out stream.
      if(optr-outbuffer >= QPENC_BUF)
      {
        size_t todo = optr-outbuffer;

        // now we do a binary write of the data
        if(fwrite(outbuffer, 1, todo, out) != todo)
        {
          E(DBF_MIME, "error on writing data!");

          // an error must have occurred.
          RETURN(-1);
          return -1;
        }

        // now reset the outbuffer and stuff
        optr = outbuffer;
      }

      last = c;
    }
  }
Exemple #7
0
static int
nodecreate(struct puffs_usermount *pu, struct puffs_node *pn,
	struct puffs_newinfo *pni, const char *name,
	const struct vattr *vap, uint32_t dirbit)
{
	AUTOVAR(pu);
	struct puffs_node *pn_new;
	struct p9pnode *p9n = pn->pn_data;
	p9pfid_t nfid = NEXTFID(p9p);
	struct qid9p nqid;
	int tries = 0;

 again:
	if (++tries > 5) {
		rv = EPROTO;
		goto out;
	}

	rv = proto_cc_dupfid(pu, p9n->fid_base, nfid);
	if (rv)
		goto out;

	p9pbuf_put_1(pb, P9PROTO_T_CREATE);
	p9pbuf_put_2(pb, tag);
	p9pbuf_put_4(pb, nfid);
	p9pbuf_put_str(pb, name);
	p9pbuf_put_4(pb, dirbit | (vap->va_mode & 0777));
	p9pbuf_put_1(pb, 0);
	GETRESPONSE(pb);

	rv = proto_expect_qid(pb, P9PROTO_R_CREATE, &nqid);
	if (rv)
		goto out;

	/*
	 * Now, little problem here: create returns an *open* fid.
	 * So, clunk it and walk the parent directory to get a fid
	 * which is not open for I/O yet.
	 */
	proto_cc_clunkfid(pu, nfid, 0);
	nfid = NEXTFID(p9p);

	p9pbuf_recycleout(pb);
	p9pbuf_put_1(pb, P9PROTO_T_WALK);
	p9pbuf_put_2(pb, tag);
	p9pbuf_put_4(pb, p9n->fid_base);
	p9pbuf_put_4(pb, nfid);
	p9pbuf_put_2(pb, 1);
	p9pbuf_put_str(pb, name);
	GETRESPONSE(pb);

	/*
	 * someone removed it already? try again
	 * note: this is kind of lose/lose
	 */
	if (p9pbuf_get_type(pb) != P9PROTO_R_WALK)
		goto again;

	pn_new = newp9pnode_va(pu, vap, nfid);
	qid2vattr(&pn_new->pn_va, &nqid);
	puffs_newinfo_setcookie(pni, pn_new);

 out:
	RETURN(rv);
}
Exemple #8
0
int
__ddi_create_minor_node(dev_info_t *di, char *name, int spec_type,
                        minor_t minor_num, char *node_type,
		        int flags, struct module *mod)
{
	struct cdev *cdev;
	struct dev_ops *dev_ops;
	struct cb_ops *cb_ops;
	struct file_operations *fops;
	int rc;
	ENTRY;

	ASSERT(spec_type == S_IFCHR);
	ASSERT(minor_num < di->di_minors);
	ASSERT(!strcmp(node_type, DDI_PSEUDO));

	fops = kzalloc(sizeof(struct file_operations), GFP_KERNEL);
	if (fops == NULL)
		RETURN(DDI_FAILURE);

	cdev = cdev_alloc();
	if (cdev == NULL) {
		kfree(fops);
		RETURN(DDI_FAILURE);
	}

	cdev->ops = fops;

	mutex_enter(&di->di_lock);
	dev_ops = di->di_ops;
	ASSERT(dev_ops);
	cb_ops = di->di_ops->devo_cb_ops;
	ASSERT(cb_ops);

	/* Setup the fops to cb_ops mapping */
	fops->owner = mod;
	if (cb_ops->cb_ioctl) {
		fops->ioctl = mod_generic_ioctl;
#ifdef CONFIG_COMPAT
		fops->compat_ioctl = mod_generic_compat_ioctl;
#endif
	}

#if 0
	if (cb_ops->cb_open)
		fops->open = mod_generic_open;

	if (cb_ops->cb_close)
		fops->release = mod_generic_close;

	if (cb_ops->cb_read)
		fops->read = mod_generic_read;

	if (cb_ops->cb_write)
		fops->write = mod_generic_write;
#endif
	/* XXX: Currently unsupported operations */
	ASSERT(cb_ops->cb_open == NULL);
	ASSERT(cb_ops->cb_close == NULL);
	ASSERT(cb_ops->cb_read == NULL);
	ASSERT(cb_ops->cb_write == NULL);
	ASSERT(cb_ops->cb_strategy == NULL);
	ASSERT(cb_ops->cb_print == NULL);
	ASSERT(cb_ops->cb_dump == NULL);
	ASSERT(cb_ops->cb_devmap == NULL);
	ASSERT(cb_ops->cb_mmap == NULL);
	ASSERT(cb_ops->cb_segmap == NULL);
	ASSERT(cb_ops->cb_chpoll == NULL);
	ASSERT(cb_ops->cb_prop_op == NULL);
	ASSERT(cb_ops->cb_str == NULL);
	ASSERT(cb_ops->cb_aread == NULL);
	ASSERT(cb_ops->cb_awrite == NULL);

	snprintf(di->di_name, DDI_MAX_NAME_LEN-1, "/dev/%s", name);
	di->di_cdev  = cdev;
	di->di_flags = flags;
	di->di_minor = minor_num;
	di->di_dev   = MKDEV(di->di_major, di->di_minor);

	rc = cdev_add(cdev, di->di_dev, 1);
	if (rc) {
		CERROR("Error adding cdev, %d\n", rc);
		kfree(fops);
		cdev_del(cdev);
		mutex_exit(&di->di_lock);
		RETURN(DDI_FAILURE);
	}

	spin_lock(&dev_info_lock);
	list_add(&di->di_list, &dev_info_list);
	spin_unlock(&dev_info_lock);

	mutex_exit(&di->di_lock);

	RETURN(DDI_SUCCESS);
}
Exemple #9
0
int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
		     int flags, struct obd_uuid *uuid)
{
	struct llog_log_hdr	*llh;
	int			 rc;

	ENTRY;
	LASSERT(handle->lgh_hdr == NULL);

	OBD_ALLOC_PTR(llh);
	if (llh == NULL)
		RETURN(-ENOMEM);
	handle->lgh_hdr = llh;
	/* first assign flags to use llog_client_ops */
	llh->llh_flags = flags;
	rc = llog_read_header(env, handle, uuid);
	if (rc == 0) {
		if (unlikely((llh->llh_flags & LLOG_F_IS_PLAIN &&
			      flags & LLOG_F_IS_CAT) ||
			     (llh->llh_flags & LLOG_F_IS_CAT &&
			      flags & LLOG_F_IS_PLAIN))) {
			CERROR("%s: llog type is %s but initializing %s\n",
			       handle->lgh_ctxt->loc_obd->obd_name,
			       llh->llh_flags & LLOG_F_IS_CAT ?
			       "catalog" : "plain",
			       flags & LLOG_F_IS_CAT ? "catalog" : "plain");
			GOTO(out, rc = -EINVAL);
		} else if (llh->llh_flags &
			   (LLOG_F_IS_PLAIN | LLOG_F_IS_CAT)) {
			/*
			 * it is possible to open llog without specifying llog
			 * type so it is taken from llh_flags
			 */
			flags = llh->llh_flags;
		} else {
			/* for some reason the llh_flags has no type set */
			CERROR("llog type is not specified!\n");
			GOTO(out, rc = -EINVAL);
		}
		if (unlikely(uuid &&
			     !obd_uuid_equals(uuid, &llh->llh_tgtuuid))) {
			CERROR("%s: llog uuid mismatch: %s/%s\n",
			       handle->lgh_ctxt->loc_obd->obd_name,
			       (char *)uuid->uuid,
			       (char *)llh->llh_tgtuuid.uuid);
			GOTO(out, rc = -EEXIST);
		}
	}
	if (flags & LLOG_F_IS_CAT) {
		LASSERT(cfs_list_empty(&handle->u.chd.chd_head));
		CFS_INIT_LIST_HEAD(&handle->u.chd.chd_head);
		llh->llh_size = sizeof(struct llog_logid_rec);
	} else if (!(flags & LLOG_F_IS_PLAIN)) {
		CERROR("%s: unknown flags: %#x (expected %#x or %#x)\n",
		       handle->lgh_ctxt->loc_obd->obd_name,
		       flags, LLOG_F_IS_CAT, LLOG_F_IS_PLAIN);
		rc = -EINVAL;
	}
out:
	if (rc) {
		OBD_FREE_PTR(llh);
		handle->lgh_hdr = NULL;
	}
	RETURN(rc);
}
Exemple #10
0
int
gas_parser_lex(YYSTYPE *lvalp, yasm_parser_gas *parser_gas)
{
    yasm_scanner *s = &parser_gas->s;
    YYCTYPE *cursor = s->cur;
    size_t count;
    YYCTYPE savech;

    /* Handle one token of lookahead */
    if (parser_gas->peek_token != NONE) {
        int tok = parser_gas->peek_token;
        *lvalp = parser_gas->peek_tokval;  /* structure copy */
        parser_gas->tokch = parser_gas->peek_tokch;
        parser_gas->peek_token = NONE;
        return tok;
    }

    /* Catch EOF */
    if (s->eof && cursor == s->eof)
        return 0;

    /* Jump to proper "exclusive" states */
    switch (parser_gas->state) {
        case COMMENT:
            goto comment;
        case SECTION_DIRECTIVE:
            goto section_directive;
        case NASM_FILENAME:
            goto nasm_filename;
        default:
            break;
    }

scan:
    SCANINIT();

    {
	static unsigned char yybm[] = {
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   1,   0,   0,   0,   1,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  1,   0,   0,   0,  12,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,  12,   0, 
	254, 254, 126, 126, 126, 126, 126, 126, 
	 94,  94,   0,   0,   0,   0,   0,   0, 
	  8,  78,  78,  78,  78,  78,  78,  14, 
	 14,  14,  14,  14,  14,  14,  14,  14, 
	 14,  14,  14,  14,  14,  14,  14,  14, 
	 14,  14,  14,   0,   0,   0,   0,  12, 
	  0,  78,  78,  78,  78,  78,  78,  14, 
	 14,  14,  14,  14,  14,  14,  14,  14, 
	 14,  14,  14,  14,  14,  14,  14,  14, 
	 14,  14,  14,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	};

#line 258 "gas-token.c"
{
	YYCTYPE yych;
	unsigned int yyaccept;
	goto yy0;
	++YYCURSOR;
yy0:
	if((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
	yych = *YYCURSOR;
	if(yych <= '/'){
		if(yych <= '#'){
			if(yych <= '\r'){
				if(yych <= '\t'){
					if(yych <= '\b')	goto yy30;
					goto yy26;
				} else {
					if(yych <= '\n')	goto yy28;
					if(yych <= '\f')	goto yy30;
					goto yy26;
				}
			} else {
				if(yych <= ' '){
					if(yych <= '\037')	goto yy30;
					goto yy26;
				} else {
					if(yych <= '!')	goto yy17;
					if(yych <= '"')	goto yy11;
					goto yy24;
				}
			}
		} else {
			if(yych <= '*'){
				if(yych <= '%'){
					if(yych <= '$')	goto yy17;
					goto yy22;
				} else {
					if(yych == '\'')	goto yy9;
					goto yy17;
				}
			} else {
				if(yych <= ','){
					if(yych <= '+')	goto yy5;
					goto yy17;
				} else {
					if(yych <= '-')	goto yy5;
					if(yych <= '.')	goto yy7;
					goto yy18;
				}
			}
		}
	} else {
		if(yych <= 'Z'){
			if(yych <= '<'){
				if(yych <= '9'){
					if(yych >= '1')	goto yy4;
					goto yy2;
				} else {
					if(yych <= ':')	goto yy17;
					if(yych <= ';')	goto yy19;
					goto yy13;
				}
			} else {
				if(yych <= '>'){
					if(yych <= '=')	goto yy17;
					goto yy15;
				} else {
					if(yych <= '?')	goto yy30;
					if(yych <= '@')	goto yy17;
					goto yy21;
				}
			}
		} else {
			if(yych <= 'z'){
				if(yych <= '^'){
					if(yych <= ']')	goto yy30;
					goto yy17;
				} else {
					if(yych == '`')	goto yy30;
					goto yy21;
				}
			} else {
				if(yych <= '|'){
					if(yych <= '{')	goto yy30;
					goto yy17;
				} else {
					if(yych == '~')	goto yy17;
					goto yy30;
				}
			}
		}
	}
yy2:	yyaccept = 0;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych <= 'T'){
		if(yych <= 'A'){
			if(yych <= '/'){
				if(yych == '.')	goto yy90;
				goto yy3;
			} else {
				if(yych <= '9')	goto yy90;
				if(yych <= ':')	goto yy81;
				goto yy3;
			}
		} else {
			if(yych <= 'E'){
				if(yych <= 'B')	goto yy85;
				if(yych >= 'D')	goto yy88;
				goto yy3;
			} else {
				if(yych <= 'F')	goto yy86;
				if(yych >= 'T')	goto yy88;
				goto yy3;
			}
		}
	} else {
		if(yych <= 'e'){
			if(yych <= 'a'){
				if(yych == 'X')	goto yy92;
				goto yy3;
			} else {
				if(yych <= 'b')	goto yy85;
				if(yych >= 'd')	goto yy88;
				goto yy3;
			}
		} else {
			if(yych <= 't'){
				if(yych <= 'f')	goto yy86;
				if(yych >= 't')	goto yy88;
				goto yy3;
			} else {
				if(yych == 'x')	goto yy92;
				goto yy3;
			}
		}
	}
yy3:
#line 229 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->intn = yasm_intnum_create_dec(TOK);
            s->tok[TOKLEN] = savech;
            RETURN(INTNUM);
        }
#line 402 "gas-token.c"
yy4:	yych = *++YYCURSOR;
	if(yych <= 'E'){
		if(yych <= ':'){
			if(yych <= '9')	goto yy84;
			goto yy81;
		} else {
			if(yych == 'B')	goto yy77;
			goto yy84;
		}
	} else {
		if(yych <= 'b'){
			if(yych <= 'F')	goto yy79;
			if(yych <= 'a')	goto yy84;
			goto yy77;
		} else {
			if(yych == 'f')	goto yy79;
			goto yy84;
		}
	}
yy5:	yyaccept = 1;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych == '.')	goto yy61;
	if(yych <= '/')	goto yy6;
	if(yych <= '9')	goto yy59;
	goto yy6;
yy6:
#line 303 "./modules/parsers/gas/gas-token.re"
{ RETURN(s->tok[0]); }
#line 431 "gas-token.c"
yy7:	yych = *++YYCURSOR;
	if(yybm[0+yych] & 16) {
		goto yy49;
	}
	goto yy37;
yy8:
#line 310 "./modules/parsers/gas/gas-token.re"
{
            lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN);
            lvalp->str.len = TOKLEN;
            RETURN(ID);
        }
#line 444 "gas-token.c"
yy9:	yych = *++YYCURSOR;
	goto yy10;
yy10:
#line 289 "./modules/parsers/gas/gas-token.re"
{
            goto charconst;
        }
#line 452 "gas-token.c"
yy11:	yych = *++YYCURSOR;
	goto yy12;
yy12:
#line 294 "./modules/parsers/gas/gas-token.re"
{
            goto stringconst;
        }
#line 460 "gas-token.c"
yy13:	yych = *++YYCURSOR;
	if(yych == '<')	goto yy47;
	goto yy14;
yy14:
#line 301 "./modules/parsers/gas/gas-token.re"
{ RETURN(LEFT_OP); }
#line 467 "gas-token.c"
yy15:	yych = *++YYCURSOR;
	if(yych == '>')	goto yy45;
	goto yy16;
yy16:
#line 302 "./modules/parsers/gas/gas-token.re"
{ RETURN(RIGHT_OP); }
#line 474 "gas-token.c"
yy17:	yych = *++YYCURSOR;
	goto yy6;
yy18:	yych = *++YYCURSOR;
	if(yych == '*')	goto yy43;
	if(yych == '/')	goto yy41;
	goto yy6;
yy19:	yych = *++YYCURSOR;
	goto yy20;
yy20:
#line 304 "./modules/parsers/gas/gas-token.re"
{
            parser_gas->state = INITIAL;
            RETURN(s->tok[0]);
        }
#line 489 "gas-token.c"
yy21:	yych = *++YYCURSOR;
	goto yy37;
yy22:	yych = *++YYCURSOR;
	if(yybm[0+yych] & 2) {
		goto yy33;
	}
	goto yy23;
yy23:
#line 407 "./modules/parsers/gas/gas-token.re"
{
            yasm_warn_set(YASM_WARN_UNREC_CHAR,
                          N_("ignoring unrecognized character `%s'"),
                          yasm__conv_unprint(s->tok[0]));
            goto scan;
        }
#line 505 "gas-token.c"
yy24:	yych = *++YYCURSOR;
	goto yy25;
yy25:
#line 389 "./modules/parsers/gas/gas-token.re"
{
            if (parser_gas->is_cpp_preproc)
            {
                RETURN(CPP_LINE_MARKER);
            } else
                goto line_comment;
        }
#line 517 "gas-token.c"
yy26:	yych = *++YYCURSOR;
	goto yy32;
yy27:
#line 398 "./modules/parsers/gas/gas-token.re"
{ goto scan; }
#line 523 "gas-token.c"
yy28:	yych = *++YYCURSOR;
	goto yy29;
yy29:
#line 400 "./modules/parsers/gas/gas-token.re"
{
            if (parser_gas->save_input)
                cursor = save_line(parser_gas, cursor);
            parser_gas->state = INITIAL;
            RETURN(s->tok[0]);
        }
#line 534 "gas-token.c"
yy30:	yych = *++YYCURSOR;
	goto yy23;
yy31:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy32;
yy32:	if(yybm[0+yych] & 1) {
		goto yy31;
	}
	goto yy27;
yy33:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy34;
yy34:	if(yybm[0+yych] & 2) {
		goto yy33;
	}
	goto yy35;
yy35:
#line 327 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            if (parser_gas->is_nasm_preproc && strcmp(TOK+1, "line") == 0) {
                s->tok[TOKLEN] = savech;
                RETURN(NASM_LINE_MARKER);
            }

            switch (yasm_arch_parse_check_regtmod
                    (p_object->arch, TOK+1, TOKLEN-1, &lvalp->arch_data)) {
                case YASM_ARCH_REG:
                    s->tok[TOKLEN] = savech;
                    RETURN(REG);
                case YASM_ARCH_REGGROUP:
                    s->tok[TOKLEN] = savech;
                    RETURN(REGGROUP);
                case YASM_ARCH_SEGREG:
                    s->tok[TOKLEN] = savech;
                    RETURN(SEGREG);
                default:
                    break;
            }
            yasm_error_set(YASM_ERROR_GENERAL,
                           N_("Unrecognized register name `%s'"), s->tok);
            s->tok[TOKLEN] = savech;
            lvalp->arch_data = 0;
            RETURN(REG);
        }
#line 583 "gas-token.c"
yy36:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy37;
yy37:	if(yybm[0+yych] & 4) {
		goto yy36;
	}
	if(yych != '@')	goto yy8;
	goto yy38;
yy38:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy39;
yy39:	if(yybm[0+yych] & 8) {
		goto yy38;
	}
	goto yy40;
yy40:
#line 317 "./modules/parsers/gas/gas-token.re"
{
            /* if @ not part of ID, move the scanner cursor to the first @ */
            if (!((yasm_objfmt_base *)p_object->objfmt)->module->id_at_ok)
                cursor = (unsigned char *)strchr(TOK, '@');
            lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN);
            lvalp->str.len = TOKLEN;
            RETURN(ID);
        }
#line 611 "gas-token.c"
yy41:	yych = *++YYCURSOR;
	goto yy42;
yy42:
#line 396 "./modules/parsers/gas/gas-token.re"
{ goto line_comment; }
#line 617 "gas-token.c"
yy43:	yych = *++YYCURSOR;
	goto yy44;
yy44:
#line 388 "./modules/parsers/gas/gas-token.re"
{ parser_gas->state = COMMENT; goto comment; }
#line 623 "gas-token.c"
yy45:	yych = *++YYCURSOR;
	goto yy46;
yy46:
#line 300 "./modules/parsers/gas/gas-token.re"
{ RETURN(RIGHT_OP); }
#line 629 "gas-token.c"
yy47:	yych = *++YYCURSOR;
	goto yy48;
yy48:
#line 299 "./modules/parsers/gas/gas-token.re"
{ RETURN(LEFT_OP); }
#line 635 "gas-token.c"
yy49:	++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
	yych = *YYCURSOR;
	goto yy50;
yy50:	if(yybm[0+yych] & 16) {
		goto yy49;
	}
	if(yych <= 'E'){
		if(yych <= '.'){
			if(yych == '$')	goto yy36;
			if(yych >= '.')	goto yy36;
			goto yy51;
		} else {
			if(yych <= '?')	goto yy51;
			if(yych <= '@')	goto yy38;
			if(yych <= 'D')	goto yy36;
			goto yy52;
		}
	} else {
		if(yych <= '`'){
			if(yych <= 'Z')	goto yy36;
			if(yych == '_')	goto yy36;
			goto yy51;
		} else {
			if(yych == 'e')	goto yy52;
			if(yych <= 'z')	goto yy36;
			goto yy51;
		}
	}
yy51:
#line 266 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->flt = yasm_floatnum_create(TOK);
            s->tok[TOKLEN] = savech;
            RETURN(FLTNUM);
        }
#line 674 "gas-token.c"
yy52:	yyaccept = 2;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych <= ','){
		if(yych == '+')	goto yy55;
		goto yy37;
	} else {
		if(yych <= '-')	goto yy55;
		if(yych <= '/')	goto yy37;
		if(yych >= ':')	goto yy37;
		goto yy53;
	}
yy53:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy54;
yy54:	if(yych <= '?'){
		if(yych <= '-'){
			if(yych == '$')	goto yy36;
			goto yy51;
		} else {
			if(yych <= '.')	goto yy36;
			if(yych <= '/')	goto yy51;
			if(yych <= '9')	goto yy53;
			goto yy51;
		}
	} else {
		if(yych <= '^'){
			if(yych <= '@')	goto yy38;
			if(yych <= 'Z')	goto yy36;
			goto yy51;
		} else {
			if(yych == '`')	goto yy51;
			if(yych <= 'z')	goto yy36;
			goto yy51;
		}
	}
yy55:	yych = *++YYCURSOR;
	if(yych <= '/')	goto yy56;
	if(yych <= '9')	goto yy57;
	goto yy56;
yy56:	YYCURSOR = YYMARKER;
	switch(yyaccept){
	case 0:	goto yy3;
	case 6:	goto yy91;
	case 3:	goto yy51;
	case 4:	goto yy66;
	case 5:	goto yy87;
	case 1:	goto yy6;
	case 2:	goto yy8;
	}
yy57:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy58;
yy58:	if(yych <= '/')	goto yy51;
	if(yych <= '9')	goto yy57;
	goto yy51;
yy59:	++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
	yych = *YYCURSOR;
	goto yy60;
yy60:	if(yych == '.')	goto yy65;
	if(yych <= '/')	goto yy56;
	if(yych <= '9')	goto yy59;
	goto yy56;
yy61:	yych = *++YYCURSOR;
	if(yych <= '/')	goto yy56;
	if(yych >= ':')	goto yy56;
	goto yy62;
yy62:	yyaccept = 3;
	YYMARKER = ++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
	yych = *YYCURSOR;
	goto yy63;
yy63:	if(yych <= 'D'){
		if(yych <= '/')	goto yy51;
		if(yych <= '9')	goto yy62;
		goto yy51;
	} else {
		if(yych <= 'E')	goto yy64;
		if(yych != 'e')	goto yy51;
		goto yy64;
	}
yy64:	yych = *++YYCURSOR;
	if(yych <= ','){
		if(yych == '+')	goto yy55;
		goto yy56;
	} else {
		if(yych <= '-')	goto yy55;
		if(yych <= '/')	goto yy56;
		if(yych <= '9')	goto yy57;
		goto yy56;
	}
yy65:	yyaccept = 4;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych <= 'D'){
		if(yych <= '/')	goto yy66;
		if(yych <= '9')	goto yy67;
		goto yy66;
	} else {
		if(yych <= 'E')	goto yy69;
		if(yych == 'e')	goto yy69;
		goto yy66;
	}
yy66:
#line 273 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->flt = yasm_floatnum_create(TOK);
            s->tok[TOKLEN] = savech;
            RETURN(FLTNUM);
        }
#line 788 "gas-token.c"
yy67:	yyaccept = 3;
	YYMARKER = ++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
	yych = *YYCURSOR;
	goto yy68;
yy68:	if(yych <= 'D'){
		if(yych <= '/')	goto yy51;
		if(yych <= '9')	goto yy67;
		goto yy51;
	} else {
		if(yych <= 'E')	goto yy73;
		if(yych == 'e')	goto yy73;
		goto yy51;
	}
yy69:	yych = *++YYCURSOR;
	if(yych <= ','){
		if(yych != '+')	goto yy56;
		goto yy70;
	} else {
		if(yych <= '-')	goto yy70;
		if(yych <= '/')	goto yy56;
		if(yych <= '9')	goto yy71;
		goto yy56;
	}
yy70:	yych = *++YYCURSOR;
	if(yych <= '/')	goto yy56;
	if(yych >= ':')	goto yy56;
	goto yy71;
yy71:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy72;
yy72:	if(yych <= '/')	goto yy66;
	if(yych <= '9')	goto yy71;
	goto yy66;
yy73:	yych = *++YYCURSOR;
	if(yych <= ','){
		if(yych != '+')	goto yy56;
		goto yy74;
	} else {
		if(yych <= '-')	goto yy74;
		if(yych <= '/')	goto yy56;
		if(yych <= '9')	goto yy75;
		goto yy56;
	}
yy74:	yych = *++YYCURSOR;
	if(yych <= '/')	goto yy56;
	if(yych >= ':')	goto yy56;
	goto yy75;
yy75:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy76;
yy76:	if(yych <= '/')	goto yy51;
	if(yych <= '9')	goto yy75;
	goto yy51;
yy77:	yych = *++YYCURSOR;
	goto yy78;
yy78:
#line 379 "./modules/parsers/gas/gas-token.re"
{
            /* build local label name */
            lvalp->str.contents = yasm_xmalloc(30);
            lvalp->str.len =
                sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0],
                        parser_gas->local[s->tok[0]-'0']);
            RETURN(ID);
        }
#line 857 "gas-token.c"
yy79:	yych = *++YYCURSOR;
	goto yy80;
yy80:
#line 369 "./modules/parsers/gas/gas-token.re"
{
            /* build local label name */
            lvalp->str.contents = yasm_xmalloc(30);
            lvalp->str.len =
                sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0],
                        parser_gas->local[s->tok[0]-'0']+1);
            RETURN(ID);
        }
#line 870 "gas-token.c"
yy81:	yych = *++YYCURSOR;
	goto yy82;
yy82:
#line 357 "./modules/parsers/gas/gas-token.re"
{
            /* increment label index */
            parser_gas->local[s->tok[0]-'0']++;
            /* build local label name */
            lvalp->str.contents = yasm_xmalloc(30);
            lvalp->str.len =
                sprintf(lvalp->str.contents, "L%c\001%lu", s->tok[0],
                        parser_gas->local[s->tok[0]-'0']);
            RETURN(LABEL);
        }
#line 885 "gas-token.c"
yy83:	++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
	yych = *YYCURSOR;
	goto yy84;
yy84:	if(yych == '.')	goto yy65;
	if(yych <= '/')	goto yy3;
	if(yych <= '9')	goto yy83;
	goto yy3;
yy85:	yych = *++YYCURSOR;
	if(yybm[0+yych] & 128) {
		goto yy104;
	}
	goto yy78;
yy86:	yyaccept = 5;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych == '+')	goto yy96;
	if(yych == '-')	goto yy96;
	goto yy97;
yy87:
#line 280 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->flt = yasm_floatnum_create(TOK+2);
            s->tok[TOKLEN] = savech;
            RETURN(FLTNUM);
        }
#line 913 "gas-token.c"
yy88:	yyaccept = 5;
	yych = *(YYMARKER = ++YYCURSOR);
	if(yych == '+')	goto yy96;
	if(yych == '-')	goto yy96;
	goto yy97;
yy89:	yyaccept = 6;
	YYMARKER = ++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
	yych = *YYCURSOR;
	goto yy90;
yy90:	if(yybm[0+yych] & 32) {
		goto yy89;
	}
	if(yych == '.')	goto yy65;
	if(yych <= '/')	goto yy91;
	if(yych <= '9')	goto yy59;
	goto yy91;
yy91:
#line 247 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->intn = yasm_intnum_create_oct(TOK);
            s->tok[TOKLEN] = savech;
            RETURN(INTNUM);
        }
#line 940 "gas-token.c"
yy92:	yych = *++YYCURSOR;
	if(yybm[0+yych] & 64) {
		goto yy93;
	}
	goto yy56;
yy93:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy94;
yy94:	if(yybm[0+yych] & 64) {
		goto yy93;
	}
	goto yy95;
yy95:
#line 256 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            /* skip 0 and x */
            lvalp->intn = yasm_intnum_create_hex(TOK+2);
            s->tok[TOKLEN] = savech;
            RETURN(INTNUM);
        }
#line 964 "gas-token.c"
yy96:	yyaccept = 5;
	YYMARKER = ++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
	yych = *YYCURSOR;
	goto yy97;
yy97:	if(yych <= '9'){
		if(yych == '.')	goto yy98;
		if(yych <= '/')	goto yy87;
		goto yy96;
	} else {
		if(yych <= 'E'){
			if(yych <= 'D')	goto yy87;
			goto yy100;
		} else {
			if(yych == 'e')	goto yy100;
			goto yy87;
		}
	}
yy98:	yyaccept = 5;
	YYMARKER = ++YYCURSOR;
	if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
	yych = *YYCURSOR;
	goto yy99;
yy99:	if(yych <= 'D'){
		if(yych <= '/')	goto yy87;
		if(yych <= '9')	goto yy98;
		goto yy87;
	} else {
		if(yych <= 'E')	goto yy100;
		if(yych != 'e')	goto yy87;
		goto yy100;
	}
yy100:	yych = *++YYCURSOR;
	if(yych <= ','){
		if(yych != '+')	goto yy56;
		goto yy101;
	} else {
		if(yych <= '-')	goto yy101;
		if(yych <= '/')	goto yy56;
		if(yych <= '9')	goto yy102;
		goto yy56;
	}
yy101:	yych = *++YYCURSOR;
	if(yych <= '/')	goto yy56;
	if(yych >= ':')	goto yy56;
	goto yy102;
yy102:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy103;
yy103:	if(yych <= '/')	goto yy87;
	if(yych <= '9')	goto yy102;
	goto yy87;
yy104:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy105;
yy105:	if(yybm[0+yych] & 128) {
		goto yy104;
	}
	goto yy106;
yy106:
#line 238 "./modules/parsers/gas/gas-token.re"
{
            savech = s->tok[TOKLEN];
            s->tok[TOKLEN] = '\0';
            lvalp->intn = yasm_intnum_create_bin(TOK+2);
            s->tok[TOKLEN] = savech;
            RETURN(INTNUM);
        }
#line 1035 "gas-token.c"
}
}
#line 413 "./modules/parsers/gas/gas-token.re"


    /* C-style comment; nesting not supported */
comment:
    SCANINIT();

    {

#line 1047 "gas-token.c"
{
	YYCTYPE yych;
	goto yy107;
	++YYCURSOR;
yy107:
	if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
	if(yych == '\n')	goto yy111;
	if(yych != '*')	goto yy113;
	goto yy109;
yy109:	yych = *++YYCURSOR;
	if(yych == '/')	goto yy114;
	goto yy110;
yy110:
#line 429 "./modules/parsers/gas/gas-token.re"
{
            if (cursor == s->eof)
                return 0;
            goto comment;
        }
#line 1068 "gas-token.c"
yy111:	yych = *++YYCURSOR;
	goto yy112;
yy112:
#line 423 "./modules/parsers/gas/gas-token.re"
{
            if (parser_gas->save_input)
                cursor = save_line(parser_gas, cursor);
            RETURN(s->tok[0]);
        }
#line 1078 "gas-token.c"
yy113:	yych = *++YYCURSOR;
	goto yy110;
yy114:	yych = *++YYCURSOR;
	goto yy115;
yy115:
#line 421 "./modules/parsers/gas/gas-token.re"
{ parser_gas->state = INITIAL; goto scan; }
#line 1086 "gas-token.c"
}
}
#line 434 "./modules/parsers/gas/gas-token.re"


    /* Single line comment. */
line_comment:
    {
	static unsigned char yybm[] = {
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128,   0, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	};

#line 1130 "gas-token.c"
{
	YYCTYPE yych;
	goto yy116;
yy117:	++YYCURSOR;
yy116:
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy118;
yy118:	if(yybm[0+yych] & 128) {
		goto yy117;
	}
	goto yy119;
yy119:
#line 439 "./modules/parsers/gas/gas-token.re"
{ goto scan; }
#line 1146 "gas-token.c"
}
}
#line 440 "./modules/parsers/gas/gas-token.re"


    /* .section directive (the section name portion thereof) */
section_directive:
    SCANINIT();

    {
	static unsigned char yybm[] = {
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,  64,   0,   0,   0,  64,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	 64,   0,   0,   0, 128,   0,   0,   0, 
	  0,   0,   0,   0,   0, 128, 128,   0, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128,   0,   0,   0,   0,   0,   0, 
	  0, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128,   0,   0,   0,   0, 128, 
	  0, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128, 128, 128, 128, 128, 128, 
	128, 128, 128,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	};

#line 1192 "gas-token.c"
{
	YYCTYPE yych;
	goto yy120;
	++YYCURSOR;
yy120:
	if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
	if(yych <= '$'){
		if(yych <= '\r'){
			if(yych <= '\t'){
				if(yych <= '\b')	goto yy132;
				goto yy126;
			} else {
				if(yych <= '\n')	goto yy130;
				if(yych <= '\f')	goto yy132;
				goto yy126;
			}
		} else {
			if(yych <= '!'){
				if(yych == ' ')	goto yy126;
				goto yy132;
			} else {
				if(yych <= '"')	goto yy124;
				if(yych <= '#')	goto yy132;
				goto yy122;
			}
		}
	} else {
		if(yych <= '@'){
			if(yych <= '.'){
				if(yych <= '+')	goto yy132;
				if(yych <= ',')	goto yy128;
				goto yy122;
			} else {
				if(yych <= '/')	goto yy132;
				if(yych >= ':')	goto yy132;
				goto yy122;
			}
		} else {
			if(yych <= '_'){
				if(yych <= 'Z')	goto yy122;
				if(yych <= '^')	goto yy132;
				goto yy122;
			} else {
				if(yych <= '`')	goto yy132;
				if(yych >= '{')	goto yy132;
				goto yy122;
			}
		}
	}
yy122:	yych = *++YYCURSOR;
	goto yy137;
yy123:
#line 447 "./modules/parsers/gas/gas-token.re"
{
            lvalp->str.contents = yasm__xstrndup(TOK, TOKLEN);
            lvalp->str.len = TOKLEN;
            parser_gas->state = INITIAL;
            RETURN(ID);
        }
#line 1253 "gas-token.c"
yy124:	yych = *++YYCURSOR;
	goto yy125;
yy125:
#line 454 "./modules/parsers/gas/gas-token.re"
{ goto stringconst; }
#line 1259 "gas-token.c"
yy126:	yych = *++YYCURSOR;
	goto yy135;
yy127:
#line 456 "./modules/parsers/gas/gas-token.re"
{ goto section_directive; }
#line 1265 "gas-token.c"
yy128:	yych = *++YYCURSOR;
	goto yy129;
yy129:
#line 458 "./modules/parsers/gas/gas-token.re"
{
            parser_gas->state = INITIAL;
            RETURN(s->tok[0]);
        }
#line 1274 "gas-token.c"
yy130:	yych = *++YYCURSOR;
	goto yy131;
yy131:
#line 463 "./modules/parsers/gas/gas-token.re"
{
            if (parser_gas->save_input)
                cursor = save_line(parser_gas, cursor);
            parser_gas->state = INITIAL;
            RETURN(s->tok[0]);
        }
#line 1285 "gas-token.c"
yy132:	yych = *++YYCURSOR;
	goto yy133;
yy133:
#line 470 "./modules/parsers/gas/gas-token.re"
{
            yasm_warn_set(YASM_WARN_UNREC_CHAR,
                          N_("ignoring unrecognized character `%s'"),
                          yasm__conv_unprint(s->tok[0]));
            goto section_directive;
        }
#line 1296 "gas-token.c"
yy134:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy135;
yy135:	if(yybm[0+yych] & 64) {
		goto yy134;
	}
	goto yy127;
yy136:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy137;
yy137:	if(yybm[0+yych] & 128) {
		goto yy136;
	}
	goto yy123;
}
}
#line 476 "./modules/parsers/gas/gas-token.re"


    /* filename portion of nasm preproc %line */
nasm_filename:
    strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
    strbuf_size = STRBUF_ALLOC_SIZE;
    count = 0;

nasm_filename_scan:
    SCANINIT();

    {
	static unsigned char yybm[] = {
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0, 128,   0,   0,   0, 128,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	128,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	  0,   0,   0,   0,   0,   0,   0,   0, 
	};

#line 1363 "gas-token.c"
{
	YYCTYPE yych;
	goto yy138;
	++YYCURSOR;
yy138:
	if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
	if(yych <= '\f'){
		if(yych <= '\b')	goto yy144;
		if(yych <= '\t')	goto yy142;
		if(yych >= '\v')	goto yy144;
		goto yy140;
	} else {
		if(yych <= '\r')	goto yy142;
		if(yych == ' ')	goto yy142;
		goto yy144;
	}
yy140:	yych = *++YYCURSOR;
	goto yy141;
yy141:
#line 488 "./modules/parsers/gas/gas-token.re"
{
            strbuf_append(count++, cursor, s, '\0');
            lvalp->str.contents = (char *)strbuf;
            lvalp->str.len = count;
            parser_gas->state = INITIAL;
            RETURN(STRING);
        }
#line 1392 "gas-token.c"
yy142:	yych = *++YYCURSOR;
	goto yy147;
yy143:
#line 496 "./modules/parsers/gas/gas-token.re"
{ goto nasm_filename_scan; }
#line 1398 "gas-token.c"
yy144:	yych = *++YYCURSOR;
	goto yy145;
yy145:
#line 498 "./modules/parsers/gas/gas-token.re"
{
            if (cursor == s->eof) {
                strbuf_append(count++, cursor, s, '\0');
                lvalp->str.contents = (char *)strbuf;
                lvalp->str.len = count;
                parser_gas->state = INITIAL;
                RETURN(STRING);
            }
            strbuf_append(count++, cursor, s, s->tok[0]);
            goto nasm_filename_scan;
        }
#line 1414 "gas-token.c"
yy146:	++YYCURSOR;
	if(YYLIMIT == YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
	goto yy147;
yy147:	if(yybm[0+yych] & 128) {
		goto yy146;
	}
	goto yy143;
}
}
#line 509 "./modules/parsers/gas/gas-token.re"


    /* character constant values */
charconst:
    /*TODO*/

    /* string constant values */
stringconst:
    strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);
    strbuf_size = STRBUF_ALLOC_SIZE;
    count = 0;

stringconst_scan:
    SCANINIT();

    {

#line 1443 "gas-token.c"
{
	YYCTYPE yych;
	goto yy148;
	++YYCURSOR;
yy148:
	if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
	yych = *YYCURSOR;
	if(yych == '"')	goto yy152;
	if(yych != '\\')	goto yy154;
	goto yy150;
yy150:	yych = *++YYCURSOR;
	if(yych != '\n')	goto yy155;
	goto yy151;
yy151:
#line 547 "./modules/parsers/gas/gas-token.re"
{
            if (cursor == s->eof) {
                yasm_error_set(YASM_ERROR_SYNTAX,
                               N_("unexpected end of file in string"));
                lvalp->str.contents = (char *)strbuf;
                lvalp->str.len = count;
                RETURN(STRING);
            }
            strbuf_append(count++, cursor, s, s->tok[0]);
            goto stringconst_scan;
        }
#line 1470 "gas-token.c"
yy152:	yych = *++YYCURSOR;
	goto yy153;
yy153:
#line 539 "./modules/parsers/gas/gas-token.re"
{
            strbuf_append(count, cursor, s, '\0');
            yasm_unescape_cstring(strbuf, &count);
            lvalp->str.contents = (char *)strbuf;
            lvalp->str.len = count;
            RETURN(STRING);
        }
#line 1482 "gas-token.c"
yy154:	yych = *++YYCURSOR;
	goto yy151;
yy155:	yych = *++YYCURSOR;
	goto yy156;
yy156:
#line 526 "./modules/parsers/gas/gas-token.re"
{
            if (cursor == s->eof) {
                yasm_error_set(YASM_ERROR_SYNTAX,
                               N_("unexpected end of file in string"));
                lvalp->str.contents = (char *)strbuf;
                lvalp->str.len = count;
                RETURN(STRING);
            }
            strbuf_append(count++, cursor, s, '\\');
            strbuf_append(count++, cursor, s, s->tok[1]);
            goto stringconst_scan;
        }
#line 1501 "gas-token.c"
}
}
#line 558 "./modules/parsers/gas/gas-token.re"

}
Exemple #11
0
int
ddi_quiesce_not_needed(dev_info_t *dip)
{
	RETURN(DDI_SUCCESS);
}
Exemple #12
0
static int seq_client_rpc(struct lu_client_seq *seq,
                          struct lu_seq_range *output, __u32 opc,
                          const char *opcname)
{
        struct obd_export     *exp = seq->lcs_exp;
        struct ptlrpc_request *req;
        struct lu_seq_range   *out, *in;
        __u32                 *op;
        int                    rc;
        ENTRY;

        req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY,
                                        LUSTRE_MDS_VERSION, SEQ_QUERY);
        if (req == NULL)
                RETURN(-ENOMEM);

        /* Init operation code */
        op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC);
        *op = opc;

        /* Zero out input range, this is not recovery yet. */
        in = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_RANGE);
        range_init(in);

        ptlrpc_request_set_replen(req);

       if (seq->lcs_type == LUSTRE_SEQ_METADATA) {
                req->rq_request_portal = SEQ_METADATA_PORTAL;
                in->lsr_flags = LU_SEQ_RANGE_MDT;
        } else {
                LASSERTF(seq->lcs_type == LUSTRE_SEQ_DATA,
                         "unknown lcs_type %u\n", seq->lcs_type);
                req->rq_request_portal = SEQ_DATA_PORTAL;
                in->lsr_flags = LU_SEQ_RANGE_OST;
        }

        if (opc == SEQ_ALLOC_SUPER) {
                /* Update index field of *in, it is required for
                 * FLD update on super sequence allocator node. */
                in->lsr_index = seq->lcs_space.lsr_index;
                req->rq_request_portal = SEQ_CONTROLLER_PORTAL;
        } else {
                LASSERTF(opc == SEQ_ALLOC_META,
                         "unknown opcode %u\n, opc", opc);
        }

        ptlrpc_at_set_req_timeout(req);

        mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
        rc = ptlrpc_queue_wait(req);
        mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);

        if (rc)
                GOTO(out_req, rc);

        out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE);
        *output = *out;

        if (!range_is_sane(output)) {
                CERROR("%s: Invalid range received from server: "
                       DRANGE"\n", seq->lcs_name, PRANGE(output));
                GOTO(out_req, rc = -EINVAL);
        }

        if (range_is_exhausted(output)) {
                CERROR("%s: Range received from server is exhausted: "
                       DRANGE"]\n", seq->lcs_name, PRANGE(output));
                GOTO(out_req, rc = -EINVAL);
        }

        CDEBUG(D_INFO, "%s: Allocated %s-sequence "DRANGE"]\n",
               seq->lcs_name, opcname, PRANGE(output));

        EXIT;
out_req:
        ptlrpc_req_finished(req);
        return rc;
}
static mongoc_stream_t *
mongoc_client_connect_tcp (const mongoc_uri_t       *uri,
                           const mongoc_host_list_t *host,
                           bson_error_t             *error)
{
   mongoc_socket_t *sock = NULL;
   struct addrinfo hints;
   struct addrinfo *result, *rp;
   int32_t connecttimeoutms = MONGOC_DEFAULT_CONNECTTIMEOUTMS;
   int64_t expire_at;
   const bson_t *options;
   bson_iter_t iter;
   char portstr [8];
   int s;

   ENTRY;

   bson_return_val_if_fail (uri, NULL);
   bson_return_val_if_fail (host, NULL);

   if ((options = mongoc_uri_get_options (uri)) &&
       bson_iter_init_find_case (&iter, options, "connecttimeoutms") &&
       BSON_ITER_HOLDS_INT32 (&iter)) {
      if (!(connecttimeoutms = bson_iter_int32(&iter))) {
         connecttimeoutms = MONGOC_DEFAULT_CONNECTTIMEOUTMS;
      }
   }

   BSON_ASSERT (connecttimeoutms);
   expire_at = bson_get_monotonic_time () + (connecttimeoutms * 1000L);

   bson_snprintf (portstr, sizeof portstr, "%hu", host->port);

   memset (&hints, 0, sizeof hints);
   hints.ai_family = host->family;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags = 0;
   hints.ai_protocol = 0;

   s = getaddrinfo (host->host, portstr, &hints, &result);

   if (s != 0) {
      mongoc_counter_dns_failure_inc ();
      bson_set_error(error,
                     MONGOC_ERROR_STREAM,
                     MONGOC_ERROR_STREAM_NAME_RESOLUTION,
                     "Failed to resolve %s",
                     host->host);
      RETURN (NULL);
   }

   mongoc_counter_dns_success_inc ();

   for (rp = result; rp; rp = rp->ai_next) {
      /*
       * Create a new non-blocking socket.
       */
      if (!(sock = mongoc_socket_new (rp->ai_family,
                                      rp->ai_socktype,
                                      rp->ai_protocol))) {
         continue;
      }

      /*
       * Try to connect to the peer.
       */
      if (0 != mongoc_socket_connect (sock,
                                      rp->ai_addr,
                                      (socklen_t)rp->ai_addrlen,
                                      expire_at)) {
         char *errmsg;
         char errmsg_buf[BSON_ERROR_BUFFER_SIZE];
         char ip[255];

         mongoc_socket_inet_ntop (rp, ip, sizeof ip);
         errmsg = bson_strerror_r (
            mongoc_socket_errno (sock), errmsg_buf, sizeof errmsg_buf);
         MONGOC_WARNING ("Failed to connect to: %s:%d, error: %d, %s\n",
                         ip,
                         host->port,
                         mongoc_socket_errno(sock),
                         errmsg);
         mongoc_socket_destroy (sock);
         sock = NULL;
         continue;
      }

      break;
   }

   if (!sock) {
      bson_set_error (error,
                      MONGOC_ERROR_STREAM,
                      MONGOC_ERROR_STREAM_CONNECT,
                      "Failed to connect to target host: %s",
                      host->host_and_port);
      freeaddrinfo (result);
      RETURN (NULL);
   }

   freeaddrinfo (result);

   return mongoc_stream_socket_new (sock);
}
bool
_mongoc_client_recv_gle (mongoc_client_t  *client,
                         uint32_t          hint,
                         bson_t          **gle_doc,
                         bson_error_t     *error)
{
   mongoc_buffer_t buffer;
   mongoc_rpc_t rpc;
   bson_iter_t iter;
   bool ret = false;
   bson_t b;

   ENTRY;

   bson_return_val_if_fail (client, false);
   bson_return_val_if_fail (hint, false);

   if (gle_doc) {
      *gle_doc = NULL;
   }

   _mongoc_buffer_init (&buffer, NULL, 0, NULL, NULL);

   if (!_mongoc_cluster_try_recv (&client->cluster, &rpc, &buffer,
                                  hint, error)) {
      GOTO (cleanup);
   }

   if (rpc.header.opcode != MONGOC_OPCODE_REPLY) {
      bson_set_error (error,
                      MONGOC_ERROR_PROTOCOL,
                      MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
                      "Received message other than OP_REPLY.");
      GOTO (cleanup);
   }

   if (_mongoc_rpc_reply_get_first (&rpc.reply, &b)) {
      if (gle_doc) {
         *gle_doc = bson_copy (&b);
      }

      if ((rpc.reply.flags & MONGOC_REPLY_QUERY_FAILURE)) {
         _bson_to_error (&b, error);
         bson_destroy (&b);
         GOTO (cleanup);
      }

      if (!bson_iter_init_find (&iter, &b, "ok") ||
          BSON_ITER_HOLDS_DOUBLE (&iter)) {
        if (bson_iter_double (&iter) == 0.0) {
          _bson_to_error (&b, error);
        }
      }

      bson_destroy (&b);
   }

   ret = true;

cleanup:
   _mongoc_buffer_destroy (&buffer);

   RETURN (ret);
}
Exemple #15
0
static int mdt_ck_thread_main(void *args)
{
        struct mdt_device      *mdt = args;
        struct ptlrpc_thread   *thread = &mdt->mdt_ck_thread;
        struct lustre_capa_key *bkey = &mdt->mdt_capa_keys[0],
                               *rkey = &mdt->mdt_capa_keys[1];
        struct lustre_capa_key *tmp;
        struct lu_env           env;
        struct mdt_thread_info *info;
        struct md_device       *next;
        struct l_wait_info      lwi = { 0 };
        mdsno_t                 mdsnum;
        int                     rc;
        ENTRY;

        cfs_daemonize_ctxt("mdt_ck");
        cfs_block_allsigs();

        thread_set_flags(thread, SVC_RUNNING);
        cfs_waitq_signal(&thread->t_ctl_waitq);

        rc = lu_env_init(&env, LCT_MD_THREAD|LCT_REMEMBER|LCT_NOREF);
        if (rc)
                RETURN(rc);

        thread->t_env = &env;
        env.le_ctx.lc_thread = thread;
        env.le_ctx.lc_cookie = 0x1;

        info = lu_context_key_get(&env.le_ctx, &mdt_thread_key);
        LASSERT(info != NULL);

        tmp = &info->mti_capa_key;
        mdsnum = mdt_md_site(mdt)->ms_node_id;
        while (1) {
                l_wait_event(thread->t_ctl_waitq,
                             thread_is_stopping(thread) ||
                             thread_is_event(thread),
                             &lwi);

                if (thread_is_stopping(thread))
                        break;
                thread_clear_flags(thread, SVC_EVENT);

                if (cfs_time_before(cfs_time_current(), mdt->mdt_ck_expiry))
                        break;

                *tmp = *rkey;
                make_capa_key(tmp, mdsnum, rkey->lk_keyid);

                next = mdt->mdt_child;
                rc = next->md_ops->mdo_update_capa_key(&env, next, tmp);
                if (!rc) {
                        cfs_spin_lock(&capa_lock);
                        *bkey = *rkey;
                        *rkey = *tmp;
                        cfs_spin_unlock(&capa_lock);

                        rc = write_capa_keys(&env, mdt, mdt->mdt_capa_keys);
                        if (rc) {
                                cfs_spin_lock(&capa_lock);
                                *rkey = *bkey;
                                memset(bkey, 0, sizeof(*bkey));
                                cfs_spin_unlock(&capa_lock);
                        } else {
                                set_capa_key_expiry(mdt);
                                DEBUG_CAPA_KEY(D_SEC, rkey, "new");
                        }
                }
                if (rc) {
                        DEBUG_CAPA_KEY(D_ERROR, rkey, "update failed for");
                        /* next retry is in 300 sec */
                        mdt->mdt_ck_expiry = jiffies + 300 * CFS_HZ;
                }

                cfs_timer_arm(&mdt->mdt_ck_timer, mdt->mdt_ck_expiry);
                CDEBUG(D_SEC, "mdt_ck_timer %lu\n", mdt->mdt_ck_expiry);
        }
        lu_env_fini(&env);

        thread_set_flags(thread, SVC_STOPPED);
        cfs_waitq_signal(&thread->t_ctl_waitq);
        RETURN(0);
}
Exemple #16
0
static int llog_process_thread(void *arg)
{
	struct llog_process_info	*lpi = arg;
	struct llog_handle		*loghandle = lpi->lpi_loghandle;
	struct llog_log_hdr		*llh = loghandle->lgh_hdr;
	struct llog_process_cat_data	*cd  = lpi->lpi_catdata;
	char				*buf;
	__u64				 cur_offset = LLOG_CHUNK_SIZE;
	__u64				 last_offset;
	int				 rc = 0, index = 1, last_index;
	int				 saved_index = 0;
	int				 last_called_index = 0;

	ENTRY;

        LASSERT(llh);

        OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
        if (!buf) {
                lpi->lpi_rc = -ENOMEM;
		RETURN(0);
        }

        if (cd != NULL) {
                last_called_index = cd->lpcd_first_idx;
                index = cd->lpcd_first_idx + 1;
        }
        if (cd != NULL && cd->lpcd_last_idx)
                last_index = cd->lpcd_last_idx;
        else
                last_index = LLOG_BITMAP_BYTES * 8 - 1;

        while (rc == 0) {
                struct llog_rec_hdr *rec;

                /* skip records not set in bitmap */
                while (index <= last_index &&
                       !ext2_test_bit(index, llh->llh_bitmap))
                        ++index;

                LASSERT(index <= last_index + 1);
                if (index == last_index + 1)
                        break;
repeat:
                CDEBUG(D_OTHER, "index: %d last_index %d\n",
                       index, last_index);

                /* get the buf with our target record; avoid old garbage */
                memset(buf, 0, LLOG_CHUNK_SIZE);
                last_offset = cur_offset;
		rc = llog_next_block(lpi->lpi_env, loghandle, &saved_index,
				     index, &cur_offset, buf, LLOG_CHUNK_SIZE);
                if (rc)
                        GOTO(out, rc);

                /* NB: when rec->lrh_len is accessed it is already swabbed
                 * since it is used at the "end" of the loop and the rec
                 * swabbing is done at the beginning of the loop. */
                for (rec = (struct llog_rec_hdr *)buf;
                     (char *)rec < buf + LLOG_CHUNK_SIZE;
                     rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)){

                        CDEBUG(D_OTHER, "processing rec 0x%p type %#x\n",
                               rec, rec->lrh_type);

                        if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
				lustre_swab_llog_rec(rec);

                        CDEBUG(D_OTHER, "after swabbing, type=%#x idx=%d\n",
                               rec->lrh_type, rec->lrh_index);

			if (rec->lrh_index == 0) {
				/* probably another rec just got added? */
				if (index <= loghandle->lgh_last_idx)
					GOTO(repeat, rc = 0);
				GOTO(out, rc = 0); /* no more records */
			}
			if (rec->lrh_len == 0 ||
			    rec->lrh_len > LLOG_CHUNK_SIZE) {
                                CWARN("invalid length %d in llog record for "
                                      "index %d/%d\n", rec->lrh_len,
                                      rec->lrh_index, index);
                                GOTO(out, rc = -EINVAL);
                        }

                        if (rec->lrh_index < index) {
                                CDEBUG(D_OTHER, "skipping lrh_index %d\n",
                                       rec->lrh_index);
                                continue;
                        }

                        CDEBUG(D_OTHER,
                               "lrh_index: %d lrh_len: %d (%d remains)\n",
                               rec->lrh_index, rec->lrh_len,
                               (int)(buf + LLOG_CHUNK_SIZE - (char *)rec));

                        loghandle->lgh_cur_idx = rec->lrh_index;
                        loghandle->lgh_cur_offset = (char *)rec - (char *)buf +
                                                    last_offset;

                        /* if set, process the callback on this record */
                        if (ext2_test_bit(index, llh->llh_bitmap)) {
				rc = lpi->lpi_cb(lpi->lpi_env, loghandle, rec,
						 lpi->lpi_cbdata);
				last_called_index = index;
				if (rc == LLOG_PROC_BREAK) {
					GOTO(out, rc);
				} else if (rc == LLOG_DEL_RECORD) {
					llog_cancel_rec(lpi->lpi_env,
							loghandle,
							rec->lrh_index);
                                        rc = 0;
                                }
                                if (rc)
                                        GOTO(out, rc);
                        } else {
                                CDEBUG(D_OTHER, "Skipped index %d\n", index);
                        }

                        /* next record, still in buffer? */
                        ++index;
                        if (index > last_index)
                                GOTO(out, rc = 0);
                }
        }

out:
        if (cd != NULL)
                cd->lpcd_last_idx = last_called_index;

	OBD_FREE(buf, LLOG_CHUNK_SIZE);
        lpi->lpi_rc = rc;
        return 0;
}
/*---------------------------------------------------------------------------
|   Facility      :  libnform  
|   Function      :  static int Connect_Fields(FORM *form, FIELD **fields)
|   
|   Description   :  Set association between form and array of fields.
|
|   Return Values :  E_OK            - no error
|                    E_CONNECTED     - a field is already connected
|                    E_BAD_ARGUMENT  - Invalid form pointer or field array
|                    E_SYSTEM_ERROR  - not enough memory
+--------------------------------------------------------------------------*/
static int Connect_Fields(FORM  * form, FIELD ** fields)
{
  int field_cnt, j;
  int page_nr;
  int maximum_row_in_field, maximum_col_in_field;
  _PAGE *pg;
  
  assert(form != 0);

  form->field    = fields;
  form->maxfield = 0;
  form->maxpage  = 0;

  if (!fields)
    RETURN(E_OK);
  
  page_nr = 0;
  /* store formpointer in fields and count pages */
  for(field_cnt=0;fields[field_cnt];field_cnt++)
    {
      if (fields[field_cnt]->form) 
	RETURN(E_CONNECTED);
      if ( field_cnt==0 || 
	  (fields[field_cnt]->status & _NEWPAGE)) 
	page_nr++;
      fields[field_cnt]->form = form;
    }	
  if (field_cnt==0)
    RETURN(E_BAD_ARGUMENT);
  
  /* allocate page structures */
  if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
    {
      form->page = pg;
    }
  else
    RETURN(E_SYSTEM_ERROR);
  
  /* Cycle through fields and calculate page boundaries as well as
     size of the form */
  for(j=0;j<field_cnt;j++)
    {
      if (j==0) 
	pg->pmin = j;
      else
	{
	  if (fields[j]->status & _NEWPAGE)
	    {
	      pg->pmax = j-1;
	      pg++;
	      pg->pmin = j;
	    }
	}
      
      maximum_row_in_field = fields[j]->frow + fields[j]->rows;
      maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
      
      if (form->rows < maximum_row_in_field) 
	form->rows = maximum_row_in_field;
      if (form->cols < maximum_col_in_field) 
	form->cols = maximum_col_in_field;
    }
  
  pg->pmax       = field_cnt-1;
  form->maxfield = field_cnt;
  form->maxpage  = page_nr; 
  
  /* Sort fields on form pages */
  for(page_nr = 0;page_nr < form->maxpage; page_nr++)
    {
      FIELD *fld = (FIELD *)0;
      for(j = form->page[page_nr].pmin;j <= form->page[page_nr].pmax;j++)
	{
	  fields[j]->index = j;
	  fields[j]->page  = page_nr;
	  fld = Insert_Field_By_Position(fields[j],fld);
	}
      form->page[page_nr].smin = fld->index;
      form->page[page_nr].smax = fld->sprev->index;
    }
  RETURN(E_OK);
}
Exemple #18
0
int llog_reverse_process(const struct lu_env *env,
			 struct llog_handle *loghandle, llog_cb_t cb,
			 void *data, void *catdata)
{
        struct llog_log_hdr *llh = loghandle->lgh_hdr;
        struct llog_process_cat_data *cd = catdata;
        void *buf;
        int rc = 0, first_index = 1, index, idx;
        ENTRY;

        OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
        if (!buf)
                RETURN(-ENOMEM);

        if (cd != NULL)
                first_index = cd->lpcd_first_idx + 1;
        if (cd != NULL && cd->lpcd_last_idx)
                index = cd->lpcd_last_idx;
        else
                index = LLOG_BITMAP_BYTES * 8 - 1;

        while (rc == 0) {
                struct llog_rec_hdr *rec;
                struct llog_rec_tail *tail;

                /* skip records not set in bitmap */
                while (index >= first_index &&
                       !ext2_test_bit(index, llh->llh_bitmap))
                        --index;

                LASSERT(index >= first_index - 1);
                if (index == first_index - 1)
                        break;

                /* get the buf with our target record; avoid old garbage */
                memset(buf, 0, LLOG_CHUNK_SIZE);
		rc = llog_prev_block(env, loghandle, index, buf,
				     LLOG_CHUNK_SIZE);
		if (rc)
			GOTO(out, rc);

		rec = buf;
		idx = rec->lrh_index;
		CDEBUG(D_RPCTRACE, "index %u : idx %u\n", index, idx);
                while (idx < index) {
			rec = (void *)rec + rec->lrh_len;
			if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
				lustre_swab_llog_rec(rec);
                        idx ++;
                }
		LASSERT(idx == index);
		tail = (void *)rec + rec->lrh_len - sizeof(*tail);

                /* process records in buffer, starting where we found one */
                while ((void *)tail > buf) {
			if (tail->lrt_index == 0)
				GOTO(out, rc = 0); /* no more records */

                        /* if set, process the callback on this record */
                        if (ext2_test_bit(index, llh->llh_bitmap)) {
				rec = (void *)tail - tail->lrt_len +
				      sizeof(*tail);

				rc = cb(env, loghandle, rec, data);
				if (rc == LLOG_PROC_BREAK) {
					GOTO(out, rc);
				} else if (rc == LLOG_DEL_RECORD) {
					llog_cancel_rec(env, loghandle,
							tail->lrt_index);
					rc = 0;
				}
                                if (rc)
                                        GOTO(out, rc);
                        }

                        /* previous record, still in buffer? */
                        --index;
                        if (index < first_index)
                                GOTO(out, rc = 0);
			tail = (void *)tail - tail->lrt_len;
                }
        }

out:
        if (buf)
                OBD_FREE(buf, LLOG_CHUNK_SIZE);
        RETURN(rc);
}
Exemple #19
0
/*
 * Problem is that 9P doesn't allow seeking into a directory.  So we
 * maintain a list of active fids for any given directory.  They
 * start living at the first read and exist either until the directory
 * is closed or until they reach the end.
 */
int
puffs9p_node_readdir(struct puffs_usermount *pu, void *opc, struct dirent *dent,
	off_t *readoff, size_t *reslen, const struct puffs_cred *pcr,
	int *eofflag, off_t *cookies, size_t *ncookies)
{
	AUTOVAR(pu);
	struct puffs_node *pn = opc;
	struct p9pnode *p9n = pn->pn_data;
	struct vattr va;
	struct dirfid *dfp;
	char *name;
	uint32_t count;
	uint16_t statsize;

	rv = getdfwithoffset(pu, p9n, *readoff, &dfp);
	if (rv)
		goto out;

	tag = NEXTTAG(p9p);
	p9pbuf_put_1(pb, P9PROTO_T_READ);
	p9pbuf_put_2(pb, tag);
	p9pbuf_put_4(pb, dfp->fid);
	p9pbuf_put_8(pb, *readoff);
	p9pbuf_put_4(pb, *reslen); /* XXX */
	GETRESPONSE(pb);

	p9pbuf_get_4(pb, &count);

	/*
	 * if count is 0, assume we at end-of-dir.  dfp is no longer
	 * useful, so nuke it
	 */
	if (count == 0) {
		*eofflag = 1;
		releasedf(pu, dfp);
		goto out;
	}

	while (count > 0) {
		if ((rv = proto_getstat(pb, &va, &name, &statsize))) {
			/*
			 * If there was an error, it's unlikely we'll be
			 * coming back, so just nuke the dfp.  If we do
			 * come back for some strange reason, we'll just
			 * regen it.
			 */
			releasedf(pu, dfp);
			goto out;
		}

		puffs_nextdent(&dent, name, va.va_fileid,
		    puffs_vtype2dt(va.va_type), reslen);

		count -= statsize;
		*readoff += statsize;
		dfp->seekoff += statsize;
		free(name);
	}

	storedf(p9n, dfp);

 out:
	RETURN(rv);
}
Exemple #20
0
/* backup plain llog */
int llog_backup(const struct lu_env *env, struct obd_device *obd,
		struct llog_ctxt *ctxt, struct llog_ctxt *bctxt,
		char *name, char *backup)
{
	struct llog_handle	*llh, *bllh;
	int			 rc;

	ENTRY;

	/* open original log */
	rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
	if (rc < 0) {
		/* the -ENOENT case is also reported to the caller
		 * but silently so it should handle that if needed.
		 */
		if (rc != -ENOENT)
			CERROR("%s: failed to open log %s: rc = %d\n",
			       obd->obd_name, name, rc);
		RETURN(rc);
	}

	rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
	if (rc)
		GOTO(out_close, rc);

	/* Make sure there's no old backup log */
	rc = llog_erase(env, bctxt, NULL, backup);
	if (rc < 0 && rc != -ENOENT)
		GOTO(out_close, rc);

	/* open backup log */
	rc = llog_open_create(env, bctxt, &bllh, NULL, backup);
	if (rc) {
		CERROR("%s: failed to open backup logfile %s: rc = %d\n",
		       obd->obd_name, backup, rc);
		GOTO(out_close, rc);
	}

	/* check that backup llog is not the same object as original one */
	if (llh->lgh_obj == bllh->lgh_obj) {
		CERROR("%s: backup llog %s to itself (%s), objects %p/%p\n",
		       obd->obd_name, name, backup, llh->lgh_obj,
		       bllh->lgh_obj);
		GOTO(out_backup, rc = -EEXIST);
	}

	rc = llog_init_handle(env, bllh, LLOG_F_IS_PLAIN, NULL);
	if (rc)
		GOTO(out_backup, rc);

	/* Copy log record by record */
	rc = llog_process_or_fork(env, llh, llog_copy_handler, (void *)bllh,
				  NULL, false);
	if (rc)
		CERROR("%s: failed to backup log %s: rc = %d\n",
		       obd->obd_name, name, rc);
out_backup:
	llog_close(env, bllh);
out_close:
	llog_close(env, llh);
	RETURN(rc);
}
Exemple #21
0
int
puffs9p_node_lookup(struct puffs_usermount *pu, void *opc, struct puffs_newinfo *pni,
	const struct puffs_cn *pcn)
{
	AUTOVAR(pu);
	struct vattr va;
	struct puffs_node *pn, *pn_dir = opc;
	struct p9pnode *p9n_dir = pn_dir->pn_data;
	p9ptag_t tfid = NEXTFID(p9p);
	struct qid9p newqid;
	uint16_t nqid;

	p9pbuf_put_1(pb, P9PROTO_T_WALK);
	p9pbuf_put_2(pb, tag);
	p9pbuf_put_4(pb, p9n_dir->fid_base);
	p9pbuf_put_4(pb, tfid);
	p9pbuf_put_2(pb, 1);
	p9pbuf_put_str(pb, pcn->pcn_name);
	GETRESPONSE(pb);

	rv = proto_expect_walk_nqids(pb, &nqid);
	if (rv) {
		rv = ENOENT;
		goto out;
	}
	if (nqid != 1) {
		rv = EPROTO;
		goto out;
	}
	if ((rv = proto_getqid(pb, &newqid)))
		goto out;

	/* we get the parent vers in walk(?)  compensate */
	p9pbuf_recycleout(pb);
	tag = NEXTTAG(p9p);
	p9pbuf_put_1(pb, P9PROTO_T_STAT);
	p9pbuf_put_2(pb, tag);
	p9pbuf_put_4(pb, tfid);
	GETRESPONSE(pb);
	if ((rv = proto_expect_stat(pb, &va)) != 0) {
		proto_cc_clunkfid(pu, tfid, 0);
		rv = ENOENT;
		goto out;
	}
	if (newqid.qidpath != va.va_fileid) {
		proto_cc_clunkfid(pu, tfid, 0);
		rv = EPROTO;
		goto out;
	}
	newqid.qidvers = va.va_gen;

	pn = puffs_pn_nodewalk(pu, nodecmp, &newqid);
	if (pn == NULL)
		pn = newp9pnode_qid(pu, &newqid, tfid);
	else
		proto_cc_clunkfid(pu, tfid, 0);
	/* assert pn */
	memcpy(&pn->pn_va, &va, sizeof(va));

	puffs_newinfo_setcookie(pni, pn);
	puffs_newinfo_setvtype(pni, pn->pn_va.va_type);
	puffs_newinfo_setsize(pni, pn->pn_va.va_size);
	puffs_newinfo_setrdev(pni, pn->pn_va.va_rdev);

 out:
	RETURN(rv);
}
Exemple #22
0
static EFT
get_next_format_from_precision(const char** pf) {
    int     sh, lg, quad, longdouble, ptrdifft, sizet;
    const char*  f;
    sh = lg = quad = longdouble = ptrdifft = sizet = 0;
    f = *pf;

    switch (*f) {
    case 'h':
        f++;
        sh = 1;
        break;

    case 'l':
        f++;

        if (!*f) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        if (*f == 'l') {
            f++;
            quad = 1;
        } else {
            lg = 1;
        }

        break;

    case 'q':
        f++;
        quad = 1;
        break;

    case 't':
        f++;
        ptrdifft = 1;
        break;

    case 'z':
        f++;
        sizet = 1;
        break;

    case 'L':
        f++;
        longdouble = 1;
        break;

    default:
        break;
    }

    if (!*f) {
        RETURN(pf, f, FMTCHECK_UNKNOWN);
    }

    if (strchr("diouxX", *f)) {
        if (longdouble) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        if (lg) {
            RETURN(pf, f, FMTCHECK_LONG);
        }

        if (quad) {
            RETURN(pf, f, FMTCHECK_QUAD);
        }

        if (ptrdifft) {
            RETURN(pf, f, FMTCHECK_PTRDIFFT);
        }

        if (sizet) {
            RETURN(pf, f, FMTCHECK_SIZET);
        }

        RETURN(pf, f, FMTCHECK_INT);
    }

    if (*f == 'n') {
        if (longdouble) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        if (sh) {
            RETURN(pf, f, FMTCHECK_SHORTPOINTER);
        }

        if (lg) {
            RETURN(pf, f, FMTCHECK_LONGPOINTER);
        }

        if (quad) {
            RETURN(pf, f, FMTCHECK_QUADPOINTER);
        }

        if (ptrdifft) {
            RETURN(pf, f, FMTCHECK_PTRDIFFTPOINTER);
        }

        if (sizet) {
            RETURN(pf, f, FMTCHECK_SIZETPOINTER);
        }

        RETURN(pf, f, FMTCHECK_INTPOINTER);
    }

    if (strchr("DOU", *f)) {
        if (sh + lg + quad + longdouble + ptrdifft + sizet) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        RETURN(pf, f, FMTCHECK_LONG);
    }

#ifndef NO_FLOATING_POINT

    if (strchr("aAeEfFgG", *f)) {
        if (longdouble) {
            RETURN(pf, f, FMTCHECK_LONGDOUBLE);
        }

        if (sh + lg + quad + ptrdifft + sizet) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        RETURN(pf, f, FMTCHECK_DOUBLE);
    }

#endif

    if (*f == 'c') {
        if (sh + lg + quad + longdouble + ptrdifft + sizet) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        RETURN(pf, f, FMTCHECK_INT);
    }

    if (*f == 's') {
        if (sh + lg + quad + longdouble + ptrdifft + sizet) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        RETURN(pf, f, FMTCHECK_STRING);
    }

    if (*f == 'p') {
        if (sh + lg + quad + longdouble + ptrdifft + sizet) {
            RETURN(pf, f, FMTCHECK_UNKNOWN);
        }

        RETURN(pf, f, FMTCHECK_LONG);
    }

    RETURN(pf, f, FMTCHECK_UNKNOWN);
    /*NOTREACHED*/
}
Exemple #23
0
void sceKernelRegisterDefaultExceptionHandler()
{
	ERROR_LOG(HLE,"UNIMPL sceKernelRegisterDefaultExceptionHandler()");
	RETURN(0);
}
Exemple #24
0
void LALReadNRWave_raw(LALStatus *status,	/**< pointer to LALStatus structure */
		       REAL4TimeVectorSeries **out, /**< [out] output time series for h+ and hx */
		       const CHAR  *filename        /**< [in] File containing numrel waveform */)
{

  UINT4 length, k, r;
  REAL4TimeVectorSeries *ret=NULL;
  REAL4VectorSequence *data=NULL;
  REAL4Vector *timeVec=NULL;
  LALParsedDataFile *cfgdata=NULL;
  REAL4 tmp1, tmp2, tmp3;

  INITSTATUS(status);
  ATTATCHSTATUSPTR (status);

  /* some consistency checks */
  ASSERT (filename != NULL, status, NRWAVEIO_ENULL, NRWAVEIO_MSGENULL );
  ASSERT ( out != NULL, status, NRWAVEIO_ENULL, NRWAVEIO_MSGENULL );
  ASSERT ( *out == NULL, status, NRWAVEIO_ENONULL, NRWAVEIO_MSGENONULL );

  if ( XLALParseDataFile ( &cfgdata, filename) != XLAL_SUCCESS ) {
    ABORT( status, NRWAVEIO_EFILE, NRWAVEIO_MSGEFILE );
  }
  length = cfgdata->lines->nTokens; /*number of data points */


  /* allocate memory */
  ret = LALCalloc(1, sizeof(*ret));
  if (!ret) {
    ABORT( status, NRWAVEIO_ENOMEM, NRWAVEIO_MSGENOMEM );
  }
  strcpy(ret->name,filename);
  ret->f0 = 0;

  data =  XLALCreateREAL4VectorSequence (2, length);
  if (!data) {
    ABORT( status, NRWAVEIO_ENOMEM, NRWAVEIO_MSGENOMEM );
  }

  timeVec = XLALCreateREAL4Vector (length);
  if (!timeVec) {
    ABORT( status, NRWAVEIO_ENOMEM, NRWAVEIO_MSGENOMEM );
  }

  /* now get the data */
  for (k = 0; k < length; k++) {
    r = sscanf(cfgdata->lines->tokens[k], "%f%f%f", &tmp1, &tmp2, &tmp3);

    /* Check the data file format */
    if ( r != 3) {
      /* there must be exactly 3 data entries -- time, h+, hx */
      ABORT( status, NRWAVEIO_EFORMAT, NRWAVEIO_MSGEFORMAT );
    }

    timeVec->data[k] = tmp1;
    data->data[k] = tmp2;
    data->data[data->vectorLength + k] = tmp3;

  }

  /*  scale time */
  ret->deltaT = timeVec->data[1] - timeVec->data[0];

  /* might also want to go through timeVec to make sure it is evenly spaced */


  ret->data = data;
  (*out) = ret;

  XLALDestroyREAL4Vector (timeVec);
  XLALDestroyParsedDataFile ( cfgdata);

  DETATCHSTATUSPTR(status);
  RETURN(status);

} /* LALReadNRWave() */
Exemple #25
0
void sceDisplayGetCurrentHcount() {
	RETURN(hCount++);
}
Exemple #26
0
/** Put the main functionalities of nr_wave.c together */
void
LALAddStrainModes(
  LALStatus              *status,	/**< pointer to LALStatus structure */
  REAL4TimeVectorSeries  **outStrain,   /**< h+, hx data       */
  NRWaveCatalog          *nrCatalog,    /**< NR wave metadata struct        */
  INT4                   modeLlo,      /**< contains modeLlo and modeLhi   */
  INT4                   modeLhi,      /**< modeLhi                        */
  const SimInspiralTable       *thisInj     /**< injection                      */)
{
  INT4 modeL, modeM;
  REAL4TimeVectorSeries *sumStrain=NULL;
  REAL4TimeVectorSeries *tempStrain=NULL;
  NRWaveMetaData thisMetaData;

  INITSTATUS(status);
  ATTATCHSTATUSPTR (status);

  /* loop over l values */
  for ( modeL = modeLlo; modeL <= modeLhi; modeL++ )
    {
      /* loop over m values */
      for ( modeM = -modeL; modeM <= modeL; modeM++ )
        {
          /* find nearest matching numrel waveform */
          XLALFindNRFile( &thisMetaData, nrCatalog, thisInj, modeL, modeM );

          /* read numrel waveform */
          TRY( LALReadNRWave( status->statusPtr, &tempStrain, thisInj->mass1 +
                thisInj->mass2, thisMetaData.filename ), status );

          /* compute the h+ and hx for given inclination and coalescence phase*/
          XLALOrientNRWave( tempStrain, thisMetaData.mode[0],
			    thisMetaData.mode[1], thisInj->inclination, thisInj->coa_phase );

	  if (sumStrain == NULL) {

	    sumStrain = LALCalloc(1, sizeof(*sumStrain));

	    sumStrain->data =  XLALCreateREAL4VectorSequence(2, tempStrain->data->vectorLength);
	    sumStrain->deltaT = tempStrain->deltaT;
	    sumStrain->f0 = tempStrain->f0;
	    sumStrain->sampleUnits = tempStrain->sampleUnits;

	    memset(sumStrain->data->data,0.0,2*tempStrain->data->vectorLength*sizeof(REAL4));

	    sumStrain = XLALSumStrain( sumStrain, tempStrain );
	  }

	  else {
	    sumStrain = XLALSumStrain( sumStrain, tempStrain );
	  }

	  /*fprintf(stdout, "\nInjecting NR waveform from file %s", thisMetaData.filename);*/

          /* clear memory for strain */
          XLALDestroyREAL4VectorSequence ( tempStrain->data );
          LALFree( tempStrain );
          tempStrain = NULL;

        } /* end loop over modeM values */

      } /* end loop over modeL values */

  /*fprintf(stdout, "\nNR injections done\n");*/

  *outStrain = sumStrain;

  DETATCHSTATUSPTR(status);
  RETURN(status);

}
Exemple #27
0
static int osp_declare_object_create(const struct lu_env *env,
				     struct dt_object *dt,
				     struct lu_attr *attr,
				     struct dt_allocation_hint *hint,
				     struct dt_object_format *dof,
				     struct thandle *th)
{
	struct osp_thread_info	*osi = osp_env_info(env);
	struct osp_device	*d = lu2osp_dev(dt->do_lu.lo_dev);
	struct osp_object	*o = dt2osp_obj(dt);
	const struct lu_fid	*fid;
	int			 rc = 0;

	ENTRY;

	/* should happen to non-0 OSP only so that at least one object
	 * has been already declared in the scenario and LOD should
	 * cleanup that */
	if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OSC_CREATE_FAIL) && d->opd_index == 1)
		RETURN(-ENOSPC);

	LASSERT(d->opd_last_used_oid_file);
	fid = lu_object_fid(&dt->do_lu);

	/*
	 * There can be gaps in precreated ids and record to unlink llog
	 * XXX: we do not handle gaps yet, implemented before solution
	 *	was found to be racy, so we disabled that. there is no
	 *	point in making useless but expensive llog declaration.
	 */
	/* rc = osp_sync_declare_add(env, o, MDS_UNLINK64_REC, th); */

	if (unlikely(!fid_is_zero(fid))) {
		/* replay case: caller knows fid */
		osi->osi_off = sizeof(osi->osi_id) * d->opd_index;
		rc = dt_declare_record_write(env, d->opd_last_used_oid_file,
					     sizeof(osi->osi_id), osi->osi_off,
					     th);
		RETURN(rc);
	}

	/*
	 * in declaration we need to reserve object so that we don't block
	 * awaiting precreation RPC to complete
	 */
	rc = osp_precreate_reserve(env, d);
	/*
	 * we also need to declare update to local "last used id" file for
	 * recovery if object isn't used for a reason, we need to release
	 * reservation, this can be made in osd_object_release()
	 */
	if (rc == 0) {
		/* mark id is reserved: in create we don't want to talk
		 * to OST */
		LASSERT(o->opo_reserved == 0);
		o->opo_reserved = 1;

		/* common for all OSPs file hystorically */
		osi->osi_off = sizeof(osi->osi_id) * d->opd_index;
		rc = dt_declare_record_write(env, d->opd_last_used_oid_file,
					     sizeof(osi->osi_id), osi->osi_off,
					     th);
	} else {
		/* not needed in the cache anymore */
		set_bit(LU_OBJECT_HEARD_BANSHEE,
			    &dt->do_lu.lo_header->loh_flags);
	}
	RETURN(rc);
}
Exemple #28
0
void * udppmchild(struct clientparam* param) {
 unsigned char *buf = NULL;
 int res, i;
#ifdef _WIN32
 SASIZETYPE size;
 unsigned long ul = 1;
#endif
 struct udpmap *udpmappings = NULL;
 struct pollfd fds[256];


 if(!param->hostname)parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport));
 if (!param->req.sin_addr.s_addr) {
	param->srv->fds.events = POLLIN;
	RETURN (100);
 }
 if(!param->clibuf && (!(param->clibuf=myalloc(UDPBUFSIZE)) || !(param->clibufsize = UDPBUFSIZE))){
	param->srv->fds.events = POLLIN;
	RETURN (21);
 }
 param->cliinbuf = param->clioffset = 0;
 i = sockrecvfrom(param->srv->srvsock, &param->sinc, param->clibuf, param->clibufsize, 0);
 if(i<=0){
	param->srv->fds.events = POLLIN;
	RETURN (214);
 }
 param->cliinbuf = i;

#ifdef _WIN32
	if((param->clisock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
		RETURN(818);
	}
	if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);};
	ioctlsocket(param->clisock, FIONBIO, &ul);
	size = sizeof(struct sockaddr_in);
	if(so._getsockname(param->srv->srvsock, (struct sockaddr *)&param->sins, &size)) {RETURN(21);};
	if(so._bind(param->clisock,(struct sockaddr *)&param->sins,sizeof(struct sockaddr_in))) {
		RETURN(822);
	}
#else
	param->clisock = param->srv->srvsock;
#endif

 param->sins.sin_family = AF_INET;
 param->sins.sin_port = htons(0);
 param->sins.sin_addr.s_addr = param->extip;
 if ((param->remsock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
 if(so._bind(param->remsock,(struct sockaddr *)&param->sins,sizeof(param->sins))) {RETURN (12);}
#ifdef _WIN32
	ioctlsocket(param->remsock, FIONBIO, &ul);
#else
	fcntl(param->remsock,F_SETFL,O_NONBLOCK);
#endif
 param->sins.sin_addr.s_addr = param->req.sin_addr.s_addr;
 param->sins.sin_port = param->req.sin_port;

 param->operation = UDPASSOC;
 if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
 if(param->srv->singlepacket) {
	param->srv->fds.events = POLLIN;
 }

 param->res = sockmap(param, conf.timeouts[(param->srv->singlepacket)?SINGLEBYTE_L:STRING_L]);
 if(!param->srv->singlepacket) {
	param->srv->fds.events = POLLIN;
 }

CLEANRET:

 if(buf)myfree(buf);
 (*param->srv->logfunc)(param, NULL);
#ifndef _WIN32
 param->clisock = INVALID_SOCKET;
#endif
 freeparam(param);
 return (NULL);
}
Exemple #29
0
QVariant
IssueModel::data( const QModelIndex& index, int role ) const
{
    ENTER()(index)(role);

    if( index.row() < 0 || index.row() >= items_.count() )
        RETURN( QVariant() );

    const Issue& item = items_[index.row()];

    if( role == IdRole )
        RETURN( item.id );
    else if( role == DescriptionRole )
        RETURN( item.description );
    else if( role == DoneRatioRole )
        RETURN( item.doneRatio );
    else if( role == SubjectRole )
        RETURN( item.subject );
    else if( role == AuthorRole )
        RETURN( QVariant::fromValue(item.author) );
    else if( role == CategoryRole )
        RETURN( QVariant::fromValue(item.category) );
    else if( role == PriorityRole )
        RETURN( QVariant::fromValue(item.priority) );
    else if( role == ProjectRole )
        RETURN( QVariant::fromValue(item.project) );
    else if( role == StatusRole )
        RETURN( QVariant::fromValue(item.status) );
    else if( role == TrackerRole )
        RETURN( QVariant::fromValue(item.tracker) );
    else if( role == CreatedOnRole )
        RETURN( item.createdOn );
    else if( role == DueDateRole )
        RETURN( item.dueDate );
    else if( role == EstimatedHoursRole )
        RETURN( item.estimatedHours );
    else if( role == StartDateRole )
        RETURN( item.startDate );
    else if( role == UpdatedOnRole )
        RETURN( item.updatedOn );
    else if( role == CustomFieldsRole )
        RETURN( QVariant::fromValue(item.customFields) );
    else if( role == TextRole )
        RETURN( QString("#%1: %2").arg(QString::number(item.id)).arg(item.subject) );
    else if( role == FindRole )
        RETURN( QString("%1 %2").arg(item.subject).arg(item.description) );
    else
        RETURN( QVariant() );
}
Exemple #30
0
static BOOL ClassInit(UNUSED struct Library *base)
{
  ENTER();

  if((DataTypesBase = OpenLibrary("datatypes.library",37)) &&
     GETINTERFACE(IDataTypes,struct DataTypesIFace *,DataTypesBase) &&
     (IFFParseBase = OpenLibrary("iffparse.library",37)) &&
     GETINTERFACE(IIFFParse,struct IFFParseIFace *,IFFParseBase) &&
     (LocaleBase = (APTR)OpenLibrary("locale.library",36)) &&
     GETINTERFACE(ILocale,struct LocaleIFace *,LocaleBase))
  {
    BOOL success = TRUE;

    // check for MUI 3.9+
    if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 0))
    {
      lib_flags |= BASEFLG_MUI20;

      // check for MUI 4.0+
      if(LIB_VERSION_IS_AT_LEAST(MUIMasterBase, 20, 5500))
        lib_flags |= BASEFLG_MUI4;
    }

    // on MUI 3.1 system's we do have to
    // initialize our subclasses as well
    #if defined(__amigaos3__)
    if(!(lib_flags & BASEFLG_MUI20))
    {
      if(!initColoradjust() ||
         !initPenadjust() ||
         !initBackgroundadjust() ||
         !initPoppen() ||
         !initPopbackground())
      {
        success = FALSE;
      }
    }
    #endif

    if(success == TRUE)
    {
      // open the TheBar_mcp catalog
      OpenCat();

      LocalizeArray(regs,regIDs);
      LocalizeArray(frames,frameIDs);
      LocalizeArray(precisions,precisionIDs);
      LocalizeArray(dismodes,dismodeIDs);
      LocalizeArray(spacersSizes,spacersSizeIDs);
      LocalizeArray(viewModes,viewModeIDs);
      LocalizeArray(labelPoss,labelPosIDs);

      // we open the cybgraphics.library but without failing if
      // it doesn't exist
      #if !defined(__amigaos4__)
      CyberGfxBase = OpenLibrary("cybergraphics.library", 41);
/*
      if(!GETINTERFACE(ICyberGfx, struct CyberGfxIFace *, CyberGfxBase))
      {
        CloseLibrary(CyberGfxBase);
        CyberGfxBase = NULL;
      }
*/
      #endif

      #if !defined(__MORPHOS__)
      {
        struct Library *nbitmapMcc;

        nbitmapCanHandleRawData = FALSE;

        // we need at least NBitmap.mcc V15.8 to be able to let it handle raw image data
        if((nbitmapMcc = OpenLibrary("mui/NBitmap.mcc", 0)) != NULL)
        {
          SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Version);
          SHOWVALUE(DBF_ALWAYS, nbitmapMcc->lib_Revision);

          if(nbitmapMcc->lib_Version > 15 || (nbitmapMcc->lib_Version == 15 && nbitmapMcc->lib_Revision >= 8))
            nbitmapCanHandleRawData = TRUE;

          CloseLibrary(nbitmapMcc);
        }

        SHOWVALUE(DBF_ALWAYS, nbitmapCanHandleRawData);
      }
      #endif

      lib_flags |= BASEFLG_Init;

      RETURN(TRUE);
      return TRUE;
    }
  }

  ClassExpunge(base);

  RETURN(FALSE);
  return FALSE;
}