Example #1
0
void fn00401547(word32 eax, word32 ecx, word32 edx, word32 ebx, word32 esi, word32 edi)
{
fn00401547_entry:
	goto l00401547
l00401289:
l0040142B:
	branch P l00401289
l0040143F:
l00401444:
	branch P l00401289
l0040144A:
l00401547:
	word32 esi_11 = esi | eax
	branch OVERFLOW(esi_11 - 0x00000001) || !OVERFLOW(esi_11 - 0x00000001) l0040142B
	goto l00401567
l0040155F:
l00401567:
fn00401547_exit:
}
static unsigned long mon_get_count(struct bwmon *m)
{
	unsigned long count, status;

	count = readl_relaxed(MON_CNT(m));
	status = mon_irq_status(m);

	dev_dbg(m->dev, "Counter: %08lx\n", count);

	if (OVERFLOW(status) && m->spec->overflow)
		count += 0xFFFFFFFF;
	if (THRES_HIT(status) && m->spec->wrap_on_thres)
		count += mon_get_limit(m);

	dev_dbg(m->dev, "Actual Count: %08lx\n", count);

	return count;
}
Example #3
0
_CODE_ACCESS time_t mktime(register struct tm *tptr)
{
   time_t   result;
   time_t   daycount;
   int      mdays;
   int      adjust;
    
   /*-----------------------------------------------------------------*/
   /* HANDLE SECONDS.  IF TOO MANY OR TOO FEW, MODIFY MINUTES.        */
   /*-----------------------------------------------------------------*/
   adjust = (tptr->tm_sec < 0) ? -((unsigned)(-tptr->tm_sec + 59) / 60) 
			       : (tptr->tm_sec / 60);

   if (OVERFLOW(tptr->tm_min, adjust)) return((time_t) -1);
   tptr->tm_min += adjust;
   tptr->tm_sec -= adjust * 60;

   /*-----------------------------------------------------------------*/
   /* HANDLE MINUTES.  IF TOO MANY OR TOO FEW, MODIFY HOURS           */
   /*-----------------------------------------------------------------*/
   adjust = (tptr->tm_min < 0) ? -((unsigned)(-tptr->tm_min + 59) / 60) 
			       : (tptr->tm_min / 60);

   if (OVERFLOW(tptr->tm_hour, adjust)) return((time_t) -1);
   tptr->tm_hour += adjust;
   tptr->tm_min  -= adjust * 60;

   /*-----------------------------------------------------------------*/
   /* HANDLE HOURS.    IF TOO MANY OR TOO FEW, MODIFY DAYS            */
   /*-----------------------------------------------------------------*/
   adjust = (tptr->tm_hour < 0) ? -((unsigned)(-tptr->tm_hour + 23) / 24) 
			        : (tptr->tm_hour / 24);

   if (OVERFLOW(tptr->tm_mday, adjust)) return((time_t) -1);
   tptr->tm_mday += adjust;
   tptr->tm_hour -= adjust * 24;

   for (;;)
   {
      /*-----------------------------------------------------------------*/
      /* HANDLE MONTHS.   IF TOO MANY OR TOO FEW, MODIFY YEARS           */
      /*-----------------------------------------------------------------*/
      adjust = (tptr->tm_mon < 0) ? -((unsigned)(-tptr->tm_mon + 11) / 12) 
				  : (tptr->tm_mon / 12);

      if (OVERFLOW(tptr->tm_year, adjust)) return((time_t) -1);
      tptr->tm_year += adjust;
      tptr->tm_mon  -= adjust * 12;

      /*-----------------------------------------------------------------*/
      /* HANDLE DAYS.     IF TOO MANY OR TOO FEW, MODIFY MONTHS          */
      /*-----------------------------------------------------------------*/
      if (tptr->tm_mday <= 0)
      { 
	   tptr->tm_mon--;  
           tptr->tm_mday += mon_len[tptr->tm_mon < 0 ? 11 : tptr->tm_mon] + 
		        ((tptr->tm_mon == 1) && ((tptr->tm_year % 4) == 0));
	   continue;
      }

      /*-----------------------------------------------------------------*/
      /* CALCULATE NUMBER OF DAYS IN THIS MONTH.                         */
      /*-----------------------------------------------------------------*/
      mdays = mon_len[tptr->tm_mon] + 
		( (tptr->tm_mon == 1) && LEAPYEAR(tptr->tm_year) );

      if (tptr->tm_mday > mdays) 
	{ tptr->tm_mday -= mdays; tptr->tm_mon++; }
      else break;
   }

   /*--------------------------------------------------------------------*/
   /* WE CAN NOW BE SURE THAT ALL FIELDS IN THE TIME STRUCTURE ARE RIGHT */
   /*--------------------------------------------------------------------*/
   tptr->tm_yday = mon_day[tptr->tm_mon]  + tptr->tm_mday - 1 +
                   ( (tptr->tm_mon > 1) && LEAPYEAR(tptr->tm_year) );

   daycount      = tptr->tm_year * DAYS_IN_YR  + 
	           ((tptr->tm_year - 1) / 4)   + tptr->tm_yday;

   result        = daycount      * SECS_IN_DAY + 
	           tptr->tm_hour * SECS_IN_HR  +
	           tptr->tm_min  * SECS_IN_MIN + tptr->tm_sec;

   tptr->tm_wday  = (JAN11900 + daycount) % 7;
   tptr->tm_isdst = _tz.daylight;

   return result;
}
Example #4
0
File: ac_1074.c Project: shaung/oj
int main(int argc, char* argv[])
{
	struct number num;
	int n = 0, i = 0, ep = 0, eplus = 0, shouldcnt = 0, esign = 0, etmp = 0, err = 0;
	char line[101] = "", c = 0;

#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

	while(gets(line) != NULL){
		if(line[0] == '#' && line[1] == 0) break;

		memset(&num, 0, sizeof(num));
		memset(num.dec, 0x30, sizeof(num.dec) - 1);
		err = 0;
		eplus = 1;
		ep = EP_SIGN_INT_PUNC;
		for(i = 0; ; i++){
			c = line[i];
			if(ep == EP_SIGN_INT_PUNC){
				if(IS_SIGN(c)){
					num.sign = (c == '-') ? 0 : 1;
					ep = EP_INT_PUNC;
				} else if(IS_DIGIT(c)){
					num.sign = 1;
					if(c > 0x30){
						num.dec[num.lendec++] = c;
						if(eplus == 1) num.e++;
					}
					ep = EP_INT_PUNC_E_BREAK;
				} else if(c == '.'){
					num.sign = 1;
					eplus = 0;
					ep = EP_DEC;
				} else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_INT_PUNC){
				if(IS_DIGIT(c)){
					if(num.lendec > 0 || c > 0x30){
						num.dec[num.lendec++] = c;
						if(eplus == 1) num.e++;
					}
                    ep = EP_INT_PUNC_E_BREAK;
				} else if(c == '.'){
					eplus = 0;
					ep = EP_DEC;
				} else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_INT_PUNC_E_BREAK){
				if(IS_DIGIT(c)){
					if(num.lendec > 0 || c > 0x30){
						num.dec[num.lendec++] = c;
						if(eplus == 1) num.e++;
					}
					ep = EP_INT_PUNC_E_BREAK;
				} else if(c == '.'){
					eplus = 0;
					ep = EP_DEC;
				} else if(IS_EXP(c)){
                    eplus = 0;
					ep = EP_SIGNE_INTE;
				} else if(c == 0) break;
				else {
					err = 1;
					break;
				}
			}
            /* when dealing with the fractional part, should be care of sth. like 0.001001000 and 0.1000 */
            /* fractional part the first digit */
			else if(ep == EP_DEC){
				if(IS_DIGIT(c)){
                    if(c == 0x30) eplus++;
                    else num.dec[num.lendec++] = c;
                    shouldcnt = (c == 0x30) ? 0 : 1;
					ep = EP_DEC_E_BREAK;
				} else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_DEC_E_BREAK){
				if(IS_DIGIT(c)){
                    if(c == 0x30) eplus++;
                    else {
                        //num.lendec++;
                        if(shouldcnt == 0){
                            shouldcnt = 1;
                            if(num.lendec == 0) num.e -= eplus;
                            else num.lendec += eplus;
                        }
                        else {
                            num.lendec += eplus;
                        }
  						num.dec[num.lendec] = c;
                        if(num.lendec == 0) num.lendec++;
                        eplus = 1;
                    }
					ep = EP_DEC_E_BREAK;
				} else if(IS_EXP(c)){
					ep = EP_SIGNE_INTE;
				} else if(c == 0) break;
				else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_SIGNE_INTE){
				if(IS_SIGN(c)){
					esign = (c == '-') ? -1 : 1;
					etmp = 0;
					ep = EP_INTE;
				} else if(IS_DIGIT(c)){
					esign = 1;
					etmp = c - 0x30;
					ep = EP_INTE_BREAK;
				} else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_INTE){
				if(IS_DIGIT(c)){
					if(!OVERFLOW(num.e + (etmp * esign)))
						etmp = etmp * 10 + c - 0x30;
					ep = EP_INTE_BREAK;
				}
                else {
					err = 1;
					break;
				}
			}
			else if(ep == EP_INTE_BREAK){
				if(IS_DIGIT(c)){
					if(!OVERFLOW(num.e + (etmp * esign)))
						etmp = etmp * 10 + c - 0x30;
					ep = EP_INTE_BREAK;
				} else if(c == 0){
					num.e += (etmp * esign);
					break;
				}
				else {
					err = 1;
					break;
				}
			}
			else break;
		}

		scanf("%d", &n);
        gets(line);

        /*		
		printf("[%s] ->\n", line);
		if(num.sign == 0) printf("-");
		printf(" 0.%se%d\n", num.dec, num.e);
        */
        if(err == 1) printf("Not a floating point number\n");
		else{
			if(num.lendec == 0) num.e = 0;
			/* sign when rslt != 0 */
			if(num.sign == 0 && num.lendec > 0 && n + num.e > 0) printf("-");
			/* int part */
			if(num.e <= 0) printf("0");
			else for(i = 0; i < num.e; i++) printf("%c", num.dec[i]);
			/* fractional part */
			if(n > 0){
				printf(".");
				/* anyway we need to output n digits here */
				if(num.e >= 0) for(i = 0; i < n; i++) printf("%c", num.dec[num.e + i]);
				else {
					num.e *= -1;
 				    for(i = 0; i < num.e && i < n; i++) printf("0");
					for(i = 0; i < n - num.e; i++) printf("%c", num.dec[i]);
				}
			}
			printf("\n");
		}
	}

	return 0;
}
 static void overflow_error(const char * message) {
     OVERFLOW(message);
 }