// **//// /** ** ////////** /**//////**
// ** /** ** /** /** /**
// ** /** ** ******** /** /**
-// // /******/ //////// // //
+// // /******/ //////// // //
//
// FOSA(Frescor Operating System Adaptation layer)
//================================================
} \
} while(0)
-
#define add_timespec(sum, t1, t2) \
do { \
(sum).tv_sec = (t1).tv_sec + (t2).tv_sec; \
normalize_timespec(sum); \
} while(0)
-
+#define incr_timespec(t1, t2) \
+do { \
+ (t1).tv_sec += (t2).tv_sec; \
+ (t1).tv_nsec += (t2).tv_nsec; \
+ normalize_timespec(t1); \
+} while(0)
// -------------------------------------------------------------------
(diff).tv_sec = (base).tv_sec - (interval).tv_sec; \
(diff).tv_nsec = (base).tv_nsec - (interval).tv_nsec; \
} \
-} while(0)
+} while(0)
// ---------------------------------------------------------
// ---------------------------------------------------------
#define timespec_to_msec(t1) \
- ( ((t1).tv_sec % 2147482) * 1000 + (t1).tv_nsec/1000000 )
+ ( ((t1).tv_sec % 2147482) * 1000 + (t1).tv_nsec/1000000 )
// ---------------------------------------------------------
#define timespec_is_null(t1) ( (t1).tv_sec == 0 ) && ( (t1).tv_nsec == 0 )
-
+
/***************************************/
/* T I M E S P E C F U N C T I O N S */
/***************************************/
static inline fosa_abs_time_t fosa_abs_time_incr(fosa_abs_time_t base, fosa_rel_time_t interval)
{
fosa_abs_time_t result;
-
+
add_timespec(result, base, interval);
return result;
return result;
}
-
+
// ---------------------------------------------------------
* exact_long_multiply_smaller_10e5()
*
* Same as below but with operands smaller than 10000 which allows
- * to perform all component multiplications without an overflow risk.
+ * to perform all component multiplications without an overflow risk.
**/
static inline struct timespec exact_long_multiply_smaller_10e5(long t, long k)
{
return result;
}
-
-// -------------------------------------------------------------
-
+// -------------------------------------------------------------
+
+
/**
* exact_long_multiply()
{
overflow_risk = true;
}
-
+
if (! overflow_risk)
{
c0.tv_sec = 0;
return result;
}
-
-// -------------------------------------------------------------
+
+// -------------------------------------------------------------
static inline fosa_rel_time_t fosa_rel_time_times_integer(fosa_rel_time_t time, long multiplier)
intermediate = exact_long_multiply(time.tv_nsec, multiplier);
add_timespec(result, result, intermediate);
-
+
return result;
}
enhacer *= 10;
back_enhacer = 1000000000 / enhacer;
next_numeral = (time.tv_nsec / back_enhacer) % 10;
-
+
// Note: a possible overflow may happen here with large denominators
if (reminder > 200000000)
{
abort();
}
next_dividend = reminder * 10 + next_numeral;
-
+
result.tv_nsec += (next_dividend / divider) * back_enhacer;
reminder = next_dividend % divider;
} while (back_enhacer > 1);
-
+
return result;
}