Ejemplo n.º 1
0
tr_dh_ctx_t
tr_dh_new (const uint8_t * prime_num,
           size_t          prime_num_length,
           const uint8_t * generator_num,
           size_t          generator_num_length)
{
  DH * handle = DH_new ();
  BIGNUM * p, * g;

  assert (prime_num != NULL);
  assert (generator_num != NULL);

  p = BN_bin2bn (prime_num, prime_num_length, NULL);
  g = BN_bin2bn (generator_num, generator_num_length, NULL);

  if (!check_pointer (p) || !check_pointer (g) || !DH_set0_pqg (handle, p, NULL, g))
    {
      BN_free (p);
      BN_free (g);
      DH_free (handle);
      handle = NULL;
    }

  return handle;
}
Ejemplo n.º 2
0
struct bufferedTags *allocateNewBufferedTag (void)
{
  struct bufferedTags *newS			= (struct bufferedTags*)malloc (sizeof (struct bufferedTags));
  check_pointer (allocateNewBufferedTag);
  
  check_pointer (newS->gID		= (long*)malloc (sizeof(long)*DEFAULT_STRING_ALLOC));
  check_pointer (newS->startTag	= (long*)malloc (sizeof(long)*DEFAULT_STRING_ALLOC));
  check_pointer (newS->lengthTag	= (long*)malloc (sizeof(long)*DEFAULT_STRING_ALLOC));
  
  newS->sLength  = 0;
  newS->saLength = DEFAULT_STRING_ALLOC;
  return newS;
}
Ejemplo n.º 3
0
tr_dh_secret_t
tr_dh_agree (tr_dh_ctx_t     handle,
             const uint8_t * other_public_key,
             size_t          other_public_key_length)
{
  struct tr_dh_secret * ret;
  int dh_size, secret_key_length;
  BIGNUM * other_key;

  assert (handle != NULL);
  assert (other_public_key != NULL);

  if (!check_pointer (other_key = BN_bin2bn (other_public_key, other_public_key_length, NULL)))
    return NULL;

  dh_size = DH_size (handle);
  ret = tr_dh_secret_new (dh_size);

  secret_key_length = DH_compute_key (ret->key, other_key, handle);
  if (check_result_neq (secret_key_length, -1))
    {
      tr_dh_secret_align (ret, secret_key_length);
    }
  else
    {
      tr_dh_secret_free (ret);
      ret = NULL;
    }

  BN_free (other_key);
  return ret;
}
Ejemplo n.º 4
0
static void
check_pointer_move(struct client *client, int x, int y)
{
	weston_test_move_pointer(client->test->weston_test, x, y);
	client_roundtrip(client);
	check_pointer(client, x, y);
}
Ejemplo n.º 5
0
static void   check_ro_ptrpair_sib   (Sib* ap) {
    //        ====================
    //
    Val* p;
    Val* stop;
    Val	 w;

    int gen =  GET_AGE_FROM_SIBID(ap->id);

    if (*sib_is_active(ap))   return;							// sib_is_active	def in    src/c/h/heap.h

    debug_say ("  pairs [%d]: [%#x..%#x:%#x)\n",
	gen, ap->tospace, ap->tospace.first_free, ap->tospace.limit);

    p = ap->tospace + 2;
    stop = ap->tospace.first_free;
    while (p < stop) {
	w = *p++;
	if (IS_TAGWORD(w)) {
	    ERROR;
	    debug_say (
		"** @%#x: unexpected tagword %#x in pair sib\n",
		p-1, w);
	    return;
	}
	else if (IS_POINTER(w)) {
	    check_pointer(p, w, gen, RO_CONSCELL_KIND, CHUNKC_any);
	}
    }
}
Ejemplo n.º 6
0
u_int32_t extract_ipv4(const struct sockaddr_in * address)
{
    u_int32_t result = 0;
    if (check_pointer(address) == 0)
        result = address->sin_addr.s_addr;

    return result;
}
Ejemplo n.º 7
0
// EzMemPool 构造函数
EzMemPool::EzMemPool() :
#ifdef _DEBUG
m_iAllocCounter(0),
#endif
m_iNULLCounter(0),
m_pHeadNode(NULL)
{
	m_pHeadNode = new_EzMemNode();
	check_pointer(m_pHeadNode, "<EzMemPool::EzMemPool>");
}
Ejemplo n.º 8
0
// 申请内存
void* EzMemPool::Alloc(size_t size){
	void* result = m_pHeadNode->alloc(size);
	if (!result){
		// 万一....
	ReCall:
		// 增加计数
		++m_iNULLCounter;
		// 奇数次->new 偶数次->调换
		if (m_iNULLCounter & 1){
			EzMemNode* node = new_EzMemNode();
			check_pointer(node, "<EzMemPool::Alloc>");
			if (!node)
				return nullptr;
			node->m_pNextNode = m_pHeadNode;
			m_pHeadNode = node;
			result = m_pHeadNode->alloc(size);
		}
		else{
			EzMemNode *pToTail = NULL, *pTail = m_pHeadNode;
			while (pTail){
				if (!pTail->m_pNextNode)
					break;
				pToTail = pTail;
				pTail = pTail->m_pNextNode;
			}
#ifdef _DEBUG
			assert(pToTail&&"我去.");
#endif
			pTail->m_pNextNode = NULL;
			m_pHeadNode = pTail;
			result = m_pHeadNode->alloc(size);
			if (!result)
				goto ReCall;
		}
	}
#ifdef _DEBUG
	if (result)
		++m_iAllocCounter;
	check_pointer(result, "池子干涸了.");
#endif
	return result;
}
Ejemplo n.º 9
0
struct storedNameTag * allocateNameTag (void)
{
  struct storedNameTag *newS = (struct storedNameTag*)malloc (sizeof (struct storedNameTag));
  check_pointer (newS);
  newS->taxID			= 0;
  newS->startIndex	= 0;
  newS->length		= 0;
  newS->mappedTag		= -1;
  
