lib/iec_std_lib.h
changeset 700 b0ef6711f2a8
parent 696 7530eae6786d
child 739 438cb1078886
equal deleted inserted replaced
699:0307fa16db3f 700:b0ef6711f2a8
   293   __normalize_timespec(&res);
   293   __normalize_timespec(&res);
   294   return res;
   294   return res;
   295 }
   295 }
   296 static inline TIME __time_mul(TIME IN1, LREAL IN2){
   296 static inline TIME __time_mul(TIME IN1, LREAL IN2){
   297   LREAL s_f = IN1.tv_sec * IN2;
   297   LREAL s_f = IN1.tv_sec * IN2;
   298   time_t s = s_f;
   298   time_t s = (time_t)s_f;
   299   div_t ns = div((LREAL)IN1.tv_nsec * IN2, 1000000000);
   299   div_t ns = div((int)((LREAL)IN1.tv_nsec * IN2), 1000000000);
   300   TIME res = {s + ns.quot,
   300   TIME res = {(long)s + ns.quot,
   301               ns.rem + (s_f - s) * 1000000000 };
   301 		      (long)ns.rem + (s_f - s) * 1000000000 };
   302   __normalize_timespec(&res);
   302   __normalize_timespec(&res);
   303   return res;
   303   return res;
   304 }
   304 }
   305 static inline TIME __time_div(TIME IN1, LREAL IN2){
   305 static inline TIME __time_div(TIME IN1, LREAL IN2){
   306   LREAL s_f = IN1.tv_sec / IN2;
   306   LREAL s_f = IN1.tv_sec / IN2;
   307   time_t s = s_f;
   307   time_t s = (time_t)s_f;
   308   TIME res = {s,
   308   TIME res = {(long)s,
   309               IN1.tv_nsec / IN2 + (s_f - s) * 1000000000 };
   309               (long)(IN1.tv_nsec / IN2 + (s_f - s) * 1000000000) };
   310   __normalize_timespec(&res);
   310   __normalize_timespec(&res);
   311   return res;
   311   return res;
   312 }
   312 }
   313 
   313 
   314 
   314 
   480     /* search the dot */
   480     /* search the dot */
   481     l = IN.len;
   481     l = IN.len;
   482     while(--l > 0 && IN.body[l] != '.');
   482     while(--l > 0 && IN.body[l] != '.');
   483     if(l != 0){
   483     if(l != 0){
   484         LREAL IN_val = atof((const char *)&IN.body);
   484         LREAL IN_val = atof((const char *)&IN.body);
   485         return  (TIME){IN_val, (IN_val - (LINT)IN_val)*1000000000};
   485         return  (TIME){(long)IN_val, (long)(IN_val - (LINT)IN_val)*1000000000};
   486     }else{
   486     }else{
   487         return  (TIME){__pstring_to_sint(&IN), 0};
   487         return  (TIME){(long)__pstring_to_sint(&IN), 0};
   488     }
   488     }
   489 }
   489 }
   490 
   490 
   491     /***************/
   491     /***************/
   492     /*  FROM_TIME  */
   492     /*  FROM_TIME  */