|
11 | 11 |
|
12 | 12 | #pragma once
|
13 | 13 |
|
| 14 | +#if defined( __EMSCRIPTEN__) |
| 15 | +#include <time.h> |
| 16 | +#include <emscripten/emscripten.h> |
| 17 | +#endif |
| 18 | + |
14 | 19 | #if defined( LINUX ) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
|
15 | 20 | // based on some Jonathan Wakely macros on the net...
|
16 | 21 | #define GCC_DIAG_STR(s) #s
|
@@ -1715,8 +1720,8 @@ PLATFORM_INTERFACE void Plat_GetLocalTime( struct tm *pNow );
|
1715 | 1720 |
|
1716 | 1721 | // Convert a time_t (specified in nTime - seconds since Jan 1, 1970 UTC) to a local calendar time in a threadsafe and non-crash-prone way.
|
1717 | 1722 | PLATFORM_INTERFACE void Plat_ConvertToLocalTime( uint64 nTime, struct tm *pNow );
|
1718 |
| -// In Emscripten, it loves being a bitch, so we have to use std::. |
1719 |
| -PLATFORM_INTERFACE struct tm * Plat_localtime( const std::time_t *timep, struct tm *result ); |
| 1723 | +// In Emscripten, it loves being a bitch. |
| 1724 | +PLATFORM_INTERFACE struct tm * Plat_localtime( const time_t *timep, struct tm *result ); |
1720 | 1725 |
|
1721 | 1726 | // Get a time string (same as ascstring, but threadsafe).
|
1722 | 1727 | PLATFORM_INTERFACE void Plat_GetTimeString( struct tm *pTime, char *pOut, int nMaxBytes );
|
@@ -1792,6 +1797,10 @@ inline uint64 Plat_Rdtsc()
|
1792 | 1797 | uint32 lo, hi;
|
1793 | 1798 | __asm__ __volatile__ ( "rdtsc" : "=a" (lo), "=d" (hi));
|
1794 | 1799 | return ( ( ( uint64 )hi ) << 32 ) | lo;
|
| 1800 | +#elif defined( __EMSCRIPTEN__ ) |
| 1801 | +uint64 val { |
| 1802 | + return (uint64_t)(emscripten_get_now() * 1000.0); // microseconds |
| 1803 | +}; |
1795 | 1804 | #else
|
1796 | 1805 | #error
|
1797 | 1806 | #endif
|
|
0 commit comments