  return newS;
}
Ejemplo n.º 10
0
tr_dh_ctx_t
tr_dh_new (const uint8_t * prime_num,
           size_t          prime_num_length,
           const uint8_t * generator_num,
           size_t          generator_num_length)
{
  DH * handle = DH_new ();

  assert (prime_num != NULL);
  assert (generator_num != NULL);

  if (!check_pointer (handle->p = BN_bin2bn (prime_num, prime_num_length, NULL)) ||
      !check_pointer (handle->g = BN_bin2bn (generator_num, generator_num_length, NULL)))
    {
      DH_free (handle);
      handle = NULL;
    }

  return handle;
}
Ejemplo n.º 11
0
void appendTagToBuffer (struct bufferedTags * d, const long id, const long start, const long length)
{
  long addThis;
		
  if (d->saLength == d->sLength)
  {
    addThis = d->saLength / 8;
    
    if (DEFAULT_STRING_ALLOC > addThis)
      addThis = DEFAULT_STRING_ALLOC;
    
    d->saLength += addThis;
    check_pointer (d->gID		= (long*)realloc (d->gID,sizeof(long)*d->saLength));
    check_pointer (d->startTag	= (long*)realloc (d->startTag,sizeof(long)*d->saLength));
    check_pointer (d->lengthTag	= (long*)realloc (d->lengthTag,sizeof(long)*d->saLength));
  }
  
  d->gID	   [d->sLength]   = id;
  d->startTag[d->sLength]   = start;
  d->lengthTag[d->sLength++] = length;
  
}
Ejemplo n.º 12
0
void register_object(int x, int y, void **objectadress, int type)
{
	if (x >= 0 && x < field_length && y >= 0 && y < field_height)
	{
			if (type == FIELD_NOTHING)
			{
				objects[y][x] = NULL;
				objecttypes[y][x] = FIELD_NOTHING;
			}
			else
				if (objects[y][x] == NULL || objecttypes[y][x] == FIELD_NOTHING)
				{
					//There is not yet an object at this place.
					objects[y][x] = objectadress;
					objecttypes[y][x] = type;
				}
				else
				{
					//Collision: There is another object at the same position.
					collision(objectadress, type, objects[y][x], objecttypes[y][x]);
					check_pointer();
				}
	}
}
void main(){

 FILE *infile,*outfile;
 char currch,nextch,*ch,chp[100];
 staggered_list *listpointer,*root=create_list_with_file("B:keywords");
 int dat,length_of;
 TOKEN *token,t;
 


                int g2_001_DATA_A;
                int g3_001_DOUBLE_SUBTREE_A;
                int g4_001_SINGLE_SUBTREE_A;
                int g5_001_KEYWORD_OR_WORD_A;
      /**************************************************************************/
      /**************************************************************************/
      /******************** DRIVING PROCEDURE    B:\ALSCAN *********************/
      /**************************************************************************/
       PROCEDURE_DIVISION:
      /**/
      /** takes the output from allinescan*/
      /** which is one line with all the cobol*/
      /** details on it, rather than cobol details*/
      /** */
      /** being spread across a number of lines*/
      /**/
       C1_001_SCAN:
           goto C1_002_SCAN_START;
       C1_002_SCAN_START_EX:
           goto C1_003_LINES;
       C1_003_LINES_EX:
           goto C1_013_EOF;
       C1_013_EOF_EX:
           goto veryend;
      /**/
       C1_002_SCAN_START:
  /*001*/      infile=open_input("b:\\testout.dat");
  /*003*/      currch=getc(infile);
           if(currch!=EOF) nextch=getc(infile);
  /*033*/      token=&t;
  /*021*/      outfile=open_output("b:\\testout2.dat");
           goto C1_002_SCAN_START_EX;
      /**/
       C1_003_LINES:
       C1_004_LINE_EX:
           if(!(
  /*C01*/         (currch==EOF)
))
                   goto C1_004_LINE;
           goto C1_003_LINES_EX;
      /**/
       C1_004_LINE:
           goto C1_005_LINE_START;
       C1_005_LINE_START_EX:
           goto C1_006_CHUNKS;
       C1_006_CHUNKS_EX:
           goto C1_012_BACKSLASH_N;
       C1_012_BACKSLASH_N_EX:
           goto C1_004_LINE_EX;
      /**/
       C1_005_LINE_START:
  /*016*/      /*printf("START OF LINE\n");*/
           goto C1_005_LINE_START_EX;
      /**/
       C1_006_CHUNKS:
       C1_007_CHUNK_EX:
           if(!(
  /*C02*/         (currch=='\n')
))
                   goto C1_007_CHUNK;
           goto C1_006_CHUNKS_EX;
      /**/
       C1_007_CHUNK:
           goto C1_008_START_CHUNK;
       C1_008_START_CHUNK_EX:
           goto C1_009_BLANKS;
       C1_009_BLANKS_EX:
           goto C1_011_DATA;
       C1_011_DATA_EX:
           goto C1_007_CHUNK_EX;
      /**/
       C1_008_START_CHUNK:
  /*005*/      ch=chp;
           goto C1_008_START_CHUNK_EX;
      /**/
       C1_009_BLANKS:
       C1_010_BLANK_EX:
           if(!(
  /*C03*/         (currch!=' ')
))
                   goto C1_010_BLANK;
           goto C1_009_BLANKS_EX;
      /**/
       C1_010_BLANK:
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C1_010_BLANK_EX;
      /**/
       C1_011_DATA:
                g2_001_DATA_A=0;
           goto C2_001_DATA;
       C2_001_EXIT01:
           goto C1_011_DATA_EX;
      /**/
       C1_012_BACKSLASH_N:
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*015*/      /*printf("END LINE TOKEN\n");*/
           /*getchar();*/
           goto C1_012_BACKSLASH_N_EX;
      /**/
       C1_013_EOF:
  /*002*/      close_file(infile);
  /*022*/      close_file(outfile);
           goto C1_013_EOF_EX;
      /**/
       C2_001_DATA:
           goto C2_002_DATA;
       C2_002_DATA_EX:
       C2_001_DATA_A:
                switch(g2_001_DATA_A){
                case 0 : goto C2_001_EXIT01;break;
                }
      /**/
       C2_002_DATA:
           if((
  /*C06*/         (currch=='"' || currch=='\'')
))
                   goto C2_003_NON_NUMERI_C_LITERAL;
           if((
  /*C07*/         (currch=='(')
))
                   goto C2_008_OPEN_BRACE;
           if((
  /*C08*/         (currch==')')
))
                   goto C2_010_CLOSE_BRACE;
           if((
  /*C15*/         (currch=='.')
))
                   goto C2_012_FULLSTOP;
           if((
  /*C09*/         (currch!='"' &&
               currch!='\'' &&
               currch!='(' &&
               currch!=')' &&
               currch!='.' &&
               currch!='\n')
))
                   goto C2_014_WORD;
       C2_003_NON_NUMERI_C_LITERAL_EX:
       C2_008_OPEN_BRACE_EX:
       C2_010_CLOSE_BRACE_EX:
       C2_012_FULLSTOP_EX:
       C2_014_WORD_EX:
           goto C2_002_DATA_EX;
      /**/
       C2_003_NON_NUMERI_C_LITERAL:
           if((
  /*C04*/         (currch=='"')
))
                   goto C2_004_DOUBLE_QUOTE;
           if((
  /*C05*/         (currch=='\'')
))
                   goto C2_006_SINGLE_QUOTE;
       C2_004_DOUBLE_QUOTE_EX:
       C2_006_SINGLE_QUOTE_EX:
           goto C2_003_NON_NUMERI_C_LITERAL_EX;
      /**/
       C2_004_DOUBLE_QUOTE:
           goto C2_005_DOUBLE_SUBTREE;
       C2_005_DOUBLE_SUBTREE_EX:
           goto C2_004_DOUBLE_QUOTE_EX;
      /**/
       C2_005_DOUBLE_SUBTREE:
                g3_001_DOUBLE_SUBTREE_A=0;
           goto C3_001_DOUBLE_SUBTREE;
       C3_001_EXIT01:
           goto C2_005_DOUBLE_SUBTREE_EX;
      /**/
       C2_006_SINGLE_QUOTE:
           goto C2_007_SINGLE_SUBTREE;
       C2_007_SINGLE_SUBTREE_EX:
           goto C2_006_SINGLE_QUOTE_EX;
      /**/
       C2_007_SINGLE_SUBTREE:
                g4_001_SINGLE_SUBTREE_A=0;
           goto C4_001_SINGLE_SUBTREE;
       C4_001_EXIT01:
           goto C2_007_SINGLE_SUBTREE_EX;
      /**/
       C2_008_OPEN_BRACE:
           goto C2_009_BRACE;
       C2_009_BRACE_EX:
           goto C2_008_OPEN_BRACE_EX;
      /**/
       C2_009_BRACE:
  /*008*/      /*printf("open brace\n");*/
  /*024*/      token->token_type=OPEN_BRACE; 
           token->value.keyword_number=OPEN_BRACE;
  /*023*/      write_token(outfile,token);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C2_009_BRACE_EX;
      /**/
       C2_010_CLOSE_BRACE:
           goto C2_011_PARENTHESI;
       C2_011_PARENTHESI_EX:
           goto C2_010_CLOSE_BRACE_EX;
      /**/
       C2_011_PARENTHESI:
  /*009*/      /*printf("close brace\n");*/
  /*025*/      token->token_type=CLOSE_BRACE; 
           token->value.keyword_number=CLOSE_BRACE;
  /*023*/      write_token(outfile,token);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C2_011_PARENTHESI_EX;
      /**/
       C2_012_FULLSTOP:
           goto C2_013_PERIOD;
       C2_013_PERIOD_EX:
           goto C2_012_FULLSTOP_EX;
      /**/
       C2_013_PERIOD:
  /*014*/      /*printf("fullstop\n");*/
  /*026*/      token->token_type=FULLSTOP; 
           token->value.keyword_number=FULLSTOP;
  /*023*/      write_token(outfile,token);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C2_013_PERIOD_EX;
      /**/
       C2_014_WORD:
           goto C2_015_KEYWORD_OR_WORD;
       C2_015_KEYWORD_OR_WORD_EX:
           goto C2_014_WORD_EX;
      /**/
       C2_015_KEYWORD_OR_WORD:
                g5_001_KEYWORD_OR_WORD_A=0;
           goto C5_001_KEYWORD_OR_WORD;
       C5_001_EXIT01:
           goto C2_015_KEYWORD_OR_WORD_EX;
      /**/
       C3_001_DOUBLE_SUBTREE:
           goto C3_002_START_QUOTE;
       C3_002_START_QUOTE_EX:
           goto C3_003_THE_IN_BETWEEN;
       C3_003_THE_IN_BETWEEN_EX:
           goto C3_007_END_QUOTE;
       C3_007_END_QUOTE_EX:
       C3_001_DOUBLE_SUBTREE_A:
                switch(g3_001_DOUBLE_SUBTREE_A){
                case 0 : goto C3_001_EXIT01;break;
                }
      /**/
       C3_002_START_QUOTE:
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*011*/      length_of=0;
  /*005*/      ch=chp;
  /*006*/      *ch='\0';
           goto C3_002_START_QUOTE_EX;
      /**/
       C3_003_THE_IN_BETWEEN:
       C3_004_CHAR_SEQUENCE_EX:
           if(!(
  /*C11*/         (currch=='"' && nextch!='"')
))
                   goto C3_004_CHAR_SEQUENCE;
           goto C3_003_THE_IN_BETWEEN_EX;
      /**/
       C3_004_CHAR_SEQUENCE:
           if((
  /*C13*/         (currch=='"' && nextch=='"')
))
                   goto C3_005_QUOTE_QUOTE;
           if(!(
  /*C13*/         (currch=='"' && nextch=='"')
))
                   goto C3_006_ANY_OTHER;
       C3_005_QUOTE_QUOTE_EX:
       C3_006_ANY_OTHER_EX:
           goto C3_004_CHAR_SEQUENCE_EX;
      /**/
       C3_005_QUOTE_QUOTE:
  /*012*/      length_of++;
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C3_005_QUOTE_QUOTE_EX;
      /**/
       C3_006_ANY_OTHER:
  /*012*/      length_of++;
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C3_006_ANY_OTHER_EX;
      /**/
       C3_007_END_QUOTE:
  /*013*/      token->token_type=NON_NUMERIC_LITERAL_LENGTH;
           token->value.keyword_number=length_of;
  /*023*/      write_token(outfile,token);
  /*007*/      /*printf("string token for %s\n",chp);*/
  /*029*/      token->token_type=NON_NUMERIC_LITERAL; 
           token->value.string=chp;
  /*023*/      write_token(outfile,token);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C3_007_END_QUOTE_EX;
      /**/
       C4_001_SINGLE_SUBTREE:
           goto C4_002_START_QUOTE;
       C4_002_START_QUOTE_EX:
           goto C4_003_THE_IN_BETWEEN;
       C4_003_THE_IN_BETWEEN_EX:
           goto C4_007_END_QUOTE;
       C4_007_END_QUOTE_EX:
       C4_001_SINGLE_SUBTREE_A:
                switch(g4_001_SINGLE_SUBTREE_A){
                case 0 : goto C4_001_EXIT01;break;
                }
      /**/
       C4_002_START_QUOTE:
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*011*/      length_of=0;
  /*005*/      ch=chp;
  /*006*/      *ch='\0';
           goto C4_002_START_QUOTE_EX;
      /**/
       C4_003_THE_IN_BETWEEN:
       C4_004_CHAR_SEQUENCE_EX:
           if(!(
  /*C12*/         (currch=='\'' && nextch!='\'')
))
                   goto C4_004_CHAR_SEQUENCE;
           goto C4_003_THE_IN_BETWEEN_EX;
      /**/
       C4_004_CHAR_SEQUENCE:
           if((
  /*C14*/         (currch=='\'' && nextch=='\'')
))
                   goto C4_005_SIN_QUOTE_SIN_QUOTE;
           if(!(
  /*C14*/         (currch=='\'' && nextch=='\'')
))
                   goto C4_006_ANY_OTHER;
       C4_005_SIN_QUOTE_SIN_QUOTE_EX:
       C4_006_ANY_OTHER_EX:
           goto C4_004_CHAR_SEQUENCE_EX;
      /**/
       C4_005_SIN_QUOTE_SIN_QUOTE:
  /*012*/      length_of++;
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_005_SIN_QUOTE_SIN_QUOTE_EX;
      /**/
       C4_006_ANY_OTHER:
  /*012*/      length_of++;
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_006_ANY_OTHER_EX;
      /**/
       C4_007_END_QUOTE:
  /*013*/      token->token_type=NON_NUMERIC_LITERAL_LENGTH;
           token->value.keyword_number=length_of;
  /*023*/      write_token(outfile,token);
  /*007*/      /*printf("string token for %s\n",chp);*/
  /*029*/      token->token_type=NON_NUMERIC_LITERAL; 
           token->value.string=chp;
  /*023*/      write_token(outfile,token);
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_007_END_QUOTE_EX;
      /**/
       C5_001_KEYWORD_OR_WORD:
           goto C5_002_KEYWORD_WORD_BCKTR;
       C5_002_KEYWORD_WORD_BCKTR_EX:
       C5_001_KEYWORD_OR_WORD_A:
                switch(g5_001_KEYWORD_OR_WORD_A){
                case 0 : goto C5_001_EXIT01;break;
                }
      /**/
       C5_002_KEYWORD_WORD_BCKTR:
           goto C5_003_KEYWORD;
       C5_003_KEYWORD_EX:
       C5_008_NON_KEYWORD_EX:
           goto C5_002_KEYWORD_WORD_BCKTR_EX;
      /**/
       C5_003_KEYWORD:
           goto C5_004_KEYWORD_START;
       C5_004_KEYWORD_START_EX:
           goto C5_005_KEYWORD_CHARS;
       C5_005_KEYWORD_CHARS_EX:
           goto C5_007_KEYWORD_END;
       C5_007_KEYWORD_END_EX:
           goto C5_003_KEYWORD_EX;
      /**/
       C5_004_KEYWORD_START:
  /*005*/      ch=chp;
  /*011*/      length_of=0;
  /*017*/      listpointer=root;
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*018*/      listpointer=check_pointer(listpointer,currch);
  /*012*/      length_of++;
           if((
  /*Q01*/         (!isupper(currch)) && currch!='-'
))
                   goto C5_008_NON_KEYWORD;
           if((
  /*Q02*/         listpointer==NULL
))
                   goto C5_008_NON_KEYWORD;
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_004_KEYWORD_START_EX;
      /**/
       C5_005_KEYWORD_CHARS:
       C5_006_KEYWORD_CHAR_EX:
           if(!(
  /*C10*/         (currch==' ' || currch=='\n' || 
               currch=='(' || currch==')' ||
               currch=='.')
))
                   goto C5_006_KEYWORD_CHAR;
           goto C5_005_KEYWORD_CHARS_EX;
      /**/
       C5_006_KEYWORD_CHAR:
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*012*/      length_of++;
  /*018*/      listpointer=check_pointer(listpointer,currch);
           if((
  /*Q01*/         (!isupper(currch)) && currch!='-'
))
                   goto C5_008_NON_KEYWORD;
           if((
  /*Q02*/         listpointer==NULL
))
                   goto C5_008_NON_KEYWORD;
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_006_KEYWORD_CHAR_EX;
      /**/
       C5_007_KEYWORD_END:
  /*019*/      dat=get_data(listpointer);
           if((
  /*Q03*/         dat==NULL
))
                   goto C5_008_NON_KEYWORD;
  /*020*/      /*printf("keyword - %s number %d",chp,dat);*/
  /*027*/      token->token_type=KEYWORD; 
           token->value.keyword_number=dat;
  /*023*/      write_token(outfile,token);
           goto C5_007_KEYWORD_END_EX;
      /**/
       C5_008_NON_KEYWORD:
           goto C5_009_START_NON;
       C5_009_START_NON_EX:
           goto C5_010_CHARS;
       C5_010_CHARS_EX:
           goto C5_012_END_WORD;
       C5_012_END_WORD_EX:
           goto C5_008_NON_KEYWORD_EX;
      /**/
       C5_009_START_NON:
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_009_START_NON_EX;
      /**/
       C5_010_CHARS:
       C5_011_CHAR_EX:
           if(!(
  /*C10*/         (currch==' ' || currch=='\n' || 
               currch=='(' || currch==')' ||
               currch=='.')
))
                   goto C5_011_CHAR;
           goto C5_010_CHARS_EX;
      /**/
       C5_011_CHAR:
  /*030*/      *ch=currch;
  /*031*/      ch++;
  /*006*/      *ch='\0';
  /*012*/      length_of++;
  /*004*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_011_CHAR_EX;
      /**/
       C5_012_END_WORD:
  /*010*/      /*printf("word token for %s\n",chp);*/
  /*032*/      token->token_type=NON_KEYWORD_LENGTH;
           token->value.keyword_number=length_of;
  /*023*/      write_token(outfile,token);
  /*028*/      token->token_type=NON_KEYWORD; 
           token->value.string=chp;
  /*023*/      write_token(outfile,token);
  /*013*/      token->token_type=NON_NUMERIC_LITERAL_LENGTH;
           token->value.keyword_number=length_of;
           goto C5_012_END_WORD_EX;
      /**/
      /*   Data Analysis Map*/
      /**/
      /*                         ------------- Data Analysis By -------------*/
      /**/
      /*                         BOX TYPE               OPERATION  ALLOCATION*/
      /*  Tree name: SCAN*/
      /**/
      /*                         Leaf      :   6          Operations:  11*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   0*/
      /*                         Sequences :   3*/
      /*                         Iterations:   3*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   1   -->    DATA*/
      /**/
      /*  Tree name: DATA*/
      /**/
      /*                         Leaf      :   3          Operations:  12*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   2*/
      /*                         Sequences :   7*/
      /*                         Iterations:   0*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   3   -->    DOUBLE-SUBTREE*/
      /*                                                  SINGLE-SUBTREE*/
      /*                                                  KEYWORD_OR-WORD*/
      /**/
      /*  Tree name: DOUBLE-SUBTREE*/
      /**/
      /*                         Leaf      :   4          Operations:  21*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   1*/
      /*                         Sequences :   1*/
      /*                         Iterations:   1*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   0*/
      /**/
      /*  Tree name: SINGLE-SUBTREE*/
      /**/
      /*                         Leaf      :   4          Operations:  21*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   1*/
      /*                         Sequences :   1*/
      /*                         Iterations:   1*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   0*/
      /**/
      /*  Tree name: KEYWORD_OR-WORD*/
      /**/
      /*                         Leaf      :   6          Operations:  31*/
      /*                                                  Quits     :   5*/
      /*                         Selections:   0*/
      /*                         Sequences :   3*/
      /*                         Iterations:   2*/
      /*                         Backtracks:   1*/
      /*                         Subtrees  :   0*/
      /**/
      /**/
      /**/
veryend: ;
}
Ejemplo n.º 14
0
static unsigned wait_for_vq_desc(struct virtqueue *vq,
				 struct iovec iov[],
				 unsigned int *out_num, unsigned int *in_num)
{
	unsigned int i, head, max;
	struct vring_desc *desc;
	u16 last_avail = lg_last_avail(vq);

	
	while (last_avail == vq->vring.avail->idx) {
		u64 event;

		trigger_irq(vq);

		
		vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY;

		/*
		 * They could have slipped one in as we were doing that: make
		 * sure it's written, then check again.
		 */
		mb();
		if (last_avail != vq->vring.avail->idx) {
			vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
			break;
		}

		
		if (read(vq->eventfd, &event, sizeof(event)) != sizeof(event))
			errx(1, "Event read failed?");

		
		vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
	}

	
	if ((u16)(vq->vring.avail->idx - last_avail) > vq->vring.num)
		errx(1, "Guest moved used index from %u to %u",
		     last_avail, vq->vring.avail->idx);

	head = vq->vring.avail->ring[last_avail % vq->vring.num];
	lg_last_avail(vq)++;

	
	if (head >= vq->vring.num)
		errx(1, "Guest says index %u is available", head);

	
	*out_num = *in_num = 0;

	max = vq->vring.num;
	desc = vq->vring.desc;
	i = head;

	if (desc[i].flags & VRING_DESC_F_INDIRECT) {
		if (desc[i].len % sizeof(struct vring_desc))
			errx(1, "Invalid size for indirect buffer table");

		max = desc[i].len / sizeof(struct vring_desc);
		desc = check_pointer(desc[i].addr, desc[i].len);
		i = 0;
	}

	do {
		
		iov[*out_num + *in_num].iov_len = desc[i].len;
		iov[*out_num + *in_num].iov_base
			= check_pointer(desc[i].addr, desc[i].len);
		
		if (desc[i].flags & VRING_DESC_F_WRITE)
			(*in_num)++;
		else {
			if (*in_num)
				errx(1, "Descriptor has out after in");
			(*out_num)++;
		}

		
		if (*out_num + *in_num > max)
			errx(1, "Looped descriptor");
	} while ((i = next_desc(desc, i, max)) != max);

	return head;
}
void main(){

FILE *infile,*outfile;
char currch,nextch,ch[100],*chp;
staggered_list *listpointer,*root=create_list_with_file("B:keywords");
SYMTAB_ENTRY **symtab=create_symbol_table_array(100);
int dat,length_of;
TOKEN *token,t;
NODE *node;


                int g2_001_DATA_STUFFSUB_A;
                int g3_001_REST_SUBTREE_A;
                int g4_001_SINGLE_SUBTREE_A;
                int g5_001_DOUBLE_SUBTREE_A;
                int g6_001_WORD_SUBTREE_A;
      /**************************************************************************/
      /**************************************************************************/
      /******************** DRIVING PROCEDURE    B:\OPSANYL *********************/
      /**************************************************************************/
       PROCEDURE_DIVISION:
      /**/
      /** The ops analyser takes the .ops file*/
      /** and tokenises it for processing by*/
      /** the ops builder*/
      /**/
       C1_001_OPS_ANALYSER:
           goto C1_002_OPS_START;
       C1_002_OPS_START_EX:
           goto C1_003_OPS;
       C1_003_OPS_EX:
           goto C1_015_OPS_END;
       C1_015_OPS_END_EX:
           goto veryend;
      /**/
       C1_002_OPS_START:
  /*028*/      token=&t;
  /*001*/      infile=open_input("b:altest.ops");
  /*003*/      outfile=open_output("b:opsout.dat");
  /*008*/      load_symtab(symtab,"b:symtable.out");
           cross_reference(symtab,100);
  /*005*/      currch=getc(infile);
           if(currch!=EOF) nextch=getc(infile);
           goto C1_002_OPS_START_EX;
      /**/
       C1_003_OPS:
       C1_004_OP_GROUP_EX:
           if(!(
  /*C01*/         (currch==EOF)
))
                   goto C1_004_OP_GROUP;
           goto C1_003_OPS_EX;
      /**/
       C1_004_OP_GROUP:
           goto C1_005_OP_NUM_REC;
       C1_005_OP_NUM_REC_EX:
           goto C1_014_REST_SUBTREE;
       C1_014_REST_SUBTREE_EX:
           goto C1_004_OP_GROUP_EX;
      /**/
      /** an op consists of the op number*/
      /** followed by the rest of it*/
      /**/
       C1_005_OP_NUM_REC:
           goto C1_006_OP_NUM;
       C1_006_OP_NUM_EX:
           goto C1_011_DATA;
       C1_011_DATA_EX:
           goto C1_005_OP_NUM_REC_EX;
      /**/
       C1_006_OP_NUM:
           goto C1_007_OP_NUM_START;
       C1_007_OP_NUM_START_EX:
           goto C1_008_OP_NUM_BODY;
       C1_008_OP_NUM_BODY_EX:
           goto C1_010_OP_NUM_END;
       C1_010_OP_NUM_END_EX:
           goto C1_006_OP_NUM_EX;
      /**/
       C1_007_OP_NUM_START:
  /*007*/      chp=ch;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C1_007_OP_NUM_START_EX;
      /**/
       C1_008_OP_NUM_BODY:
       C1_009_OP_NUM_NUMBER_EX:
           if(!(
  /*C02*/         (currch==' ')
))
                   goto C1_009_OP_NUM_NUMBER;
           goto C1_008_OP_NUM_BODY_EX;
      /**/
       C1_009_OP_NUM_NUMBER:
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C1_009_OP_NUM_NUMBER_EX;
      /**/
       C1_010_OP_NUM_END:
  /*018*/      dat=str_to_int(ch);
  /*022*/      token->token_type=OP_NUM;token->value.keyword_number=dat;
  /*012*/      write_token(outfile,token);
           goto C1_010_OP_NUM_END_EX;
      /**/
       C1_011_DATA:
       C1_012_DATA_GROUP_EX:
           if(!(
  /*C03*/         (currch==EOF || currch=='\n')
))
                   goto C1_012_DATA_GROUP;
           goto C1_011_DATA_EX;
      /**/
       C1_012_DATA_GROUP:
           goto C1_013_DATA_STUFFSUB;
       C1_013_DATA_STUFFSUB_EX:
           goto C1_012_DATA_GROUP_EX;
      /**/
       C1_013_DATA_STUFFSUB:
                g2_001_DATA_STUFFSUB_A=0;
           goto C2_001_DATA_STUFFSUB;
       C2_001_EXIT01:
           goto C1_013_DATA_STUFFSUB_EX;
      /**/
       C1_014_REST_SUBTREE:
                g3_001_REST_SUBTREE_A=0;
           goto C3_001_REST_SUBTREE;
       C3_001_EXIT01:
           goto C1_014_REST_SUBTREE_EX;
      /**/
       C1_015_OPS_END:
  /*002*/      close_file(infile);
  /*004*/      close_file(outfile);
           goto C1_015_OPS_END_EX;
      /**/
       C2_001_DATA_STUFFSUB:
           goto C2_002_BLANKS;
       C2_002_BLANKS_EX:
           goto C2_004_DATA;
       C2_004_DATA_EX:
       C2_001_DATA_STUFFSUB_A:
                switch(g2_001_DATA_STUFFSUB_A){
                case 0 : goto C2_001_EXIT01;break;
                case 1 : goto C2_001_EXIT03;break;
                }
      /**/
       C2_002_BLANKS:
       C2_003_BLANK_EX:
           if(!(
  /*C04*/         (currch!=' ')
))
                   goto C2_003_BLANK;
           goto C2_002_BLANKS_EX;
      /**/
       C2_003_BLANK:
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C2_003_BLANK_EX;
      /**/
       C2_004_DATA:
           if((
  /*C05*/         (currch=='"' || currch=='\'')
))
                   goto C2_005_NON_NUM_LITERAL;
           if((
  /*C06*/         (currch=='.')
))
                   goto C2_010_FULLSTOP;
           if((
  /*C07*/         (currch!='"' &&
               currch!='\'' &&
               currch!='.' &&
               currch!='\n')
))
                   goto C2_012_WORD;
       C2_005_NON_NUM_LITERAL_EX:
       C2_010_FULLSTOP_EX:
       C2_012_WORD_EX:
           goto C2_004_DATA_EX;
      /**/
       C2_005_NON_NUM_LITERAL:
           if((
  /*C08*/         (currch=='\'')
))
                   goto C2_006_SINGLE;
           if((
  /*C09*/         (currch=='"')
))
                   goto C2_008_DOUBLE;
       C2_006_SINGLE_EX:
       C2_008_DOUBLE_EX:
           goto C2_005_NON_NUM_LITERAL_EX;
      /**/
       C2_006_SINGLE:
           goto C2_007_SINGLE_SUBTREE;
       C2_007_SINGLE_SUBTREE_EX:
           goto C2_006_SINGLE_EX;
      /**/
       C2_007_SINGLE_SUBTREE:
                g4_001_SINGLE_SUBTREE_A=0;
           goto C4_001_SINGLE_SUBTREE;
       C4_001_EXIT01:
           goto C2_007_SINGLE_SUBTREE_EX;
      /**/
       C2_008_DOUBLE:
           goto C2_009_DOUBLE_SUBTREE;
       C2_009_DOUBLE_SUBTREE_EX:
           goto C2_008_DOUBLE_EX;
      /**/
       C2_009_DOUBLE_SUBTREE:
                g5_001_DOUBLE_SUBTREE_A=0;
           goto C5_001_DOUBLE_SUBTREE;
       C5_001_EXIT01:
           goto C2_009_DOUBLE_SUBTREE_EX;
      /**/
       C2_010_FULLSTOP:
           goto C2_011_PERIOD;
       C2_011_PERIOD_EX:
           goto C2_010_FULLSTOP_EX;
      /**/
       C2_011_PERIOD:
  /*013*/      token->token_type=FULLSTOP;token->value.keyword_number=FULLSTOP;
  /*012*/      write_token(outfile,token);
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C2_011_PERIOD_EX;
      /**/
       C2_012_WORD:
           goto C2_013_WORD_SUBTREE;
       C2_013_WORD_SUBTREE_EX:
           goto C2_012_WORD_EX;
      /**/
       C2_013_WORD_SUBTREE:
                g6_001_WORD_SUBTREE_A=0;
           goto C6_001_WORD_SUBTREE;
       C6_001_EXIT01:
           goto C2_013_WORD_SUBTREE_EX;
      /**/
       C6_001_WORD_SUBTREE:
           goto C6_002_WORD_START;
       C6_002_WORD_START_EX:
           goto C6_003_WORD_BODY;
       C6_003_WORD_BODY_EX:
       C6_001_WORD_SUBTREE_A:
                switch(g6_001_WORD_SUBTREE_A){
                case 0 : goto C6_001_EXIT01;break;
                }
      /**/
       C6_002_WORD_START:
  /*007*/      chp=ch;
  /*019*/      *chp='\0';
           goto C6_002_WORD_START_EX;
      /**/
       C6_003_WORD_BODY:
           goto C6_004_KEYWORD;
       C6_004_KEYWORD_EX:
       C6_009_NON_KEYWOR_D_EX:
           goto C6_003_WORD_BODY_EX;
      /**/
       C6_004_KEYWORD:
           goto C6_005_KEYWORD_START;
       C6_005_KEYWORD_START_EX:
           goto C6_006_KEYWORD_BODY;
       C6_006_KEYWORD_BODY_EX:
           goto C6_008_KEYWORD_END;
       C6_008_KEYWORD_END_EX:
           goto C6_004_KEYWORD_EX;
      /**/
       C6_005_KEYWORD_START:
  /*009*/      listpointer=root;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*010*/      listpointer=check_pointer(listpointer,currch);
           if((
  /*Q01*/         (!isupper(currch)) && currch!='-'
))
                   goto C6_009_NON_KEYWOR_D;
           if((
  /*Q02*/         listpointer==NULL
))
                   goto C6_009_NON_KEYWOR_D;
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C6_005_KEYWORD_START_EX;
      /**/
       C6_006_KEYWORD_BODY:
       C6_007_KEYWORD_CHAR_EX:
           if(!(
  /*C10*/         (currch==' ' || currch=='\n' ||
               currch=='.' || currch==EOF)
))
                   goto C6_007_KEYWORD_CHAR;
           goto C6_006_KEYWORD_BODY_EX;
      /**/
       C6_007_KEYWORD_CHAR:
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*010*/      listpointer=check_pointer(listpointer,currch);
           if((
  /*Q01*/         (!isupper(currch)) && currch!='-'
))
                   goto C6_009_NON_KEYWOR_D;
           if((
  /*Q02*/         listpointer==NULL
))
                   goto C6_009_NON_KEYWOR_D;
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C6_007_KEYWORD_CHAR_EX;
      /**/
       C6_008_KEYWORD_END:
  /*011*/      dat=get_data(listpointer);
           if((
  /*Q03*/         dat==NULL
))
                   goto C6_009_NON_KEYWOR_D;
  /*014*/      token->token_type=KEYWORD;token->value.keyword_number=dat;
  /*012*/      write_token(outfile,token);
           goto C6_008_KEYWORD_END_EX;
      /**/
       C6_009_NON_KEYWOR_D:
           goto C6_010_CHARS;
       C6_010_CHARS_EX:
           goto C6_015_CHOICE;
       C6_015_CHOICE_EX:
           goto C6_009_NON_KEYWOR_D_EX;
      /**/
       C6_010_CHARS:
           goto C6_011_CHARS_START;
       C6_011_CHARS_START_EX:
           goto C6_012_CHARS_BODY;
       C6_012_CHARS_BODY_EX:
           goto C6_014_CHARS_END;
       C6_014_CHARS_END_EX:
           goto C6_010_CHARS_EX;
      /**/
       C6_011_CHARS_START:
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C6_011_CHARS_START_EX;
      /**/
       C6_012_CHARS_BODY:
       C6_013_CHAR_EX:
           if(!(
  /*C10*/         (currch==' ' || currch=='\n' ||
               currch=='.' || currch==EOF)
))
                   goto C6_013_CHAR;
           goto C6_012_CHARS_BODY_EX;
      /**/
       C6_013_CHAR:
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C6_013_CHAR_EX;
      /**/
       C6_014_CHARS_END:
  /*027*/      node=look_for_by_name(ch,symtab);
           goto C6_014_CHARS_END_EX;
      /**/
       C6_015_CHOICE:
           if((
  /*C11*/         (node==NULL && isdigit(ch[0]))
))
                   goto C6_016_POSSIBLE_NUMBER;
           if((
  /*C18*/         (node!=NULL)
))
                   goto C6_018_VARIABLE;
       C6_016_POSSIBLE_NUMBER_EX:
       C6_018_VARIABLE_EX:
           goto C6_015_CHOICE_EX;
      /**/
       C6_016_POSSIBLE_NUMBER:
           goto C6_017_NUMBER;
       C6_017_NUMBER_EX:
           goto C6_016_POSSIBLE_NUMBER_EX;
      /**/
       C6_017_NUMBER:
  /*018*/      dat=str_to_int(ch);
  /*024*/      token->token_type=NUMERIC;token->value.keyword_number=dat;
  /*012*/      write_token(outfile,token);
           goto C6_017_NUMBER_EX;
      /**/
       C6_018_VARIABLE:
           goto C6_019_VAR_START;
       C6_019_VAR_START_EX:
           goto C6_018_VARIABLE_EX;
      /**/
       C6_019_VAR_START:
  /*023*/      token->token_type=VARIABLE_NAME;token->value.var_values.hash=node->own.hash;
           token->value.var_values.unique=node->own.unique;
  /*012*/      write_token(outfile,token);
           goto C6_019_VAR_START_EX;
      /**/
       C3_001_REST_SUBTREE:
           goto C3_002_REST_OF_GROUP;
       C3_002_REST_OF_GROUP_EX:
       C3_001_REST_SUBTREE_A:
                switch(g3_001_REST_SUBTREE_A){
                case 0 : goto C3_001_EXIT01;break;
                }
      /**/
       C3_002_REST_OF_GROUP:
       C3_003_DATA_GROUP_EX:
           if(!(
  /*C12*/         (currch==EOF || isdigit(currch))
))
                   goto C3_003_DATA_GROUP;
           goto C3_002_REST_OF_GROUP_EX;
      /**/
       C3_003_DATA_GROUP:
           goto C3_004_DATA;
       C3_004_DATA_EX:
           goto C3_007_DATA_END;
       C3_007_DATA_END_EX:
           goto C3_003_DATA_GROUP_EX;
      /**/
       C3_004_DATA:
       C3_005_LINE_EX:
           if(!(
  /*C13*/         (currch=='\n' || currch==EOF)
))
                   goto C3_005_LINE;
           goto C3_004_DATA_EX;
      /**/
       C3_005_LINE:
           goto C3_006_DATA_STUFFSUB;
       C3_006_DATA_STUFFSUB_EX:
           goto C3_005_LINE_EX;
      /**/
       C3_006_DATA_STUFFSUB:
                g2_001_DATA_STUFFSUB_A=1;
           goto C2_001_DATA_STUFFSUB;
       C2_001_EXIT03:
           goto C3_006_DATA_STUFFSUB_EX;
      /**/
       C3_007_DATA_END:
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C3_007_DATA_END_EX;
      /**/
       C4_001_SINGLE_SUBTREE:
           goto C4_002__START;
       C4_002__START_EX:
           goto C4_003__BODY;
       C4_003__BODY_EX:
           goto C4_007__END;
       C4_007__END_EX:
       C4_001_SINGLE_SUBTREE_A:
                switch(g4_001_SINGLE_SUBTREE_A){
                case 0 : goto C4_001_EXIT01;break;
                }
      /**/
       C4_002__START:
  /*007*/      chp=ch;
  /*019*/      *chp='\0';
  /*025*/      length_of=0;
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_002__START_EX;
      /**/
       C4_003__BODY:
       C4_004_CHAR_EX:
           if(!(
  /*C16*/         (currch=='\'' && nextch!='\'')
))
                   goto C4_004_CHAR;
           goto C4_003__BODY_EX;
      /**/
       C4_004_CHAR:
           if((
  /*C14*/         (currch=='\'' && nextch=='\'')
))
                   goto C4_005_QUOTE_QUOTE;
           if(!(
  /*C14*/         (currch=='\'' && nextch=='\'')
))
                   goto C4_006_ANY;
       C4_005_QUOTE_QUOTE_EX:
       C4_006_ANY_EX:
           goto C4_004_CHAR_EX;
      /**/
       C4_005_QUOTE_QUOTE:
  /*026*/      length_of++;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_005_QUOTE_QUOTE_EX;
      /**/
       C4_006_ANY:
  /*026*/      length_of++;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_006_ANY_EX;
      /**/
       C4_007__END:
  /*017*/      token->token_type=NON_NUMERIC_LITERAL_LENGTH;token->value.keyword_number=
                                                                           length_of;
  /*012*/      write_token(outfile,token);
  /*016*/      token->token_type=NON_NUMERIC_LITERAL;token->value.string=ch;
  /*012*/      write_token(outfile,token);
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C4_007__END_EX;
      /**/
       C5_001_DOUBLE_SUBTREE:
           goto C5_002__START;
       C5_002__START_EX:
           goto C5_003__BODY;
       C5_003__BODY_EX:
           goto C5_007__END;
       C5_007__END_EX:
       C5_001_DOUBLE_SUBTREE_A:
                switch(g5_001_DOUBLE_SUBTREE_A){
                case 0 : goto C5_001_EXIT01;break;
                }
      /**/
       C5_002__START:
  /*007*/      chp=ch;
  /*019*/      *chp='\0';
  /*025*/      length_of=0;
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_002__START_EX;
      /**/
       C5_003__BODY:
       C5_004_CHAR_EX:
           if(!(
  /*C17*/         (currch=='"' && nextch!='"')
))
                   goto C5_004_CHAR;
           goto C5_003__BODY_EX;
      /**/
       C5_004_CHAR:
           if((
  /*C15*/         (currch=='"' && nextch=='"')
))
                   goto C5_005_QUOTE_QUOTE;
           if(!(
  /*C15*/         (currch=='"' && nextch=='"')
))
                   goto C5_006_ANY;
       C5_005_QUOTE_QUOTE_EX:
       C5_006_ANY_EX:
           goto C5_004_CHAR_EX;
      /**/
       C5_005_QUOTE_QUOTE:
  /*026*/      length_of++;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_005_QUOTE_QUOTE_EX;
      /**/
       C5_006_ANY:
  /*026*/      length_of++;
  /*021*/      *chp=currch;
  /*020*/      chp++;
  /*019*/      *chp='\0';
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_006_ANY_EX;
      /**/
       C5_007__END:
  /*017*/      token->token_type=NON_NUMERIC_LITERAL_LENGTH;token->value.keyword_number=
                                                                           length_of;
  /*012*/      write_token(outfile,token);
  /*016*/      token->token_type=NON_NUMERIC_LITERAL;token->value.string=ch;
  /*012*/      write_token(outfile,token);
  /*006*/      currch=nextch;
           if(nextch!=EOF) nextch=getc(infile);
           goto C5_007__END_EX;
      /**/
      /*   Data Analysis Map*/
      /**/
      /*                         ------------- Data Analysis By -------------*/
      /**/
      /*                         BOX TYPE               OPERATION  ALLOCATION*/
      /*  Tree name: OPS-ANALYSER*/
      /**/
      /*                         Leaf      :   5          Operations:  19*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   0*/
      /*                         Sequences :   5*/
      /*                         Iterations:   3*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   2   -->    DATA-STUFFSUB*/
      /*                                                  REST-SUBTREE*/
      /**/
      /*  Tree name: DATA-STUFFSUB*/
      /**/
      /*                         Leaf      :   2          Operations:   4*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   2*/
      /*                         Sequences :   5*/
      /*                         Iterations:   1*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   3   -->    SINGLE-SUBTREE*/
      /*                                                  DOUBLE-SUBTREE*/
      /*                                                  WORD-SUBTREE*/
      /**/
      /*  Tree name: WORD-SUBTREE*/
      /**/
      /*                         Leaf      :   9          Operations:  27*/
      /*                                                  Quits     :   5*/
      /*                         Selections:   1*/
      /*                         Sequences :   6*/
      /*                         Iterations:   2*/
      /*                         Backtracks:   1*/
      /*                         Subtrees  :   0*/
      /**/
      /*  Tree name: REST-SUBTREE*/
      /**/
      /*                         Leaf      :   1          Operations:   1*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   0*/
      /*                         Sequences :   3*/
      /*                         Iterations:   2*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   1   -->    DATA-STUFFSUB*/
      /**/
      /*  Tree name: SINGLE-SUBTREE*/
      /**/
      /*                         Leaf      :   4          Operations:  20*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   1*/
      /*                         Sequences :   1*/
      /*                         Iterations:   1*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   0*/
      /**/
      /*  Tree name: DOUBLE-SUBTREE*/
      /**/
      /*                         Leaf      :   4          Operations:  20*/
      /*                                                  Quits     :   0*/
      /*                         Selections:   1*/
      /*                         Sequences :   1*/
      /*                         Iterations:   1*/
      /*                         Backtracks:   0*/
      /*                         Subtrees  :   0*/
      /**/
      /**/
      /**/
veryend: ;
}
Ejemplo n.º 16
0
/*
 * This looks in the virtqueue for the first available buffer, and converts
 * it to an iovec for convenient access.  Since descriptors consist of some
 * number of output then some number of input descriptors, it's actually two
 * iovecs, but we pack them into one and note how many of each there were.
 *
 * This function waits if necessary, and returns the descriptor number found.
 */
