32 lines
767 B
C++
32 lines
767 B
C++
#pragma once
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
|
|
#if PLATFORM_WINDOWS
|
|
#ifdef core_EXPORTS
|
|
#define CORE_API __declspec(dllexport)
|
|
#else
|
|
#define CORE_API __declspec(dllimport)
|
|
#endif
|
|
#elif PLATFORM_MACOS || PLATFORM_LINUX
|
|
#ifdef core_EXPORTS
|
|
#define CORE_API __attribute__((visibility("default")))
|
|
#else
|
|
#define CORE_API
|
|
#endif
|
|
#else
|
|
#error Unsupported platform
|
|
#endif
|
|
|
|
#if USE_DOUBLE_SAMPLE
|
|
typedef double sample_t;
|
|
#else
|
|
typedef float sample_t;
|
|
#endif
|
|
|
|
static uint64_t gen_uid() {
|
|
static uint64_t uid = 0;
|
|
const uint64_t current_uid = ++uid;
|
|
// append the current time to the uid to make it unique
|
|
return (current_uid << 32) | std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
|
} |