This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Atomic { | |
| std::atomic<int> val = 0; | |
| public: | |
| void Lock() | |
| { | |
| int expected = 0; | |
| while (!val.compare_exchange_weak(expected, 1)) { | |
| expected = 0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Atomic { | |
| std::atomic<int> val = 0; | |
| static const int writeLockBit = 0x40000000; | |
| void LockInternal(int delta, int testBits) | |
| { | |
| int expected; | |
| do { | |
| do { | |
| expected = val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Atomic { | |
| std::atomic<int> val = 0; | |
| static const int writeLockBit = 0x40000000; | |
| static const int upgradingBit = 0x00010000; | |
| static const int writeUpgradeingBits = 0x7fff0000; | |
| static const int readerBits = 0x0000ffff; | |
| void LockInternal(int delta, int testBits) | |
| { | |
| int expected; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Atomic { | |
| std::atomic<int> val = 0; | |
| static const int writeLockBit = 0x40000000; | |
| static const int upgradableBit = 0x00010000; | |
| static const int readerBits = 0x0000ffff; | |
| void LockInternal(int delta, int testBits) | |
| { | |
| int expected; | |
| do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Atomic { | |
| std::atomic<int> val = 0; | |
| static const int writeLockBit = 0x40000000; | |
| static const int upgradingBit = 0x20000000; | |
| static const int readerBits = 0x0000ffff; | |
| void LockInternal(int delta, int testBits) | |
| { | |
| int expected; | |
| do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int aflDoFileForReplace(lua_State* L) | |
| { | |
| const char* fileName = lua_tostring(L, -1); | |
| char* img = (char*)LoadFile(fileName); | |
| if (!img) { | |
| luaL_error(L, "aflDoFile: could not load file %s", fileName); | |
| return false; | |
| } | |
| bool ok = true; | |
| if (luaL_loadbuffer(L, img, strlen(img), fileName)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return "A message from callee!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function require(m) | |
| dofile(m..".lua") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("calling with dofile", dofile("random.lua"), dofile("random.lua"), dofile("random.lua")) | |
| print("calling with require", require("random"), require("random"), require("random")) | |
| assert(require("random") == package.loaded["random"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function require(m) | |
| package.loaded[m] = package.loaded[m] or dofile(m..".lua") or true | |
| return package.loaded[m] | |
| end |