diff options
-rw-r--r-- | src/library.js | 8 | ||||
-rw-r--r-- | tests/runner.py | 29 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js index b2d08f39..f40955f1 100644 --- a/src/library.js +++ b/src/library.js @@ -4192,11 +4192,11 @@ LibraryManager.library = { throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [Pointer_stringify(filename), line, Pointer_stringify(func)]; }, - __cxa_guard_acquire: function() { - return 1; + __cxa_guard_acquire: function( variable ) { + return !HEAP8[((variable))]; }, - __cxa_guard_release: function() { - return 1; + __cxa_guard_release: function( variable ) { + HEAP8[((variable))] = 1; }, _ZTVN10__cxxabiv117__class_type_infoE: [1], // no inherited classes diff --git a/tests/runner.py b/tests/runner.py index 07d55650..58e82c6b 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -3804,6 +3804,35 @@ def process(filename): return 1; } ''', 'hello world', includes=[path_from_root('tests', 'libcxx', 'include')]); + + def test_static_variable(self): + src = ''' + #include <stdio.h> + + struct DATA + { + int value; + + DATA() + { + value = 0; + } + }; + + DATA & GetData() + { + static DATA data; + + return data; + } + + int main() + { + GetData().value = 10; + printf( "value:%i", GetData().value ); + } + ''' + self.do_run(src, 'value:10') def test_cubescript(self): if self.emcc_args is not None and '-O2' in self.emcc_args: |