time_linux.cpp #1

  • //
  • guest/
  • ququlala/
  • libsprawl/
  • mainline/
  • time/
  • time_linux.cpp
  • View
  • Commits
  • Open Download .zip Download (713 B)
#include "time.hpp"
#include <time.h>
#include <type_traits>

namespace sprawl
{
	namespace time
	{
		int64_t Now(Resolution resolution)
		{
			struct timespec ts;
			clock_gettime(CLOCK_REALTIME, &ts);
			uint64_t nanosecondResult = ts.tv_sec;
			nanosecondResult *= 1000000000;
			nanosecondResult += ts.tv_nsec;
			return nanosecondResult / std::underlying_type<Resolution>::type(resolution);
		}

		int64_t SteadyNow(Resolution resolution)
		{
			struct timespec ts;
			clock_gettime(CLOCK_MONOTONIC, &ts);
			uint64_t nanosecondResult = ts.tv_sec;
			nanosecondResult *= 1000000000;
			nanosecondResult += ts.tv_nsec;
			return nanosecondResult / std::underlying_type<Resolution>::type(resolution);
		}
	}
}
# Change User Description Committed
#1 23398 ququlala "Forking branch Mainline of shadauxcat-libsprawl to ququlala-libsprawl."
//guest/ShadauxCat/Sprawl/Mainline/time/time_linux.cpp
#1 11500 ShadauxCat Added sprawl::time library.
Fixed JSON Unit Test bug.