diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index eb1bb53e2e..4ed540f5a8 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -102,3 +102,9 @@ #else #define ISC_ATTR_UNUSED __attribute__((__unused__)) #endif + +#if __STDC_VERSION__ >= 202311L +#define ISC_CONSTEXPR constexpr +#else +#define ISC_CONSTEXPR static const +#endif diff --git a/lib/isc/include/isc/time.h b/lib/isc/include/isc/time.h index 3e944352b3..ad74be9270 100644 --- a/lib/isc/include/isc/time.h +++ b/lib/isc/include/isc/time.h @@ -18,18 +18,19 @@ #include #include +#include #include #include /* * Define various time conversion constants. */ -static const unsigned int MS_PER_SEC = 1000; -static const unsigned int US_PER_MS = 1000; -static const unsigned int NS_PER_US = 1000; -static const unsigned int US_PER_SEC = 1000 * 1000; -static const unsigned int NS_PER_MS = 1000 * 1000; -static const unsigned int NS_PER_SEC = 1000 * 1000 * 1000; +ISC_CONSTEXPR unsigned int MS_PER_SEC = 1000; +ISC_CONSTEXPR unsigned int US_PER_MS = 1000; +ISC_CONSTEXPR unsigned int NS_PER_US = 1000; +ISC_CONSTEXPR unsigned int US_PER_SEC = 1000 * 1000; +ISC_CONSTEXPR unsigned int NS_PER_MS = 1000 * 1000; +ISC_CONSTEXPR unsigned int NS_PER_SEC = 1000 * 1000 * 1000; /* * ISC_FORMATHTTPTIMESTAMP_SIZE needs to be 30 in C locale and potentially