Пример #1
0
int scan_sym(FILE *fp, char *o_ptr)
  {

       int i;

X3:    TA(NA4);
       goto X4;
NA4:   TN(NN4);
       goto X4;
NN4:   TC(ES4,'_');
 /* loop back to here */  
X4:    TA(NA5);
       goto X4;
NA5:   TN(NN5);
       goto X4;
NN5:   TC(ES5,'_');
       goto X4;
ES4:   printf("Invalid name: ");
       for (i = 0; i < 7; i++) {
          printf("%c",curr_char);
          curr_char = getc(fp);
          } 
       printf("\n");       
       return(4);

ES5:   *o_ptr = '\0';
       return(0);
  }
Пример #2
0
Файл: div.c Проект: 8l/go-learn
int
multiplier(uint32 d, int p, uvlong *mp)
{
	int l;
	uvlong mlo, mhi, tlo, thi;

	l = topbit(d - 1) + 1;
	mlo = (((TN(l) - d) << 32) / d) + T32;
	if(l + p == 64)
		mhi = (((TN(l) + 1 - d) << 32) / d) + T32;
	else
		mhi = (TN(32 + l) + TN(32 + l - p)) / d;
	/*assert(mlo < mhi);*/
	while(l > 0) {
		tlo = mlo >> 1;
		thi = mhi >> 1;
		if(tlo == thi)
			break;
		mlo = tlo;
		mhi = thi;
		l--;
	}
	*mp = mhi;
	return l;
}
Пример #3
0
// Send the specified BitVector at the specified block time.
void PDCHL1Downlink::transmit(RLCBSN_t bsn, BitVector *mI, const int *qbits, int transceiverflags)
{
	parent()->debug_test();
	// Format the bits into the bursts.
	// GSM 05.03 4.1.5, 05.02 5.2.3
	// NO! Dont do a wait here.  The MAC serviceloop does this for all channels.
	// waitToSend();		// Don't get too far ahead of the clock.

	ARFCNManager *radio = getRadio();
	if (!radio) {
		// For some testing, we might not have a radio connected.
		// That's OK, as long as we know it.
		GLOG(INFO) << "XCCHL1Encoder with no radio, dumping frames";
		return;
	}

	int fn = bsn.FN();
	int tn = TN();

	for (int qi=0,B=0; B<4; B++) {
		Time nextWriteTime(fn,tn | transceiverflags);
		mchBurst.time(nextWriteTime);
		// Copy in the "encrypted" bits, GSM 05.03 4.1.5, 05.02 5.2.3.
		//OBJLOG(DEBUG) << "transmit mI["<<B<<"]=" << mI[B];
		mI[B].segment(0,57).copyToSegment(mchBurst,3);
		mI[B].segment(57,57).copyToSegment(mchBurst,88);
		mchBurst.Hl(qbits[qi++]);
		mchBurst.Hu(qbits[qi++]);
		// Send it to the radio.
		//OBJLOG(DEBUG) << "transmit mchBurst=" << mchBurst;
		if (gConfig.getBool("Control.GSMTAP.GPRS")) {
			// Send to GSMTAP.
			gWriteGSMTAP(ARFCN(),TN(),gBSNNext.FN(),
					TDMA_PDCH,
					false,	// not SACCH
					false,	// this is a downlink
					mchBurst,
					GSMTAP_TYPE_UM_BURST);
		}
#if FEC_DEBUG
		if (1) {
			// Try decoding the frame we just encoded to see if it is correct.
			devassert(mchBurst.size() == gSlotLen);
			RxBurst rxb(mchBurst);
			ChannelCodingType cc;
			decodeLowSide(rxb, B, debugDecoder, &cc);
		}
#endif
		radio->writeHighSideTx(mchBurst,"GPRS");
		fn++;	// This cannot overflow because it is within an RLC block.
	}
}
Пример #4
0
void PDCHL1FEC::mchStart() {
	getRadio()->setSlot(TN(),Transceiver::IGPRS);
	// Load up the GPRS filler idle burst tables in the transceiver.
	// We could use any consecutive bsn, but lets use ones around the current time
	// just to make sure they get through in case someone is triaging somewhere.
	// Sending all 12 blocks is 2x overkill because the modulus in Transceiver::setModulus
	// for type IGPRS is set the same as type I which is only 26, not 52.
	RLCBSN_t bsn = FrameNumber2BSN(gBTS.time().FN()) + 1;
	for (int i = 0; i < 12; i++, bsn = bsn + 1) {
		GPRSLOG(1) <<"sendIdleFrame"<<LOGVAR2("TN",TN())<<LOGVAR(bsn)<<LOGVAR(i);
		mchDownlink->sendIdleFrame(bsn);
	}
	mchOldFec->setGPRS(true,this);
	debug_test();
}
Пример #5
0
void FORTE_FB_FT_PIDWL::setInitialValues(){
  KP() = 1.0;
  TN() = 1.0;
  TV() = 1.0;
  LIM_L() = -1.0E38;
  LIM_H() = 1.0E38;
}
Пример #6
0
/*
Scan off a network label or process name (this is used for ports as well, as we don't know if a string is a port until later...)

Allowable characters are alphameric, hyphen, underscore; if character is preceded by backslash, will be accepted

This routine exits when an nonallowed character (or EOL) is encountered
*/
inline int scan_sym(FILE *fp, char * out_str)
{
	//extern char curr_char;
	char * o_ptr;

	o_ptr = out_str;
X4:
	TA(NA4);	
	goto X5;
NA4: 
	TN(NN4);
	goto X5;
NN4: 
	TC(NU4,'_');
	goto X5;
NU4:
	TC(ES4,'-');
	goto X5;
ES4:
	TCO(ES5, '\\');  // as per discussion on https://groups.google.com/forum/#!searchin/flow-based-programming/commas -
	                //             find "Special characters in process names" 
	CC;    	
X5:
	goto X4;
ES5:
	*o_ptr = '\0';           
	return(0);
}
Пример #7
0
void PDCHL1Downlink::send1Frame(BitVector& frame,ChannelCodingType encoding, bool idle)
{
	if (!idle && gConfig.getBool("Control.GSMTAP.GPRS")) {
		// Send to GSMTAP.
		gWriteGSMTAP(ARFCN(),TN(),gBSNNext.FN(),
				frame2GsmTapType(frame),
				false,	// not SACCH
				false,	// this is a downlink
				frame);	// The data.
	}

	switch (encoding) {
	case ChannelCodingCS1:
		// Process the 184 bit (23 byte) frame, leave result in mI.
		//mchCS1Enc.encodeFrame41(frame,0);
		//transmit(gBSNNext,mchCS1Enc.mI,qCS1,0);
		mchEnc.encodeCS1(frame);
		transmit(gBSNNext,mchEnc.mI,qCS1,0);
		break;
	case ChannelCodingCS4:
		//std::cout << "WARNING: Using CS4\n";
		// This did not help the 3105/3101 errors:
		//mchCS4Enc.initCS4();	// DEBUG TEST!!  Didnt help.
		//mchCS4Enc.encodeCS4(frame);	// Result left in mI[].
		//transmit(gBSNNext,mchCS4Enc.mI,qCS4,0);
		mchEnc.encodeCS4(frame);	// Result left in mI[].
		transmit(gBSNNext,mchEnc.mI,qCS4,0);
		break;
	default:
		LOG(ERR) << "unrecognized GPRS channel coding " << (int)encoding;
		devassert(0);
	}
}
Пример #8
0
static const char *tagname(uint32_t tag)
{
	static const char * const names[] = {
#define TN(t) [t] = #t
		TN(FDT_BEGIN_NODE),
		TN(FDT_END_NODE),
		TN(FDT_PROP),
		TN(FDT_NOP),
		TN(FDT_END),
#undef TN
	};
	if (tag < ARRAY_SIZE(names))
		if (names[tag])
			return names[tag];
	return "FDT_???";
}
Пример #9
0
void PDCHL1FEC::mchDump(std::ostream&os, bool verbose)
{
	os << " PDCH"<<LOGVAR2("ARFCN", ARFCN())
		<< LOGVAR2("TN",TN()) << LOGVAR2("FER",fmtfloat2(100.0*FER())) << "%" << "\n";
	if (verbose) {
		os <<"\t"; dumpReservations(os);
		os <<"\t"; usfDump(os);
		os <<"\t"; mchTFIs->tfiDump(os);
	}
}
Пример #10
0
void tt_xdoc_selectxp(IN tt_xdoc_t *xd,
                      IN tt_xpath_t *xp,
                      OUT tt_xnode_t *o_xn,
                      OUT tt_xattr_t *o_xa)
{
    pugi::xpath_node p =
        static_cast<pugi::xml_document *>(xd->p)->select_node(*P_XP(xp));

    pugi::xml_node pn = p.node();
    *o_xn = TN(pn);

    pugi::xml_attribute pa = p.attribute();
    *o_xa = TA(pa);
}
Пример #11
0
void tt_xdoc_select(IN tt_xdoc_t *xd,
                    IN const tt_char_t *xp,
                    IN OPT tt_xpvars_t *xpvs,
                    OUT tt_xnode_t *o_xn,
                    OUT tt_xattr_t *o_xa)
{
    pugi::xpath_node p =
        static_cast<pugi::xml_document *>(xd->p)->select_node(xp, P_XPVS(xpvs));

    pugi::xml_node pn = p.node();
    *o_xn = TN(pn);

    pugi::xml_attribute pa = p.attribute();
    *o_xa = TA(pa);
}
Пример #12
0
  int thxgatrs(char * comp) {

       char *o_ptr;
       char out_str[255];
       int atr = 0;
       char fname[256];
       FILE *fp = NULL;

       strcpy_s(fname,comp);
	   strcat_s(fname,".atr");
	   FILE* pFile;
	   #ifdef WIN32
	   fopen_s(&pFile, fname, "r");
       #else
	   pFile = fopen(fname,"r");
       #endif
	   
       if (pFile == NULL)
          return(-1);

       do {curr_char = getc(fp);} while (curr_char == '\n');

       o_ptr = out_str;
       scan_blanks(fp);
       TCO(nEOF,EOF);
       goto exit;

  nEOF: for (;;) {
           TA(nA);
           continue;
  nA:      TN(nN);
           continue;
  nN:      TC(nus,'_');
           continue;
  nus:     break;
         }
        *o_ptr = '\0';
        if (strcmp(out_str,"MUST_RUN") == 0 ||
            strcmp(out_str,"Must_run") == 0 ||
            strcmp(out_str,"must_run") == 0)
            atr = TRUE;
          else
            atr = FALSE;
        scan_blanks(fp);

  exit: fclose(fp);
     return(atr);
}
Пример #13
0
static void
speeddisk(int fd, off_t mediasize, u_int sectorsize)
{
	int bulk, i;
	off_t b0, b1, sectorcount, step;

	sectorcount = mediasize / sectorsize;
	step = 1ULL << (flsll(sectorcount / (4 * 200)) - 1);
	if (step > 16384)
		step = 16384;
	bulk = mediasize / (1024 * 1024);
	if (bulk > 100)
		bulk = 100;

	printf("Seek times:\n");
	printf("\tFull stroke:\t");
	b0 = 0;
	b1 = sectorcount - step;
	T0();
	for (i = 0; i < 125; i++) {
		rdsect(fd, b0, sectorsize);
		b0 += step;
		rdsect(fd, b1, sectorsize);
		b1 -= step;
	}
	TN(250);

	printf("\tHalf stroke:\t");
	b0 = sectorcount / 4;
	b1 = b0 + sectorcount / 2;
	T0();
	for (i = 0; i < 125; i++) {
		rdsect(fd, b0, sectorsize);
		b0 += step;
		rdsect(fd, b1, sectorsize);
		b1 += step;
	}
	TN(250);
	printf("\tQuarter stroke:\t");
	b0 = sectorcount / 4;
	b1 = b0 + sectorcount / 4;
	T0();
	for (i = 0; i < 250; i++) {
		rdsect(fd, b0, sectorsize);
		b0 += step;
		rdsect(fd, b1, sectorsize);
		b1 += step;
	}
	TN(500);

	printf("\tShort forward:\t");
	b0 = sectorcount / 2;
	T0();
	for (i = 0; i < 400; i++) {
		rdsect(fd, b0, sectorsize);
		b0 += step;
	}
	TN(400);

	printf("\tShort backward:\t");
	b0 = sectorcount / 2;
	T0();
	for (i = 0; i < 400; i++) {
		rdsect(fd, b0, sectorsize);
		b0 -= step;
	}
	TN(400);

	printf("\tSeq outer:\t");
	b0 = 0;
	T0();
	for (i = 0; i < 2048; i++) {
		rdsect(fd, b0, sectorsize);
		b0++;
	}
	TN(2048);

	printf("\tSeq inner:\t");
	b0 = sectorcount - 2048;
	T0();
	for (i = 0; i < 2048; i++) {
		rdsect(fd, b0, sectorsize);
		b0++;
	}
	TN(2048);

	printf("Transfer rates:\n");
	printf("\toutside:     ");
	rdsect(fd, 0, sectorsize);
	T0();
	for (i = 0; i < bulk; i++) {
		rdmega(fd);
	}
	TR(bulk * 1024);

	printf("\tmiddle:      ");
	b0 = sectorcount / 2 - bulk * (1024*1024 / sectorsize) / 2 - 1;
	rdsect(fd, b0, sectorsize);
	T0();
	for (i = 0; i < bulk; i++) {
		rdmega(fd);
	}
	TR(bulk * 1024);

	printf("\tinside:      ");
	b0 = sectorcount - bulk * (1024*1024 / sectorsize) - 1;
	rdsect(fd, b0, sectorsize);
	T0();
	for (i = 0; i < bulk; i++) {
		rdmega(fd);
	}
	TR(bulk * 1024);

	printf("\n");
	return;
}
Пример #14
0
   int thxscan(FILE *fp, cnxt_ent *cnxt_tab, proc_ent *proc_tab,
		       label_ent *label_tab, char file_name[10],
                        int *label_cp, int* proc_cp, int* cnxt_cp)
    {
       char *o_ptr;
       char out_str[255];
       char fname[256];
       char out_num[5];
       int i, IIPlen, ret_code;
       int proc_cnt;
       int proc_start = 0;
       int proc_hold, proc_last;
       int label_count, proc_count, cnxt_count;
       proc_ent *curr_proc;
       cnxt_ent *curr_cnxt;
       int label_ct;
       unsigned cnxt_open, eq_arrow;
       IIP *IIP_ptr;
       FILE *fp2;


       label_count = *label_cp;
       proc_count = *proc_cp;
       cnxt_count = *cnxt_cp;
       proc_hold = proc_count;
       ret_code = 0;
       do {curr_char = getc(fp);} while (curr_char == '\n');

 netloop:
       cnxt_open = FALSE;

       o_ptr = out_str;
       scan_blanks(fp);
       TCO(nEOF,EOF);  
       printf("End of Network Definition\n");
       goto exit;
 nEOF: TCO(NQ,'\'');
       strcpy(label_tab[label_count].label," ");
       strcpy(label_tab[label_count].file, file_name);
       label_tab[label_count].cnxt_ptr = &cnxt_tab[cnxt_count];
       label_tab[label_count].proc_ptr = &proc_tab[proc_count];
       label_tab[label_count].ent_type = 'L';
       printf("Scanning Main Network\n");
       proc_start = proc_count;
       proc_tab[proc_count].proc_name[0] = '\0';
       label_count++;
       label_tab[label_count].label[0] = '\0';
       goto TQ;
 NQ:   if (scan_sym(fp, o_ptr) != 0) {
	  printf("Name error\n");
	  ret_code = 4;
          goto exit;  }
       scan_blanks(fp);
       TCO(ncol,':');
       strcpy(label_tab[label_count].label,out_str);
       strcpy(label_tab[label_count].file, file_name);
       label_tab[label_count].cnxt_ptr = &cnxt_tab[cnxt_count];
       label_tab[label_count].proc_ptr = &proc_tab[proc_count];
       label_tab[label_count].ent_type = 'L';
       printf("Scanning Network: %s\n",out_str);
       proc_start = proc_count;
       label_count++;
       label_tab[label_count].label[0] = '\0';

       scan_blanks(fp);

loop:
       o_ptr = out_str;
       scan_blanks(fp);
       TCO(X1,'\'');
TQ:    
       TCO(tbsl,EOF);  
       printf("EOF encountered within quoted string\n");
       ret_code = 4;
       goto exit;
tbsl:  TCO(copy,'\'');
       TC(NQ2,'\'');
       goto TQ;
copy:  CC;
       goto TQ;
NQ2:   IIPlen = o_ptr - out_str;
       strcpy(cnxt_tab[cnxt_count].upstream_name,"!");
       IIP_ptr = (IIP *)malloc(IIPlen + sizeof(IIP_ptr -> IIP_len));
       IIP_ptr -> IIP_len = IIPlen;
       memcpy(IIP_ptr -> datapart, out_str, IIPlen);
       cnxt_tab[cnxt_count].gen.IIPptr = IIP_ptr;
       scan_blanks(fp);
       goto tArrow;

X1:    if (scan_sym(fp, o_ptr) != 0) {
	  printf("Name error\n");
	  ret_code = 4;
          goto exit;  }
       scan_blanks(fp);
       goto topen;

ncol:   strcpy(label_tab[label_count].label," ");
       strcpy(label_tab[label_count].file, file_name);
       label_tab[label_count].cnxt_ptr = &cnxt_tab[cnxt_count];
       label_tab[label_count].proc_ptr = &proc_tab[proc_count];
       label_tab[label_count].ent_type = 'L';
       proc_start = proc_count;
       label_count++;
       label_tab[label_count].label[0] = '\0';

topen:  if (cnxt_open) {
	  strcpy(cnxt_tab[cnxt_count].downstream_name,out_str);
	  cnxt_open = FALSE;
	  curr_cnxt = &cnxt_tab[cnxt_count];
	  if (curr_cnxt -> upstream_name[0] != '!')
             printf(" Connection: %s %s[%d] -> %s[%d] %s\n",
	     curr_cnxt -> upstream_name,
	     curr_cnxt -> upstream_port_name,
	     curr_cnxt -> upstream_elem_no,
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
	   else {
             printf(" IIP: -> %s[%d] %s\n",
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
             IIP_ptr = curr_cnxt -> gen.IIPptr;
             printf("    \'");
             for (i = 0; i < IIP_ptr -> IIP_len; i++)
	          printf("%c",IIP_ptr -> datapart[i]);
             printf("\'\n");
             }
	  cnxt_count++;
	  }
        else {
	TCO(NIP,'=');
	TCO(NIP,'>');
	scan_blanks(fp);

        strcpy(cnxt_tab[cnxt_count].upstream_name, "*");
	strcpy(cnxt_tab[cnxt_count].upstream_port_name,out_str);
        cnxt_tab[cnxt_count].upstream_elem_no = 0;
        goto ncap;
       }
	/* look up in proc list for subnet */
 NIP:  i = proc_start;
       while (proc_tab[i].proc_name[0] != '\0') {
         if (strcmp(proc_tab[i].proc_name,out_str) == 0) break;
	 i++;
         }
       proc_cnt = i;
       if (proc_tab[proc_cnt].proc_name[0] == '\0')  {
	 strcpy(proc_tab[proc_cnt].proc_name,out_str);
	 proc_tab[proc_cnt].trace = 0;
	 proc_tab[proc_cnt + 1].proc_name[0] = '\0';
	 proc_count = proc_cnt;
	 }

       TCO(NB1,'(');
       scan_blanks(fp);
       o_ptr = proc_tab[proc_cnt].comp_name;
Y1:    TA(NA2);
       goto Y1;
NA2:   TN(NN2);
       goto Y1;
NN2:   *o_ptr = '\0';
       scan_blanks(fp);
       TCO(NB1,')');
       curr_proc = &proc_tab[proc_cnt];
       printf(" Process: %s (%s)\n",curr_proc -> proc_name,
	  curr_proc -> comp_name);
NB1:   scan_blanks(fp);
       TCO(NQ1,'?');
       proc_tab[proc_cnt].trace = 1;

NQ1:   scan_blanks(fp);
       TCO(NSC1,';');
       cnxt_tab[cnxt_count].upstream_name[0] = '\0';
       cnxt_count++;
       proc_count++;
       proc_count++;
       label_count++;
       goto netloop;
NSC1:  TCO(NC1,',');
       goto loop;

NC1:   strcpy(cnxt_tab[cnxt_count].upstream_name,out_str);
       o_ptr = out_str;
X2:    TC(X2a,'*');     /* automatic port */
       *o_ptr = '\0';
       goto is_inport;
X2a:   if (scan_sym(fp, o_ptr) != 0) {
	  printf("Upstream port name error for %s\n",
	    cnxt_tab[cnxt_count].upstream_name);
	  ret_code = 4;
          goto exit;  }
is_inport:
       strcpy(cnxt_tab[cnxt_count].upstream_port_name,out_str);


       scan_blanks(fp);
       cnxt_tab[cnxt_count].upstream_elem_no = 0;
       TCO(tArrow,'[');
       o_ptr = out_num;
GNx:   TN(NNx);
       goto GNx;
NNx:   TCO(elemerr,']');
       *o_ptr = '\0';
       cnxt_tab[cnxt_count].upstream_elem_no = atoi(out_num);
       scan_blanks(fp);

tArrow: eq_arrow = FALSE;
       TCO(tEq,'-');
       goto tGr;
tEq:   TCO(nArrow,'=');
       eq_arrow = TRUE;
tGr:   TCO(nArrow,'>');

       cnxt_tab[cnxt_count].capacity = -1;
       scan_blanks(fp);
       TCO(ncap,'(');
       o_ptr = out_num;
GNz:   TN(NNz);
       goto GNz;
NNz:   TCO(caperr,')');
       *o_ptr = '\0';
       cnxt_tab[cnxt_count].capacity = atoi(out_num);
       scan_blanks(fp);
       goto ncap;
caperr: printf("Capacity error\n");
       ret_code = 4;
       goto exit;
ncap:  cnxt_tab[cnxt_count].downstream_elem_no = 0;

/* Scan off downstream port name */
       o_ptr = out_str;
       TC(Y2a,'*');       /* automatic port */
       *o_ptr = '\0';
       goto is_outport;
Y2a:   if (scan_sym(fp, o_ptr) != 0) {
	  printf("Downstream port name error for %s %s\n",
	  cnxt_tab[cnxt_count].upstream_name,
	  cnxt_tab[cnxt_count].upstream_port_name);
	  ret_code = 4;
          goto exit;  }
is_outport:
       strcpy(cnxt_tab[cnxt_count].downstream_port_name,out_str);
       strcpy(cnxt_tab[cnxt_count].downstream_name, "*");  /* ext. conn */
       cnxt_open = TRUE;

       scan_blanks(fp);
       TCO(CSC2,'[');
       o_ptr = out_num;
GNy:   TN(NNy);
       goto GNy;
NNy:   TCO(elemerr,']');
       *o_ptr = '\0';
       cnxt_tab[cnxt_count].downstream_elem_no = atoi(out_num);

CSC2:  scan_blanks(fp);
       TCO(NSC2,';');
       if (!eq_arrow)
	  printf("Port name %s not an external port\n", out_str);
       curr_cnxt = &cnxt_tab[cnxt_count];
       if (curr_cnxt -> upstream_name[0] != '!')
             printf(" Connection: %s %s[%d] -> %s[%d] %s\n",
	     curr_cnxt -> upstream_name,
	     curr_cnxt -> upstream_port_name,
	     curr_cnxt -> upstream_elem_no,
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
	   else {
             printf(" IIP: -> %s[%d] %s\n",
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
             IIP_ptr = curr_cnxt -> gen.IIPptr;
             printf("    \'");
             for (i = 0; i < IIP_ptr -> IIP_len; i++)
	          printf("%c",IIP_ptr -> datapart[i]);
             printf("\'\n");
             }


       cnxt_count++;
       cnxt_tab[cnxt_count].upstream_name[0] = '\0';
       cnxt_count++;
       proc_count++;
       proc_count++;
       label_count++;
       goto netloop;

NSC2:  TCO(loop,',');

       if (!eq_arrow)
	  printf("Port name %s not an external port\n", out_str);
       curr_cnxt = &cnxt_tab[cnxt_count];
       if (curr_cnxt -> upstream_name[0] != '!')
             printf(" Connection: %s %s[%d] -> %s[%d] %s\n",
	     curr_cnxt -> upstream_name,
	     curr_cnxt -> upstream_port_name,
	     curr_cnxt -> upstream_elem_no,
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
	   else {
             printf(" IIP: -> %s[%d] %s\n",
	     curr_cnxt -> downstream_port_name,
	     curr_cnxt -> downstream_elem_no,
	     curr_cnxt -> downstream_name);
             IIP_ptr = curr_cnxt -> gen.IIPptr;
             printf("    \'");
             for (i = 0; i < IIP_ptr -> IIP_len; i++)
	          printf("%c",IIP_ptr -> datapart[i]);
             printf("\'\n");
             }


       cnxt_count++;
       cnxt_open = FALSE;
       goto loop;

elemerr: printf("Port element error\n");
       ret_code = 4;
       goto exit;

nArrow: printf("No arrow found\n");
       ret_code = 4;
exit:
   if (fclose(fp) != 0) {
         printf("Close error\n");
         if (ret_code == 0)
            ret_code = 2;
	 }
       if (ret_code > 0) {
          printf("Scan error\n");
          return(ret_code);
          }

         proc_last = proc_count;
         for (i = proc_hold; i < proc_last; i++) {
	  curr_proc = &proc_tab[i];
	  if (curr_proc -> proc_name[0] == '\0') continue;
         label_ct = find_label(label_tab, curr_proc -> comp_name, file_name, label_count);
          curr_proc -> composite = (label_ct > 0);
          if (curr_proc -> composite)
             curr_proc -> label_count = label_ct;
           else {
            strcpy(fname, curr_proc -> comp_name);
            if ((fp2 = fopen(strcat(fname, ".net"),"r"))
                   != NULL) {
                 label_ct = label_count;
                 strcpy(fname, curr_proc -> comp_name);
	         thxscan(fp2, cnxt_tab, proc_tab, label_tab, fname,
                    &label_count, &proc_count, &cnxt_count);
                 fclose(fp2);
                 curr_proc -> composite = TRUE;
                 curr_proc -> label_count = label_ct;
                 }
                else {
                   curr_proc -> must_run =
                        (thxgatrs(curr_proc -> comp_name) > 0);
                   curr_proc -> composite = FALSE;
		   curr_proc -> faddr = 0;
                 }
	    }
          }
       *label_cp = label_count;
       *proc_cp = proc_count;
       *cnxt_cp = cnxt_count;
       printf("Scan finished\n");
       return (ret_code);
    }
Пример #15
0
int thxscan(FILE *fp, label_ent *label_tab, char file_name[10])
{
	char *o_ptr;
	char out_str[255];
	//char fname[256];
	char out_num[8];
	size_t i, IIPlen, ret_code;
	char upstream_name[255];	
	char upstream_port_name[255];
	int upstream_elem_no;
	char procname[255];	


	proc_ent *proc_curr;
	//	proc_ent *proc_new;
	//	proc_ent *proc_find;
	cnxt_ent *cnxt_tab;
	cnxt_ent *cnxt_curr;
	cnxt_ent *cnxt_new;
	cnxt_ent *cnxt_hold;

//	label_ent *label_new;

	//int label_ct;
	bool eq_arrow;
	IIP *IIP_ptr;

	char buffer[100];

	while (true) {
		if (NULL == fgets(buffer, 100, fp))
			goto finish;
		if (0 == strcmp(buffer, "INPORT") || 0 == strcmp(buffer, "OUTPORT"))
			continue;

		ret_code = 0;

		curr_char = getc(fp);
		proc_tab = 0;
		cnxt_tab = 0;
		label_curr = label_tab;

		strcpy_s(label_curr->label, " ");
		strcpy_s(label_curr->file, file_name);
		label_curr->ent_type = 'L';

		IIPlen = -1;
		out_num[0] = '\0';
		cnxt_hold = 0;

		scan_blanks(fp);

	netloop:
		TCO(X0, '\'');
		goto Xs;       // quote found - scan off rest of IIP
	X0:
		if (scan_sym(fp, out_str) != 0) {  // this could be a network label or a process name...
			printf("Name error\n");
			ret_code = 4;
			goto exit;
		}

		TCO(X2, ':');
		strcpy_s(label_curr->label, out_str);  // it was a label		  
		printf("Scanning Network: %s\n", out_str);
		scan_blanks(fp);

	bigloop:

		cnxt_hold = 0;
		IIPlen = -1;
		TCO(X1, '\'');
	Xs:
		o_ptr = out_str;
		goto get_rest_of_IIP;

	X1:
		if (scan_sym(fp, out_str) != 0) {  // this must be a process name...
			printf("Name error\n");
			ret_code = 4;
			goto exit;
		}
	X2:
		strcpy_s(procname, out_str);
		printf("Procname: %s\n", procname);
		if (cnxt_hold != 0) {
			strcpy_s(cnxt_hold->downstream_name, procname);
			cnxt_hold = 0;
		}

		proc_curr = find_or_build_proc(procname);

		if (4 == scan_blanks(fp))
			goto bigloop;

		goto X3;

	get_rest_of_IIP:
		TCO(tbsl, EOF);
		printf("EOF encountered within quoted string\n");
		ret_code = 4;
		goto exit;
	tbsl:
		TCO(tbq, '\\');
		CC;
		goto get_rest_of_IIP;
	tbq:
		TCO(copy, '\'');
		goto NQ2;
	copy:
		CC;
		goto get_rest_of_IIP;
	NQ2:
		*o_ptr = '\0';
		IIPlen = static_cast<int>(o_ptr - out_str);
		IIP_ptr = (IIP *)malloc(IIPlen + 1);
		memcpy(IIP_ptr->datapart, out_str, IIPlen);
		IIP_ptr->datapart[IIPlen] = '\0';
		printf("IIP: %s\n", IIP_ptr->datapart);
		scan_blanks(fp);
		//IIPlen = -1;
		goto tArrow;


		// scan off process name with optional component name

	X3:
		TCO(NB1, '(');
		scan_blanks(fp);
		TCO(rest_of_comp, ')');
		goto NN2;
	rest_of_comp:

		TCO(NQ6, '"');           // this says that comp name may be surrounded by double quotes (not included in comp_name)
	NQ6:
		o_ptr = comp_name;      // if no data between brackets, comp_name will not be modified...

	TB1:
		TCO(NQ7, '"');
		scan_blanks(fp);

	NQ7:
		TCO(NB2, ')');
		goto NN2;
	NB2:
		CC;
		goto TB1;

	NN2:
		*o_ptr = '\0';

		if (strlen(comp_name) > 0) {
			strcpy_s(proc_curr->comp_name, comp_name);
			printf("Comp name: %s\n", comp_name);
		}

	NB1:
		// comp scanned off, if any
		strcpy_s(upstream_name, procname);	    // in case this proc is the upstream of another arrow

		if (4 == scan_blanks(fp))
			goto bigloop;

		TCO(NQ1, '?');
		proc_curr->trace = 1;
		if (4 == scan_blanks(fp))
			goto bigloop;
	NQ1:

		TCO(tsc, EOF);
		eof_found = TRUE;
		goto nxtnet;

	tsc:
		TCO(tcom, ';');
		scan_blanks(fp);
	nxtnet:
		// this is a fudge because multiple nets are not currently supported 
		IIPlen = -1;

		TCO(nextnet, EOF);
		goto exit;

	tcom:

		IIPlen = -1;
		TCO(not_com, ',');

		scan_blanks(fp);
		goto bigloop;

	not_com:

		o_ptr = out_str;
		TC(outport, '*');     /* automatic port */
		*o_ptr = '\0';

		goto GUy;

	outport:
		if (scan_sym(fp, out_str) != 0) {
			printf("Name error\n");
			ret_code = 4;
			goto exit;
		}
	GUy:
		scan_blanks(fp);

		strcpy_s(upstream_port_name, out_str);
		printf("Upstream port: %s\n", out_str);
		upstream_elem_no = 0;
		TCO(tArrow, '[');
		o_ptr = out_num;
	GNx:
		TN(NNx);
		goto GNx;
	NNx:
		TCO(elemerr, ']');
		*o_ptr = '\0';
		upstream_elem_no = atoi(out_num);

	tArrow:
		scan_blanks(fp);
		eq_arrow = FALSE;
		TCO(tEq, '-');
		goto tGr;
	tEq:
		TCO(nArrow, '=');
		eq_arrow = TRUE;
	tGr:
		TCO(nArrow, '>');
		printf("Arrow\n");
		cnxt_new = (cnxt_ent *)malloc(sizeof(cnxt_ent));
		cnxt_new->succ = 0;
		cnxt_new->dropOldest = false;
		if (cnxt_tab == 0) {
			cnxt_tab = cnxt_new;
			label_curr->cnxt_ptr = cnxt_tab;
			cnxt_curr = cnxt_tab;
		}
		else {
			cnxt_curr->succ = cnxt_new;
			cnxt_curr = cnxt_new;
		}

		cnxt_hold = cnxt_new;
		if (IIPlen != -1) {
			strcpy_s(cnxt_hold->upstream_name, "!");
			cnxt_hold->upstream_port_name[0] = '\0';
			cnxt_hold->gen.IIPptr = IIP_ptr;
		}
		else {
			strcpy_s(cnxt_hold->upstream_name, upstream_name);
			strcpy_s(cnxt_hold->upstream_port_name, upstream_port_name);

			cnxt_hold->upstream_elem_no = upstream_elem_no;
		}
		cnxt_hold->capacity = -1;
		scan_blanks(fp);
		TCO(ncap, '(');
		o_ptr = out_num;
	GNz:
		TN(NNz);
		goto GNz;
	NNz:
		TCO(caperr, ')');
		*o_ptr = '\0';
		cnxt_hold->capacity = atoi(out_num);
		scan_blanks(fp);
		goto ncap;
	caperr:
		printf("Capacity error\n");
		ret_code = 4;
		goto exit;
	ncap:
		cnxt_hold->downstream_elem_no = 0;

		/* Scan off downstream port name */
		o_ptr = out_str;
		TC(Y2a, '*');       /* automatic port */
		*o_ptr = '\0';
		strcpy_s(cnxt_hold->downstream_port_name, out_str);  /* ext. conn */
		goto is_outport;
	Y2a:
		if (scan_sym(fp, out_str) != 0) {
			printf("Downstream port name error for %s %s\n",
				cnxt_hold->upstream_name,
				cnxt_hold->upstream_port_name);
			ret_code = 4;
			goto exit;
		}
		strcpy_s(cnxt_hold->downstream_port_name, out_str);

	is_outport:

		printf("Downstream port: %s\n", cnxt_hold->downstream_port_name);

		scan_blanks(fp);
		TCO(X1, '[');
		o_ptr = out_num;
	GNy:
		TN(NNy);
		goto GNy;
	NNy:
		TCO(elemerr, ']');
		*o_ptr = '\0';
		cnxt_hold->downstream_elem_no = atoi(out_num);
		//cnxt_hold = 0;
		scan_blanks(fp);
		goto X1;

	nextnet:
		scan_blanks(fp);

		if (eof_found) {
			label_curr->succ = 0;   // temporary fix as we are only generating one network for now
			goto exit;
		}

		goto netloop;


	elemerr:
		printf("Port element error\n");
		ret_code = 4;
		goto exit;

	nArrow:
		printf("No arrow found\n");
		ret_code = 4;
	exit:
		printf("\nSummary:\n");
		proc_curr = proc_tab;
		while (proc_curr != 0) {
			printf(" Process: %s (%s)\n", proc_curr->proc_name,
				proc_curr->comp_name);
			proc_curr = proc_curr->succ;
		}

		cnxt_hold = cnxt_tab;
		while (cnxt_hold != 0) {
			char up[200];
			char down[200];
			char elem[20];
			if (cnxt_hold->upstream_name[0] != '!') {
				strcpy_s(up, cnxt_hold->upstream_port_name);
				if (up[0] != '*') {
					strcat_s(up, "[");
					_itoa_s(cnxt_hold->upstream_elem_no, elem, 10);
					strcat_s(up, elem);
					strcat_s(up, "]");
				}
				strcpy_s(down, cnxt_hold->downstream_port_name);
				if (down[0] != '*') {
					strcat_s(down, "[");
					_itoa_s(cnxt_hold->downstream_elem_no, elem, 10);
					strcat_s(down, elem);
					strcat_s(down, "]");
				}
				printf(" Connection: %s %s -> %s %s\n",
					cnxt_hold->upstream_name,
					up,
					down,
					cnxt_hold->downstream_name);
			}
			else {
				strcpy_s(down, cnxt_hold->downstream_port_name);
				if (down[0] != '*') {
					strcat_s(down, "[");
					_itoa_s(cnxt_hold->downstream_elem_no, elem, 10);
					strcat_s(down, elem);
					strcat_s(down, "]");
				}
				printf(" IIP: -> %s %s\n",
					down,
					cnxt_hold->downstream_name);
				IIP_ptr = cnxt_hold->gen.IIPptr;
				printf("    \'");
				auto j = strlen(IIP_ptr->datapart);
				for (i = 0; i < j; i++)
					printf("%c", IIP_ptr->datapart[i]);
				printf("\'\n");
			}
			cnxt_hold = cnxt_hold->succ;
		}
	 
	}
	finish:
	if (fclose(fp) != 0) {
		printf("Close error\n");
		if (ret_code == 0)
			ret_code = 2;
	}
	if (ret_code > 0) {
		// printf("Scan error\n");
		return(ret_code);
	}
	
	// printf("Scan finished\n");
	return (ret_code);
}
Пример #16
0
static const Type *getFullyQualifiedTemplateType(const ASTContext &Ctx,
                                                 const Type *TypePtr) {
  // DependentTemplateTypes exist within template declarations and
  // definitions. Therefore we shouldn't encounter them at the end of
  // a translation unit. If we do, the caller has made an error.
  assert(!isa<DependentTemplateSpecializationType>(TypePtr));
  // In case of template specializations, iterate over the arguments
  // and fully qualify them as well.
  if (const auto *TST = dyn_cast<const TemplateSpecializationType>(TypePtr)) {
    bool MightHaveChanged = false;
    SmallVector<TemplateArgument, 4> FQArgs;
    for (TemplateSpecializationType::iterator I = TST->begin(), E = TST->end();
         I != E; ++I) {
      // Cheap to copy and potentially modified by
      // getFullyQualifedTemplateArgument.
      TemplateArgument Arg(*I);
      MightHaveChanged |= getFullyQualifiedTemplateArgument(Ctx, Arg);
      FQArgs.push_back(Arg);
    }

    // If a fully qualified arg is different from the unqualified arg,
    // allocate new type in the AST.
    if (MightHaveChanged) {
      QualType QT = Ctx.getTemplateSpecializationType(
          TST->getTemplateName(), FQArgs.data(), FQArgs.size(),
          TST->getCanonicalTypeInternal());
      // getTemplateSpecializationType returns a fully qualified
      // version of the specialization itself, so no need to qualify
      // it.
      return QT.getTypePtr();
    }
  } else if (const auto *TSTRecord = dyn_cast<const RecordType>(TypePtr)) {
    // We are asked to fully qualify and we have a Record Type,
    // which can point to a template instantiation with no sugar in any of
    // its template argument, however we still need to fully qualify them.

    if (const auto *TSTDecl =
        dyn_cast<ClassTemplateSpecializationDecl>(TSTRecord->getDecl())) {
      const TemplateArgumentList &TemplateArgs = TSTDecl->getTemplateArgs();

      bool MightHaveChanged = false;
      SmallVector<TemplateArgument, 4> FQArgs;
      for (unsigned int I = 0, E = TemplateArgs.size(); I != E; ++I) {
        // cheap to copy and potentially modified by
        // getFullyQualifedTemplateArgument
        TemplateArgument Arg(TemplateArgs[I]);
        MightHaveChanged |= getFullyQualifiedTemplateArgument(Ctx, Arg);
        FQArgs.push_back(Arg);
      }

      // If a fully qualified arg is different from the unqualified arg,
      // allocate new type in the AST.
      if (MightHaveChanged) {
        TemplateName TN(TSTDecl->getSpecializedTemplate());
        QualType QT = Ctx.getTemplateSpecializationType(
            TN, FQArgs.data(), FQArgs.size(),
            TSTRecord->getCanonicalTypeInternal());
        // getTemplateSpecializationType returns a fully qualified
        // version of the specialization itself, so no need to qualify
        // it.
        return QT.getTypePtr();
      }
    }
  }
  return TypePtr;
}
Пример #17
0
void PDCHL1FEC::mchStop() {
	getRadio()->setSlot(TN(),Transceiver::I);
	mchOldFec->setGPRS(false,NULL);
}
Пример #18
0
// WARNING: This func runs in a separate thread.
void PDCHL1Uplink::writeLowSideRx(const RxBurst &inBurst)
{
	float low, avg = inBurst.getEnergy(&low);
	//if (avg > 0.7) { OBJLOG(DEBUG) << "PDCHL1Uplink " << inBurst; }

	//ScopedLock lock(testlock);
	int burstfn = inBurst.time().FN();
	int mfn = (burstfn / 13);			// how many 13-multiframes
	int rem = (burstfn - (mfn*13));	// how many blocks within the last multiframe.
	int B = rem % 4;

	if (avg > 0.5) { GPRSLOG(256) << "FEC:"<<LOGVAR(B)<<" "<<inBurst<<LOGVAR(avg); }

	ChannelCodingType cc;
	BitVector *result = decodeLowSide(inBurst,B,mchCS14Dec,&cc);

	if (B == 3) {
		int burst_fn=burstfn-3;	// First fn in rlc block.
		RLCBSN_t bsn = FrameNumber2BSN(burst_fn);

		if (GPRSDebug) {
			PDCHL1FEC *pdch = parent();
			short *qbits = mchCS14Dec.qbits;
			BitVector cshead(mchCS14Dec.mC.head(12).sliced());

			RLCBlockReservation *res = mchParent->getReservation(bsn);
			int thisUsf = pdch->getUsf(bsn-2);
			// If we miss a reservation or usf, print it:
			int missedRes = avg>0.4 && !result && (res||thisUsf);
			if (missedRes || (GPRSDebug & (result?4:256))) {
				std::ostringstream ss;
				char buf[30];
			 	ss <<"writeLowSideRx "<<parent()
					<<(result?" === good" : "=== bad")
					<< (res?" res:" : "") <<(res ? res->str() : "")
					//<<LOGVAR(cshead)
					//<<LOGVAR2("cs",(int)mchCS14Dec.getCS())
					<<LOGVAR(cc)
					<<LOGVAR2("revusf",decodeUSF(mchCS14Dec.mC))
					<<LOGVAR(burst_fn)<<LOGVAR(bsn) 
					<<LOGVAR2("RSSI",inBurst.RSSI()) <<LOGVAR2("TE",inBurst.timingError())
					// But lets print out the USFs bracketing this on either side.
					<<getAnsweringUsfText(buf,bsn)
					//<<" AnsweringUsf="<<pdch->getUsf(bsn-2)<<" "<<pdch->getUsf(bsn-1)
					//<<" ["<<pdch->getUsf(bsn)<<"] "<<pdch->getUsf(bsn+1)<<" "<<pdch->getUsf(bsn+2)
					<<" qbits="<<qbits[0]<<qbits[1]<<qbits[2]<<qbits[3]
							   <<qbits[4]<<qbits[5]<<qbits[6]<<qbits[7]
					<<LOGVAR(low)<<LOGVAR(avg)
					;
				if (missedRes) {
					for (int i = 0; i < 4; i++) {
						// There was an unanswered reservation or usf.
						avg = mchCS14Dec.mI[i].getEnergy(&low);
						GPRSLOG(1) << "energy["<<i<<"]:"<<LOGVAR(avg)<<LOGVAR(low)<<" "
							<<mchCS14Dec.mI[i];
					}
				}
				GLOG(DEBUG)<<ss.str();
				// Make sure we see a decoder failure if it reoccurs.
				if (missedRes) std::cout <<ss.str() <<"\n";
			}
		} // if GPRSDebug

		if (result) {
			// Check clock skew for debugging purposes.
			static int cnt = 0;
			if (bsn >= gBSNNext-1) {
				if (cnt++ % 32 == 0) {
					GLOG(ERR) << "Incoming burst at frame:"<<burst_fn
						<<" is not sufficiently ahead of clock:"<<gBSNNext.FN();
					if (GPRSDebug) {
					std::cout << "Incoming burst at frame:"<<burst_fn
						<<" is not sufficiently ahead of clock:"<<gBSNNext.FN()<<"\n";
					}
				}
			}

			countGoodFrame();

			// The four frame radio block has been decoded and is in mD.
			if (gConfig.getBool("Control.GSMTAP.GPRS")) {
				// Send to GSMTAP.  Untested.
				gWriteGSMTAP(ARFCN(),TN(),gBSNNext.FN(), //GSM::TDMA_PACCH,
						frame2GsmTapType(*result),
						false,	// not SACCH
						true,	// this is an uplink.
						*result);	// The data.
			}

			mchUplinkData.write(new RLCRawBlock(bsn,*result,inBurst.RSSI(),inBurst.timingError(),cc));
		} else {
			countBadFrame();
		}
	} else {
		// We dont have a full 4 bursts yet, and we rarely care about these
		// intermediate results, but here is a way to see them:
		GPRSLOG(64) <<"writeLowSideRx "<<parent()<<LOGVAR(burstfn)<<LOGVAR(B) 
			<<" RSSI=" <<inBurst.RSSI() << " timing=" << inBurst.timingError();
	}
}