Skip to content

Commit 1f55ed6

Browse files
committed
[feat][fix] Additional Debugging mechanics in wscript and fixes in platform.h
1 parent b1fd4c6 commit 1f55ed6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/public/tier0/platform.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
#pragma once
1313

14+
#if defined( __EMSCRIPTEN__)
15+
#include <time.h>
16+
#include <emscripten/emscripten.h>
17+
#endif
18+
1419
#if defined( LINUX ) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
1520
// based on some Jonathan Wakely macros on the net...
1621
#define GCC_DIAG_STR(s) #s
@@ -1715,8 +1720,8 @@ PLATFORM_INTERFACE void Plat_GetLocalTime( struct tm *pNow );
17151720

17161721
// 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.
17171722
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 );
17201725

17211726
// Get a time string (same as ascstring, but threadsafe).
17221727
PLATFORM_INTERFACE void Plat_GetTimeString( struct tm *pTime, char *pOut, int nMaxBytes );
@@ -1792,6 +1797,10 @@ inline uint64 Plat_Rdtsc()
17921797
uint32 lo, hi;
17931798
__asm__ __volatile__ ( "rdtsc" : "=a" (lo), "=d" (hi));
17941799
return ( ( ( uint64 )hi ) << 32 ) | lo;
1800+
#elif defined( __EMSCRIPTEN__ )
1801+
uint64 val {
1802+
return (uint64_t)(emscripten_get_now() * 1000.0); // microseconds
1803+
};
17951804
#else
17961805
#error
17971806
#endif

src/wscript

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ def configure(conf):
171171
opt_flags += ['-fcolor-diagnostics']
172172
if conf.env.COMPILER_CC == 'emcc':
173173
opt_flags += ['-fcolor-diagnostics']
174+
# Easier to debug errors
175+
opt_flags += ['-ferror-limit=1']
174176
elif conf.env.COMPILER_CC == 'gcc':
175177
opt_flags += ['-fdiagnostics-color=always']
176178

0 commit comments

Comments
 (0)