コード例 #1
0
ファイル: sandy-bridge.c プロジェクト: bldewolf/mcelog
void snb_decode_model(int cputype, int bank, u64 status, u64 misc)
{
    switch (bank) {
    case 4:
        Wprintf("PCU: ");
        decode_bitfield(status, pcu_mc4);
        Wprintf("\n");
        break;
    case 6:
    case 7:
        if (cputype == CPU_SANDY_BRIDGE_EP) {
            /* MCACOD already decoded */
            Wprintf("QPI\n");
        }
        break;
    }
}
コード例 #2
0
ファイル: broadwell_de.c プロジェクト: andikleen/mcelog
void bdw_de_decode_model(int cputype, int bank, u64 status, u64 misc)
{
	switch (bank) {
	case 4:
		Wprintf("PCU: ");
		switch (EXTRACT(status, 0, 15) & ~(1ull << 12)) {
		case 0x402: case 0x403:
			Wprintf("Internal errors ");
			break;
		case 0x406:
			Wprintf("Intel TXT errors ");
			break;
		case 0x407:
			Wprintf("Other UBOX Internal errors ");
			break;
		}
		if (EXTRACT(status, 16, 19) & 3)
			Wprintf("PCU internal error ");
		if (EXTRACT(status, 20, 23) & 4)
			Wprintf("Ubox error ");
		decode_bitfield(status, pcu_mc4);
		break;
	case 9: case 10:
		Wprintf("MemCtrl: ");
		decode_bitfield(status, memctrl_mc9);
		break;
	}
}
コード例 #3
0
ファイル: keybindings.cpp プロジェクト: drfiemost/xcircuit-qt
void remove_keybinding(Widget window, const char *keystring, const char *fstring)
{
   int function = string_to_func(fstring, NULL);
   int keywstate = string_to_key(keystring);

   if ((function < 0) || (remove_binding(window, keywstate, function) < 0)) {
      Wprintf("Key binding \'%s\' to \'%s\' does not exist in list.",
		keystring, fstring);
   }
}
コード例 #4
0
ファイル: ivy-bridge.c プロジェクト: VertiPub/mcelog
void ivb_decode_model(int cputype, int bank, u64 status, u64 misc)
{
	switch (bank) {
	case 4:
		Wprintf("PCU: ");
		decode_bitfield(status, pcu_mc4);
		Wprintf("\n");
		break;
	case 5:
		if (cputype == CPU_IVY_BRIDGE_EPEX) {
			/* MCACOD already decoded */
			Wprintf("QPI\n");
		}
		break;
	case 9: case 10: case 11: case 12:
	case 13: case 14: case 15: case 16:
		Wprintf("MemCtrl: ");
		decode_bitfield(status, memctrl_mc9);
		Wprintf("\n");
		break;
	}
}
コード例 #5
0
ファイル: skylake_xeon.c プロジェクト: andikleen/mcelog
void skylake_s_decode_model(int cputype, int bank, u64 status, u64 misc)
{
	switch (bank) {
	case 4:
		Wprintf("PCU: ");
		switch (EXTRACT(status, 0, 15) & ~(1ull << 12)) {
		case 0x402: case 0x403:
			Wprintf("Internal errors ");
			break;
		case 0x406:
			Wprintf("Intel TXT errors ");
			break;
		case 0x407:
			Wprintf("Other UBOX Internal errors ");
			break;
		}
		if (EXTRACT(status, 16, 19))
			Wprintf("PCU internal error ");
		decode_bitfield(status, pcu_mc4);
		break;
	case 5:
	case 12:
	case 19:
		Wprintf("UPI: ");
		decode_bitfield(status, upi_mc);
		if (EXTRACT(status, 16, 21) == 0x12)
			decode_bitfield(status, upi_0x12);
		break;
	case 7: case 8:
		Wprintf("M2M: ");
		decode_bitfield(status, m2m);
		break;
	case 13: case 14: case 15:
	case 16: case 17: case 18:
		Wprintf("MemCtrl: ");
		if (EXTRACT(status, 27, 27))
			decode_bitfield(status, memctrl_mc13);
		else
			decode_bitfield(status, mc_bits);
		break;
	}
}
コード例 #6
0
ファイル: formats.c プロジェクト: sedic/xcircuit-3.8
void loadlgf(int mode)
{
   FILE *ps;
   char inname[150], temp[500], *pdchar;
   char **signals;
   short *signets;
   objectptr *libobj;
   genericptr *iolabel;
   int i, sigs;

   sscanf(_STR, "%149s", inname);

   ps = fopen(inname, "r");
   if (ps == NULL) {
      sprintf(inname, "%s.lgf", _STR);
      ps = fopen(inname, "r");
      if (ps == NULL) {
	 sprintf(inname, "%s.lfo", _STR);
	 ps = fopen(inname, "r");
	 if (ps == NULL) {
	    Wprintf("Can't open LGF file %s", inname);
	    return;
         }
      }
   }

   /* for PostScript file, remove ".lgf" or ".lfo" (to be replaced with ".ps") */

   if ((pdchar = strstr(inname, ".l")) != NULL) *pdchar = '\0';

   Wprintf("Loaded file: %s", inname);

   /* Make sure that LGF object library has been loaded by loading it now. */

   if (NameToLibrary(LGF_LIB) < 0) {
      int ilib;
      strcpy(_STR, LGF_LIB);
      ilib = createlibrary(FALSE);
      loadlibrary(ilib);
   }
   
   /* Read header information */

   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   for (pdchar = temp; *pdchar != '-' && *pdchar != '\n'; pdchar++);
   if (*pdchar == '\n') {
      Wprintf("Not an LGF file?");
      return;
   }
   if (*(++pdchar) != '5') {
      Wprintf("Don't know how to read version %c.", *pdchar);
      return;
   }
   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   for (pdchar = temp; *pdchar != 'f' && *pdchar != '\n'; pdchar++);
   for (; *pdchar != 's' && *pdchar != '\n'; pdchar++);
   if (*pdchar == '\n') {
      Wprintf("Something wrong with the LGF file?");
      return;
   }

   /* Done with header. . . okay to clear current page now unless importing */

   if (mode == 0) {
      reset(topobject, NORMAL);
      pagereset(areawin->page); 
   }

   /* Set up filename and object (page) name */

   xobjs.pagelist[areawin->page]->filename = (char *) realloc (
      xobjs.pagelist[areawin->page]->filename, (strlen(inname) + 1) * sizeof(char));
   strcpy(xobjs.pagelist[areawin->page]->filename, inname);

   /* If the filename has a path component, use only the root */

   if ((pdchar = strrchr(inname, '/')) != NULL)
      sprintf(topobject->name, "%s", pdchar + 1);
   else
      sprintf(topobject->name, "%s", inname);

   renamepage(areawin->page);
   printname(topobject);

   /* Read objects */

   for(;;) {
      char *lineptr, keyptr, tmpstring[256];
      int dval;
      short pvalx, pvaly, pvalx2, pvaly2;

      if (fgets(temp, 499, ps) == NULL) break;		/* End-Of-File */

      /* ignore whitespace */
      for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
      if (*lineptr == '\n') continue;  /* ignore blank lines */
      switch(keyptr = *lineptr) {

	 case '#':	/* comment */
	    break;

	 case 'n':	/* nodes */
	    sscanf(++lineptr, "%d", &dval); 	    
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in node section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	    }
	    break;

	 case 's': 	/* signal names --- save for future reference */

	    sscanf(++lineptr, "%d", &sigs);
	    signals = (char **) malloc(sigs * sizeof(char *));
	    signets = (short *) malloc(sigs * sizeof(short));
	    for (i = 0; i < sigs; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in signal section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	       
	       sscanf(lineptr, "%hd %249s", &signets[i], tmpstring);

	       signals[i] = (char *)malloc((strlen(tmpstring) + 1) * sizeof(char));
	       sprintf(signals[i], "%s", tmpstring);
            }
	    break;
	 
	 case 'l': {	/* labels */

	    labelptr *newlabel;
	    char *tstrp;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in signal section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');
	       
	       /* Allocate label, and put node number into X value, to be replaced */
	       /* Flag it using an inappropriate rotation value (= 500) */

	       sscanf(lineptr, "%hd %hd", &pvalx, &pvaly);

	       /* Get rid of newline character, if any */

	       ridnewline(lineptr);

	       /* forward to the label part of the input line */

	       tstrp = lineptr - 1;
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));
	       while (isdigit(*(++tstrp)));
	       while (isspace(*(++tstrp)));

	       if (tstrp != NULL) {	/* could be a blank line */
		  stringpart *strptr;

		  NEW_LABEL(newlabel, topobject);

		  labeldefaults(*newlabel, False, xmat(pvalx), ymat(pvaly));
	          (*newlabel)->justify = TOP | NOTBOTTOM;
		  (*newlabel)->color = DEFAULTCOLOR;
		  (*newlabel)->string->data.font = 0;
		  strptr = makesegment(&((*newlabel)->string), NULL);
		  strptr->type = TEXT_STRING;
		  strptr->data.string = (char *)malloc(1 + strlen(tstrp));
		  strcpy(strptr->data.string, tstrp);
		  (*newlabel)->pin = NORMAL;
	       }
            }}
	    break;

	case 'w': {	/* wires, implemented as single-segment polygons */
	    polyptr *newwire;
	    XPoint  *tmppnts;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in wire section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* Allocate wire */

	       NEW_POLY(newwire, topobject);

	       sscanf(lineptr, "%hd %hd %hd %hd", &pvalx, &pvaly, &pvalx2, &pvaly2);
	       (*newwire)->number = 2;
	       (*newwire)->points = (XPoint *)malloc(2 * sizeof(XPoint));
	       (*newwire)->width = 1.0;
	       (*newwire)->style = UNCLOSED;
	       (*newwire)->color = DEFAULTCOLOR;
	       (*newwire)->passed = NULL;
	       tmppnts = (*newwire)->points;
	       tmppnts->x = xmat(pvalx);
	       tmppnts->y = ymat(pvaly);
	       (++tmppnts)->x = xmat(pvalx2);
	       tmppnts->y = ymat(pvaly2);

	    }}
	    break;

	case 'p': 	/* solder dot */
	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in solder dot section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* Allocate arc */

	       sscanf(lineptr, "%hd %hd", &pvalx, &pvaly);
	       drawdot(xmat(pvalx), ymat(pvaly));
	    }
	    break;

	case 'b': {	/* boxes */
	    polyptr *newpoly;
	    pointlist newpoints;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in box section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       NEW_POLY(newpoly, topobject);

	       (*newpoly)->style = DASHED;
	       (*newpoly)->color = DEFAULTCOLOR;
	       (*newpoly)->width = 1.0;
	       (*newpoly)->number = 4;
               (*newpoly)->points = (pointlist) malloc(4 * sizeof(XPoint));
	       (*newpoly)->passed = NULL;

               newpoints = (*newpoly)->points;
	       sscanf(lineptr, "%hd %hd %hd %hd", &pvalx, &pvaly, &pvalx2, &pvaly2);
	       newpoints->x = xmat(pvalx);
	       newpoints->y = ymat(pvaly);
	       (newpoints + 1)->x = xmat(pvalx2);
	       (newpoints + 2)->y = ymat(pvaly2);

	       (newpoints + 2)->x = (newpoints + 1)->x;
	       (newpoints + 3)->x = newpoints->x;
	       (newpoints + 1)->y = newpoints->y;
	       (newpoints + 3)->y = (newpoints + 2)->y;
	    }}
	    break;

	case 'g': {	/* gates */

	    objinstptr *newinst;
	    labelptr *newlabel;
	    int j, k, hval, flip;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in gates section");
		     return;
	          }
		  for (lineptr = temp; *lineptr != '\n'; lineptr++); *lineptr = '\0';
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\0'; lineptr++);
	       } while (*lineptr == '\0');

	       /* double loop through user libraries */

	       for (j = 0; j < xobjs.numlibs; j++) {
		  for (k = 0; k < xobjs.userlibs[j].number; k++) {
		     libobj = xobjs.userlibs[j].library + k;
	             if (!strcmp(lineptr, (*libobj)->name)) break;
		  }
	          if (k < xobjs.userlibs[j].number) break;
	       }
	       strcpy(tmpstring, lineptr);

	       /* read gate definition */

	       if (fgets(temp, 499, ps) == NULL) {
		  Wprintf("End of file during gate read");
		  return;
	       }
      	       for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);

	       if (j < xobjs.numlibs || k < xobjs.userlibs[xobjs.numlibs - 1].number) {

		  NEW_OBJINST(newinst, topobject);

	          sscanf(lineptr, "%hd %hd %hd %*d %*d %*d %d", &pvalx, &pvaly,
			&pvalx2, &hval); 

		  flip = (pvalx2 >= 4) ? 1 : 0;
		  if (!strcmp(tmpstring, "FROM")) flip = 1 - flip;

		  (*newinst)->position.x = xmat(pvalx);
		  (*newinst)->position.y = ymat(pvaly);
		  (*newinst)->scale = 1.0;
		  (*newinst)->color = DEFAULTCOLOR;
		  (*newinst)->params = NULL;
	          (*newinst)->passed = NULL;

		  if (pvalx2 & 0x01) pvalx2 ^= 0x02;
                  if (pvalx2 >= 4) (*newinst)->rotation = -(((pvalx2 - 4) * 90) + 1);
                  else (*newinst)->rotation = (pvalx2 * 90) + 1;
		  (*newinst)->thisobject = *libobj;
		  (*newinst)->bbox.lowerleft.x = (*libobj)->bbox.lowerleft.x;
		  (*newinst)->bbox.lowerleft.y = (*libobj)->bbox.lowerleft.y;
		  (*newinst)->bbox.width = (*libobj)->bbox.width;
		  (*newinst)->bbox.height = (*libobj)->bbox.height;

	          /* Add label to "TO" and "FROM" */

	          if (!strcmp(tmpstring, "FROM") || !strcmp(tmpstring, "TO")) {
	   	     int nval;

		     hval--;
		     fgets(temp, 499, ps);
		     sscanf(temp, "%d", &nval);

		     for (k = 0; k < sigs; k++)
		        if (signets[k] == nval) {
			   stringpart *strptr;

			   NEW_LABEL(newlabel, topobject);
			   /* reconnect newinst if displaced by realloc() */
			   newinst = (objinstptr *)(topobject->plist
				+ topobject->parts - 2);

			   labeldefaults(*newlabel, False, (*newinst)->position.x,
				(*newinst)->position.y);
			   (*newlabel)->color = DEFAULTCOLOR;
			   (*newlabel)->pin = LOCAL;
			   (*newlabel)->color = LOCALPINCOLOR;
			   if (!strcmp(tmpstring, "TO"))
			      (*newlabel)->position.x += ((flip) ? 48 : -48);
			   else
			      (*newlabel)->position.x += ((flip) ? 54 : -54);

			   (*newlabel)->justify = NOTBOTTOM;
			   if (flip) (*newlabel)->justify |= (RIGHT | NOTLEFT);
			   (*newlabel)->string->data.font = 0;
			   strptr = makesegment(&((*newlabel)->string), NULL);
			   strptr->type = TEXT_STRING;
			   strptr->data.string = (char *)malloc(1 + strlen(signals[k]));
			   strcpy(strptr->data.string, signals[k]);
			   break;
		        }
	          }
	       }

	       /* read through list of attributes */

	       else {
	          sscanf(lineptr, "%*d %*d %*d %*d %*d %*d %d", &hval);
	          Wprintf("No library object %s", tmpstring);
	       }

	       for (j = 0; j < hval + 1; j++) {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("Unexpected end of file");
		     return;
	          }
	       }
	       /* read to next blank line */
	       do {
		  if (fgets(temp, 499, ps) == NULL) break;
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr != '\n');
	    }}
	    break;

	case 'h': {	/* history */
	    int j, hval;

	    sscanf(++lineptr, "%d", &dval);
	    for (i = 0; i < dval; i++) {
	       do {
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("End of file in history section");
		     return;
	          }
      	          for (lineptr = temp; isspace(*lineptr) && *lineptr != '\n'; lineptr++);
	       } while (*lineptr == '\n');

	       /* read through history */

	       sscanf(lineptr, "%*d %d", &hval);
	       for (j = 0; j < hval; j++)
	          if (fgets(temp, 499, ps) == NULL) {
		     Wprintf("Unexpected end of file");
		     return;
	          }
	    }}
	    break;

	case '.':	/* blank, don't use for EOF */
	    break;

	default:
	    Wprintf("Don't understand statement '%c'", *lineptr);
	    break;
      }
   }

   /* check for unattached labels and delete them */

   for (iolabel = topobject->plist; iolabel < topobject->plist +
	   topobject->parts; iolabel++)
      if (IS_LABEL(*iolabel)) {
         if (TOLABEL(iolabel)->rotation == 500) {
	    genericptr *tmplabel;

	    free(TOLABEL(iolabel)->string);
	    free(*iolabel);
            for (tmplabel = iolabel + 1; tmplabel < topobject->plist +
                topobject->parts; tmplabel++) *(tmplabel - 1) = *tmplabel;
            topobject->parts--;
	    iolabel--;
	 }
      }

   calcbbox(areawin->topinstance);
   centerview(areawin->topinstance);

   for (i = 0; i < sigs; i++) free(signals[i]);
   free(signals);
   free(signets);
}
コード例 #7
0
ファイル: formats.c プロジェクト: sedic/xcircuit-3.8
void loadmat4(caddr_t nullval)
{
   char inname[150], *temp, *buffer, keyword[30], percentc, *pdchar;
   int bufsize = 256;
   short curcolor = DEFAULTCOLOR;
   char colorstr[100][5];
   short matcolors = 0;
   float curwidth = 1.0;
   int tmpstyle = UNCLOSED;

   sscanf(_STR, "%149s", inname);

   ps = fopen(inname, "r");
   if (ps == NULL) {
      sprintf(inname, "%s.ps", _STR);
      ps = fopen(inname, "r");
      if (ps == NULL) {
	 sprintf(inname, "%s.eps", _STR);
	 ps = fopen(inname, "r");
	 if (ps == NULL) {
	    Wprintf("Can't open Matlab PostScript file %s", inname);
	    return;
         }
      }
   }

   /* Keep same filename---overwriting file is end-user's own risk */

   if ((pdchar = strstr(_STR, ".ps")) != NULL) *pdchar = '\0';
   sprintf(topobject->name, "%s", _STR);
   Wprintf("Loaded file: %s", inname);
   renamepage(areawin->page);
   printname(topobject);

   /* Create input string buffer */

   buffer = (char *)malloc(bufsize * sizeof(char));
   temp = buffer;

   /* Read header information */

   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   if (*temp != '%' || *(temp + 1) != '!') {
      Wprintf("Not a PostScript file?");
      return;
   }
   if (fgets(temp, 149, ps) == NULL) {
      Wprintf("Error: end of file.");
      return;
   }
   if (!strstr(temp, "MATLAB")) {
      Wprintf("Not a Matlab PostScript file?");
      return;
   }

   /* Read through to Page start */

   do {
      if (fgets(temp, 149, ps) == NULL) {
         Wprintf("Error: no pages in input.");
         return;
      }
      if (strstr(temp, "%%Page:") != NULL) break;
   } while (1);

   /* Read objects */

   do {
      char *lineptr, keyptr;

      if (fgets(temp, 255, ps) == NULL) break;		/* End-Of-File */
      temp = buffer;

      /* scan from the end;  ignore blank lines. */

      for (lineptr = buffer; (*lineptr != '\n') && (*lineptr != '\0'); lineptr++);

      /* ignore any blank lines and PostScript comment lines */

      if (lineptr != buffer && *buffer != '%') {
         for (keyptr = lineptr - 1; isspace(*keyptr) && keyptr != buffer; keyptr--);
         for (; !isspace(*keyptr) && keyptr != buffer; keyptr--);
         sscanf(keyptr, "%29s", keyword);

	 if (!strcmp(keyword, "showpage")) {
            free(buffer);
            return False;  /* end of page */
         }

	 else if (!strcmp(keyword, "bdef")) {   /* new color definition */
	    char *bb;
	    float red, green, blue;
	    if ((bb = strchr(buffer, '{')) != NULL) {
	       sscanf(bb + 1, "%f %f %f", &red, &green, &blue);
	       curcolor = rgb_alloccolor((int)(red * 65535), (int)(green * 65535),
			(int)(blue * 65535));
	       addnewcolorentry(curcolor);	
	    }
	    if ((bb = strchr(buffer, '/')) != NULL) {
	       sscanf(bb, "%4s", &colorstr[matcolors]);
	       matcolors++;
	    }
	 } 

	 else if (!strcmp(keyword, "w")) {	/* linewidth */
	    float tmpwidth;
	    sscanf(buffer, "%f", &tmpwidth)
	 }
	 else if (!strcmp(keyword, "DO")) {	/* style */
	    tmpstyle = DOTTED | UNCLOSED;
	 }
	 else if (!strcmp(keyword, "SO")) {	/* style */
	    tmpstyle = UNCLOSED;
	 }
	 else if (!strcmp(keyword, "DA")) {	/* style */
	    tmpstyle = DASHED | UNCLOSED;
	 }
	 else if (!strcmp(keyword, "FMSR")) ;   /* ignore font spec for now */
	 else if (!strcmp(keyword, "j")) ;   /* ignore line join */
	 else if (!strcmp(keyword, "def")) ;   /* ignore */
	 else if (!strcmp(keyword, "dictionary")) ;   /* ignore */
	 else if (!strcmp(keyword, "np")) ;   /* ignore clip paths */
	 else {  /* continuation line ? */
	    for (lineptr = buffer; (*lineptr != '\n') && (*lineptr != '\0');
			lineptr++);
	    if (*lineptr == '\n') *lineptr = ' ';

	    bufsize = (int)(lineptr - buffer) + 256;
	    buffer = (char *)realloc(buffer, bufsize * sizeof(char));
	    temp = buffer + (bufsize - 256);
         }
      }
コード例 #8
0
bool DogStateCart3::check_valid_state() const
{
    const dTensorBC5& aux = *DogStateCart3::aux;
    const dTensorBC5& q = *DogStateCart3::q;
    const int mx   = q.getsize(1);
    const int my   = q.getsize(2);
    const int mz   = q.getsize(3);
    const int meqn = q.getsize(4);
    const int kmax = q.getsize(5);
    const int mbc  = q.getmbc();
    const int maux = aux.getsize(4);

    if(!debug_check_condition())
    {
        dprintf1("debug condition violated");
        return false;
    }

    bool okay=true;
    int bad_i=0, bad_j=0, bad_m=0, bad_k=0, bad_ell=0;

// TODO: it would be nice to only use a single pragma loop here  (-DS)
#pragma omp parallel for
    for (int i=1; i<=mx; i++)
        for (int j=1; j<=my; j++)
	  for (int k=1; k<=mz; k++)
            for (int m=1; m<=meqn; m++)
	      for (int ell=1; ell<=kmax; ell++)
                {
		  const double val = q.get(i,j,k,m,ell);
		  //assert_isfinite(val);
		  bool is_finite = val >= -DBL_MAX && val <= DBL_MAX;
		  if(!is_finite)
		    // a block preceeded by a critical directive
		    // of a given name can only be executed by a
		    // single thread at a time
		    // (omitting "(NaN)" would use default name)
#pragma omp critical (not_finite)
                    {
                        okay=false;
                        Wprintf("q(%d,%d,%d,%d) is not finite", i,j,k,m,ell);
                        bad_i = i;
                        bad_j = j;
			bad_k = k;
                        bad_m = m;
                        bad_ell = ell;
                    }
                }

    bool aux_okay = true;
    int aux_i=0, aux_j=0, aux_k=0, aux_m=0, aux_ell=0;
#pragma omp parallel for
    for (int i=1; i<=mx; i++)
        for (int j=1; j<=my; j++)
	  for (int k=1; k<=mz; k++)
            for (int m=1; m<=maux; m++)
	      for (int ell=1; ell<=kmax; ell++)
                {
		  const double val = aux.get(i,j,k,m,ell);
		  //assert_isfinite(val);
		  bool is_finite = val >= -DBL_MAX && val <= DBL_MAX;
		  if(!is_finite)
#pragma omp critical (not_finite)
                    {
		      aux_okay=false;
		      Wprintf("aux(%d,%d,%d,%d) is not finite", i,j,k,m,ell);
		      aux_i = i;
		      aux_j = j;
		      aux_k = k;
		      aux_m = m;
		      aux_ell = ell;
                    }
                }
    if(!okay || !aux_okay)
      {
        write_frame(9999,get_outputdir());
        if(!okay)
            errmsg_printf("at time %e q(%d,%d,%d,%d) is not finite", get_time(),
			  bad_i,bad_j,bad_k,bad_m,bad_ell);
        if(!aux_okay)
            errmsg_printf("at time %e aux(%d,%d,%d,%d) is not finite", get_time(),
			  aux_i,aux_j,aux_k,aux_m,aux_ell);
    }
    return true;
}
コード例 #9
0
ファイル: verb.cpp プロジェクト: Filosoft/vabamorf
int main(int argc, FSTCHAR **argv)
{
    CPFSFile infile;                   /*  viit sisendfailile  */
    CPFSFile outf, errf;              /*  viidad v@ljundfailidele */
    CPFSFile lgrf;                     /*  viit lõpugruppide failile LGR*/
    FSXSTRING inbuf;		/*  toodeldav rida  */
    FSXSTRING outbuf;		/*  toodeldav rida  */

    CFSFileName fn_0, fn_1, fn_2;
    int  total, converted, unknown;
    int  k;
    int kk, era;
    FSXSTRING inbuf_era, inbuf_para_ind;

    total = converted = unknown = 0;
    if (argc != 4)
        {
        printf("pane argumendid taha !\n");
        return EXIT_FAILURE;
        }
    else
        {
        fn_0=argv[1];
        fn_1=argv[2];
        fn_2=argv[3];
        }

    if (infile.Open(fn_0,      FSTSTR("rb" )) == false ||
        outf.Open( fn_1,       FSTSTR("wb" )) == false ||
        errf.Open( fn_2,       FSTSTR("wb" )) == false ||
        lgrf.Open( FSTSTR("lgr"), FSTSTR("ab+")) == false)
        {
        printf( "Can't open files\n" );
        return EXIT_FAILURE;
        }
    loe_lgr( &lgrf );            /* loe lõpugrupid mällu */
    tyvi[0].tyv = FSxSTR("");


    for (total=0; infile.ReadLine(&inbuf)==true; total++)
        {
        era = inbuf.Find(FSxSTR("**"));
        if (era != -1)
            {
            tyybinr = 1;    /* lihtsalt et poleks 0; vaja tee_rida() jaoks */
            k = inbuf.Find(FSWSTR("!\\"));
            if ( k == -1)       /* polegi indeksit; ei saa olla... */
                sliik = FSWSTR("V");
            else
                {
                sliik = (const FSWCHAR *)inbuf.Mid(k+2);
                k = sliik.Find(FSWSTR("\\"));
                if ( k == -1)
                    {
                    printf("\nsonaliik sassis ");
                    return EXIT_FAILURE;
                    }
                sliik = (const FSWCHAR *)sliik.Left(k);
                }
            k = verbera( &inbuf );
            if (!k)                           /* oli mingi viga */
                {
                unknown++;
                nullityv();            /* et saaks järgmist parad. teha */
                if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
                    {
                    printf("\ntulemuse kirjut. error-faili ebaõnnestus");
                    return EXIT_FAILURE;
                    }
                continue;          /* vt järgmisi ridu */
                }
            converted++;
            lisa_lgr( &lgrf );      /* leiab igale selle parad tyvele lgr nr */
            tee_rida(&inbuf, &outbuf);            /* teeb rea nr|tyvi,lgr/tyvi,lgr... */
            if ((outf.WriteString((const FSxCHAR *)outbuf, outbuf.GetLength())) == false)
                {
                printf("\ntulemuse kirjut. väljundfaili ebaõnnestus");
                return EXIT_FAILURE;
                }
            nullityv();            /* et saaks järgmist parad. teha */
            continue;              /* vt järgmist kirjet */
            }
        kk = inbuf.Find(FSxSTR("&&"));
        inbuf_para_ind = FSxSTR("");
        if (kk != -1)
            inbuf_para_ind = (const FSxCHAR *)inbuf.Mid(kk);
        inbuf = (const FSxCHAR *)inbuf.Left(inbuf.GetLength()-inbuf_para_ind.GetLength());
        k = era_ind( &inbuf );
        if (!k)                           /* oli mingi viga */
            {
            unknown++;
            if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
                {
                printf("\ntulemuse kirjut. error-faili ebaõnnestus");
                return EXIT_FAILURE;
                }
            continue;          /* vt järgmisi ridu */
            }
        k = era_tyvi( &inbuf );
        if (!k)                           /* oli mingi viga */
            {
            unknown++;
            if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
                {
                printf("\ntulemuse kirjut. error-faili ebaõnnestus");
                return EXIT_FAILURE;
                }
            continue;          /* vt järgmisi ridu */
            }
        k = vteepar( );
        if (!k)                           /* oli mingi viga */
            {
            unknown++;
            nullityv();            /* et saaks järgmist parad. teha */
            if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
                {
                printf("\ntulemuse kirjut. error-faili ebaõnnestus");
                return EXIT_FAILURE;
                }
            continue;          /* vt järgmisi ridu */
	        }
	    if ( kk != -1 )                   /* leidub parall. indeks */
	        {
            inbuf_para_ind = (const FSxCHAR *)inbuf_para_ind.Mid(2);
            k = era_ind( &inbuf_para_ind );
	        if (!k)                           /* oli mingi viga */
		        {
		        unknown++;
                if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
		            {
		            printf("\ntulemuse kirjut. error-faili ebaõnnestus");
		            return EXIT_FAILURE;
		            }
		        continue;          /* vt järgmisi ridu */
		        }
	        k = vparpar( );
	        if (!k)                           /* oli mingi viga */
		        {
		        unknown++;
		        nullityv();            /* et saaks järgmist parad. teha */
                if ((errf.WriteString((const FSxCHAR *)inbuf, inbuf.GetLength())) == false)
		            {
		            printf("\ntulemuse kirjut. error-faili ebaõnnestus");
		            return EXIT_FAILURE;
		            }
		        continue;          /* vt järgmisi ridu */
		        }
	        }
	    converted++;
	    lisa_lgr( &lgrf );      /* leiab igale selle parad tyvele lgr nr */
	    tee_rida(&inbuf, &outbuf);            /* teeb rea nr|tyvi,lgr/tyvi,lgr... */
        if ((outf.WriteString((const FSxCHAR *)outbuf, outbuf.GetLength())) == false)
	        {
	        printf("\ntulemuse kirjut. väljundfaili ebaõnnestus");
	        return EXIT_FAILURE;
	        }
	    nullityv();            /* et saaks järgmist parad. teha */

	    /*STAT:*/    /* tooseisu v@ljastamine ekraanile */
	    if ( total % 100 == 0 )
	        printf( "\r  KOKKU: %6d KORRAS: %6d SEGASEID: %6d ",
			      total, converted, unknown );
	    }

   /* FILE_END:*/
    printf( "\r  KOKKU: %6d KORRAS: %6d SEGASEID: %6d ",
			  total, converted, unknown );
    Wprintf( FSTSTR("** VRB: %s\n"), (const FSTCHAR*)fn_0);
    infile.Close();
    outf.Close();
    errf.Close();
    lgrf.Close();
    return EXIT_SUCCESS;
}
コード例 #10
0
ファイル: fontfile.cpp プロジェクト: drfiemost/xcircuit-qt
FILE *findfontfile(const char *fontname)
{
   int i;
   char tempname[256];
   FILE *fd;

   /* Add subdirectory "fonts".  We will try both with and	*/
   /* without the subdirectory.					*/

   sprintf(_STR, "fonts/%s", fontname);

   /* change string to all lowercase and remove dashes */

   for (i = 0; i < strlen(_STR); i++) {
      _STR[i] = tolower(_STR[i]);
      if (_STR[i] == '-') _STR[i] = '_';
   }

   /* Fprintf(stdout, "Searching for font file \"%s\"\n", _STR); */

   /* Use the mechanism of "libopen" to find the encoding file	*/
   /* in the search path					*/

   fd = libopen(_STR + 6, FONTENCODING);

   if (fd == NULL) fd = libopen(_STR, FONTENCODING);

   /* Some other, probably futile, attempts (call findfontfile recursively) */

   if (fd == NULL) {
      char *dashptr;

      /* If this font has a suffix, remove it and look for its root */
      /* font on the supposition that this font is derived from the */
      /* root font.						    */

      strncpy(tempname, fontname, 99);
      if ((dashptr = strrchr(tempname, '-')) != NULL) {
	 *dashptr = '\0';
	 if ((fd = findfontfile(tempname)) != NULL) return fd;

	 /* And finally, because it's a common case, try adding	*/
	 /* -Roman and trying again (but don't infinite loop!)	*/

	 if (strcmp(dashptr + 1, "Roman")) {
	    strcat(dashptr, "-Roman");
	    if ((fd = findfontfile(tempname)) != NULL) return fd;
	 }
      }

      Wprintf("No font encoding file found.");
      if (fontcount > 0) {	/* Make font substitution */
	 char *dchr, *psname = NULL;
	 short fval;

	 if ((dchr = strrchr(_STR, '.')) != NULL) *dchr = '\0';
	 if ((fval = findhelvetica()) == fontcount) {
	    /* This will cause some chaos. . . */
	    Fprintf(stderr, "Error:  No fonts available!  Check library path?\n");
            qApp->exit(1);
            return NULL;
	 }

	 psname = (char *)malloc((1 + strlen(fontname)) * sizeof(char));
	 strcpy(psname, fontname);
	 Wprintf("No encoding file found for font %s: substituting %s",
			psname, fonts[fval].psname);
         fonts = (fontinfo *)realloc(fonts, (fontcount + 1) * sizeof(fontinfo));
         fonts[fontcount].psname = psname;
         fonts[fontcount].family = psname;
         fonts[fontcount].encoding = fonts[fval].encoding;
         fonts[fontcount].flags = 0; 
         fonts[fontcount].scale = 1.0;
         fontcount++;
	 makenewfontbutton();
      }
      else {
	 Fprintf(stderr, "Error:  font encoding file missing for font \"%s\"\n",
		fontname);
	 Fprintf(stderr, "No fonts exist for a subsitution.  Make sure "
		"fonts are installed or that\nenvironment variable "
		"XCIRCUIT_LIB_DIR points to a directory of valid fonts.\n");
      }
      return (FILE *)NULL;
   }
   return fd;
}