mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Limit clock duration to milliseconds type on narrow int type
On AVR, for 16 bit int types, nano and micro are not provided. Now, consistently use them only conditionally.
This commit is contained in:
parent
a0c98662ca
commit
b7dc61370c
@ -33,7 +33,11 @@ SOFTWARE.
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CHRONO_SYSTEM_CLOCK_DURATION)
|
||||
#define ETL_CHRONO_SYSTEM_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
#define ETL_CHRONO_SYSTEM_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#else
|
||||
#define ETL_CHRONO_SYSTEM_CLOCK_DURATION etl::chrono::milliseconds
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CHRONO_SYSTEM_CLOCK_IS_STEADY)
|
||||
@ -41,7 +45,11 @@ SOFTWARE.
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION)
|
||||
#define ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
#define ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#else
|
||||
#define ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION etl::chrono::milliseconds
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CHRONO_HIGH_RESOLUTION_CLOCK_IS_STEADY)
|
||||
@ -49,7 +57,11 @@ SOFTWARE.
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CHRONO_STEADY_CLOCK_DURATION)
|
||||
#define ETL_CHRONO_STEADY_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
#define ETL_CHRONO_STEADY_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
#else
|
||||
#define ETL_CHRONO_STEADY_CLOCK_DURATION etl::chrono::milliseconds
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C" ETL_CHRONO_SYSTEM_CLOCK_DURATION::rep etl_get_system_clock();
|
||||
|
||||
@ -315,13 +315,17 @@ namespace etl
|
||||
/// Duration types
|
||||
//***********************************************************************
|
||||
#if (ETL_USING_64BIT_TYPES)
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
using nanoseconds = etl::chrono::duration<int64_t, etl::nano>;
|
||||
using microseconds = etl::chrono::duration<int64_t, etl::micro>;
|
||||
#endif
|
||||
using milliseconds = etl::chrono::duration<int64_t, etl::milli>;
|
||||
using seconds = etl::chrono::duration<int64_t, etl::ratio<1U>>;
|
||||
#else
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
using nanoseconds = etl::chrono::duration<int32_t, etl::nano>;
|
||||
using microseconds = etl::chrono::duration<int32_t, etl::micro>;
|
||||
#endif
|
||||
using milliseconds = etl::chrono::duration<int32_t, etl::milli>;
|
||||
using seconds = etl::chrono::duration<int32_t, etl::ratio<1U>>;
|
||||
#endif
|
||||
@ -811,6 +815,7 @@ namespace etl
|
||||
return etl::chrono::duration<double, milli>(s);
|
||||
}
|
||||
|
||||
#if (INT_MAX >= INT32_MAX)
|
||||
//***********************************************************************
|
||||
/// Literal for microseconds duration
|
||||
//***********************************************************************
|
||||
@ -848,7 +853,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Literal for floating point microseconds duration
|
||||
/// Literal for floating point nanoseconds duration
|
||||
//***********************************************************************
|
||||
#if ETL_USING_VERBOSE_CHRONO_LITERALS
|
||||
inline ETL_CONSTEXPR14 etl::chrono::duration<double, nano> operator ""_nanoseconds(long double s) ETL_NOEXCEPT
|
||||
@ -858,6 +863,7 @@ namespace etl
|
||||
{
|
||||
return etl::chrono::duration<double, nano>(s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user