static unsigned wait_for_vq_desc(struct virtqueue *vq,
				 struct iovec iov[],
				 unsigned int *out_num, unsigned int *in_num)
{
	unsigned int i, head, max;
	struct vring_desc *desc;
	u16 last_avail = lg_last_avail(vq);

	/* There's nothing available? */
	while (last_avail == vq->vring.avail->idx) {
		u64 event;

		/*
		 * Since we're about to sleep, now is a good time to tell the
		 * Guest about what we've used up to now.
		 */
		trigger_irq(vq);

		/* OK, now we need to know about added descriptors. */
		vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY;

		/*
		 * They could have slipped one in as we were doing that: make
		 * sure it's written, then check again.
		 */
		mb();
		if (last_avail != vq->vring.avail->idx) {
			vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
			break;
		}

		/* Nothing new?  Wait for eventfd to tell us they refilled. */
		if (read(vq->eventfd, &event, sizeof(event)) != sizeof(event))
			errx(1, "Event read failed?");

		/* We don't need to be notified again. */
		vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
	}

	/* Check it isn't doing very strange things with descriptor numbers. */
	if ((u16)(vq->vring.avail->idx - last_avail) > vq->vring.num)
		errx(1, "Guest moved used index from %u to %u",
		     last_avail, vq->vring.avail->idx);

	/*
	 * Grab the next descriptor number they're advertising, and increment
	 * the index we've seen.
	 */
	head = vq->vring.avail->ring[last_avail % vq->vring.num];
	lg_last_avail(vq)++;

	/* If their number is silly, that's a fatal mistake. */
	if (head >= vq->vring.num)
		errx(1, "Guest says index %u is available", head);

	/* When we start there are none of either input nor output. */
	*out_num = *in_num = 0;

	max = vq->vring.num;
	desc = vq->vring.desc;
	i = head;

	/*
	 * If this is an indirect entry, then this buffer contains a descriptor
	 * table which we handle as if it's any normal descriptor chain.
	 */
	if (desc[i].flags & VRING_DESC_F_INDIRECT) {
		if (desc[i].len % sizeof(struct vring_desc))
			errx(1, "Invalid size for indirect buffer table");

		max = desc[i].len / sizeof(struct vring_desc);
		desc = check_pointer(desc[i].addr, desc[i].len);
		i = 0;
	}

	do {
		/* Grab the first descriptor, and check it's OK. */
		iov[*out_num + *in_num].iov_len = desc[i].len;
		iov[*out_num + *in_num].iov_base
			= check_pointer(desc[i].addr, desc[i].len);
		/* If this is an input descriptor, increment that count. */
		if (desc[i].flags & VRING_DESC_F_WRITE)
			(*in_num)++;
		else {
			/*
			 * If it's an output descriptor, they're all supposed
			 * to come before any input descriptors.
			 */
			if (*in_num)
				errx(1, "Descriptor has out after in");
			(*out_num)++;
		}

		/* If we've got too many, that implies a descriptor loop. */
		if (*out_num + *in_num > max)
			errx(1, "Looped descriptor");
	} while ((i = next_desc(desc, i, max)) != max);

	return head;
}
Ejemplo n.º 17
0
static void   check_ro_pointer_sib   (Sib* ap) {
    //        ====================
    Val* p;
    Val* stop;
    Val  tagword;
    Val  w;
    int	 i;
    int	 len;

    int gen =  GET_AGE_FROM_SIBID( ap->id );

    if (*sib_is_active(ap))   return;							// sib_is_active	def in    src/c/h/heap.h

    debug_say ("  records [%d]: [%#x..%#x:%#x)\n",
	//
        gen,
        ap->tospace,
	ap->tospace.first_free,
	ap->tospace.limit
    );

    p = ap->tospace;
    stop = ap->tospace.first_free;

    while (p < stop) {
	//
	tagword = *p++;

	if (*IS_TAGWORD(tagword)) {
	    ERROR;
	    debug_say (
		"** @%#x: expected tagword, but found %#x in record sib\n",
		p-1, tagword);
	    return;
	}

	switch (GET_BTAG_FROM_TAGWORD tagword) {
	    //
	case PAIRS_AND_RECORDS_BTAG:
	    #
	    len =  GET_LENGTH_IN_WORDS_FROM_TAGWORD( tagword );			// Length excludes tagword.
	    #
	    for (i = 0;  i < len;  i++, p++) {
		w = *p;
		if (IS_TAGWORD(w)) {
		    ERROR;
		    debug_say (
			"** @%#x: unexpected tagword %#x in slot %d of %d\n",
			p, w, i, GET_LENGTH_IN_WORDS_FROM_TAGWORD(tagword));
		    return;
		}
		else if (IS_POINTER(w)) {
		    check_pointer(p, w, gen, RO_POINTERS_KIND, CHUNKC_any);
		}
	    }
	    break;

	case RW_VECTOR_HEADER_BTAG:
	case RO_VECTOR_HEADER_BTAG:
	    //
	    switch (GET_LENGTH_IN_WORDS_FROM_TAGWORD(tagword)) {
		//
	    case TYPEAGNOSTIC_VECTOR_CTAG:
		if (GET_BTAG_FROM_TAGWORD(tagword) == RW_VECTOR_HEADER_BTAG)	check_pointer (p, *p, gen, RO_POINTERS_KIND, CHUNKC__IS_RW_POINTERS);
		else					    			check_pointer (p, *p, gen, RO_POINTERS_KIND, CHUNKC__IS_RO_POINTERS|CHUNKC__IS_RO_CONSCELL);
		break;

	    case VECTOR_OF_ONE_BYTE_UNTS_CTAG:
	    case UNT16_VECTOR_CTAG:
	    case TAGGED_INT_VECTOR_CTAG:
	    case INT1_VECTOR_CTAG:
	    case VECTOR_OF_FOUR_BYTE_FLOATS_CTAG:
	    case VECTOR_OF_EIGHT_BYTE_FLOATS_CTAG:
		check_pointer (p, *p, gen, RO_POINTERS_KIND, CHUNKC__IS_NONPTR_DATA);
		break;

	    default:
		ERROR;
		debug_say ("** @%#x: strange sequence kind %d in record sib\n",
		    p-1, GET_LENGTH_IN_WORDS_FROM_TAGWORD(tagword));
		return;
	    }

	    if (*IS_TAGGED_INT(p[1])) {
		ERROR;
		debug_say ("** @%#x: sequence header length field not an in (%#x)\n",
		    p+1, p[1]);
	    }
	    p += 2;
	    break;

	default:
	    ERROR;
	    debug_say ("** @%#x: strange tag (%#x) in record sib\n",
		p-1, GET_BTAG_FROM_TAGWORD(tagword));
	    return;
	}
    }
}											// fun check_ro_pointer_sib
Ejemplo n.º 18
0
static void   check_rw_pointer_sib   (Sib* ap,  Coarse_Inter_Agegroup_Pointers_Map* map)   {		// 'map' is nowhere used in the code?! Should be deleted or used.  XXX BUGGO FIXME
    //        ====================
    //
    Val* p;
    Val* stop;
    Val  tagword;
    Val  w;

    int  i, j;
    int  len;

    int  gen =  GET_AGE_FROM_SIBID(ap->id);

    if (*sib_is_active(ap))   return;							// sib_is_active	def in    src/c/h/heap.h

    debug_say ("  arrays [%d]: [%#x..%#x:%#x)\n",
	//
	gen,
	ap->tospace,
	ap->tospace.first_free,
	ap->tospace.limit
    );

    p = ap->tospace;
    stop = ap->tospace.first_free;

    while (p < stop) {
	tagword = *p++;
	if (*IS_TAGWORD(tagword)) {
	    ERROR;
	    debug_say (
		"** @%#x: expected tagword, but found %#x in vector sib\n",
		p-1, tagword);
	    return;
	}

	switch (GET_BTAG_FROM_TAGWORD(tagword)) {
	    //
	case RW_VECTOR_DATA_BTAG:
	    len = GET_LENGTH_IN_WORDS_FROM_TAGWORD(tagword);
	    break;

	case WEAK_POINTER_OR_SUSPENSION_BTAG:
	    len = 1;
	    break;

	default:
	    ERROR;
	    debug_say ("** @%#x: strange tag (%#x) in vector sib\n",
		p-1, GET_BTAG_FROM_TAGWORD(tagword));
	    return;
	}

	for (int i = 0;  i < len;  i++, p++) {
	    //
	    w = *p;
	    if (IS_TAGWORD(w)) {
		ERROR;
		debug_say (
		    "** @%#x: Unexpected tagword %#x in rw_vector slot %d of %d\n",
		    p, w, i, GET_LENGTH_IN_WORDS_FROM_TAGWORD(tagword));
		for (p -= (i+1), j = 0;  j <= len;  j++, p++) {
		    debug_say ("  %#x: %#10x\n", p, *p);
		}
		return;
	    } else if (IS_POINTER(w)) {
		check_pointer(p, w, gen, RW_POINTERS_KIND, CHUNKC_any);
	    }
	}
    }
}								// fun check_rw_pointer_sib