summaryrefslogtreecommitdiffstats
path: root/source/slang/compiler.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-08-07 15:44:00 -0700
committerGitHub <noreply@github.com>2017-08-07 15:44:00 -0700
commit9ad2b40b79907c847451891ce2716fcbcdd2e916 (patch)
treee492a82b13334955c1c56f6e3f9d25e8165de82c /source/slang/compiler.cpp
parentca8eea98c89c632dd7b5a6a8b84d379d1e9e59cf (diff)
parent7b54f43fb1b123f451460edb0add218a0428fe95 (diff)
Merge pull request #153 from tfoleyNV/remove-globals
Remove uses of global variables
Diffstat (limited to 'source/slang/compiler.cpp')
-rw-r--r--source/slang/compiler.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp
index 6bb8abe7e..60f111d83 100644
--- a/source/slang/compiler.cpp
+++ b/source/slang/compiler.cpp
@@ -8,7 +8,6 @@
#include "parser.h"
#include "preprocessor.h"
#include "syntax-visitors.h"
-#include "slang-stdlib.h"
#include "reflection.h"
#include "emit.h"
@@ -883,8 +882,20 @@ namespace Slang
char const* ext,
bool isBinary)
{
- static int counter = 0;
- int id = counter++;
+ // Try to generate a unique ID for the file to dump,
+ // even in cases where there might be multiple threads
+ // doing compilation.
+ //
+ // This is primarily a debugging aid, so we don't
+ // really need/want to do anything too elaborate
+
+ static uint32_t counter = 0;
+#ifdef WIN32
+ uint32_t id = InterlockedIncrement(&counter);
+#else
+ // TODO: actually implement the case for other platforms
+ uint32_t id = counter++;
+#endif
String path;
path.append("slang-dump-");