Add auto-detection of platform integer size in prometheus
This commit is contained in:
parent
a2162c01e3
commit
6b113c8270
3 changed files with 35 additions and 3 deletions
|
@ -25,7 +25,18 @@ namespace prometheus {
|
|||
///
|
||||
/// The class is thread-safe. No concurrent call to any API of this type causes
|
||||
/// a data race.
|
||||
template <typename Value_ = uint64_t>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if UINTPTR_MAX == 0xffFFffFF
|
||||
// 32-bit platform
|
||||
template <typename Value_ = uint32_t>
|
||||
#elif UINTPTR_MAX == 0xffFFffFFffFFffFF
|
||||
// 64-bit platform
|
||||
template <typename Value_ = uint64_t>
|
||||
#else
|
||||
#error Unknown platform - does not look either like 32-bit or 64-bit
|
||||
#endif
|
||||
class Counter : public Metric {
|
||||
|
||||
std::atomic<Value_> value{ 0 };
|
||||
|
|
|
@ -23,7 +23,17 @@ namespace prometheus {
|
|||
///
|
||||
/// The class is thread-safe. No concurrent call to any API of this type causes
|
||||
/// a data race.
|
||||
#include <stdint.h>
|
||||
|
||||
#if UINTPTR_MAX == 0xffFFffFF
|
||||
// 32-bit
|
||||
template <typename Value_ = uint32_t>
|
||||
#elif UINTPTR_MAX == 0xffFFffFFffFFffFF
|
||||
// 64-bit
|
||||
template <typename Value_ = uint64_t>
|
||||
#else
|
||||
#error Unknown platform - does not look either like 32-bit or 64-bit
|
||||
#endif
|
||||
class Gauge : public Metric {
|
||||
|
||||
std::atomic<Value_> value { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue