Merge bitcoin/bitcoin#24355: util, refactor: Add UNIQUE_NAME helper macro

1633f5ec88 util, refactor: Add UNIQUE_NAME helper macro (Hennadii Stepanov)

Pull request description:

  This PR replaces repetitive code with a helper macro.

ACKs for top commit:
  laanwj:
    Tested ACK 1633f5ec88

Tree-SHA512: 5f04e472c5f3184c0a9df75395377c6744bfb2cd8f95f8427c1c5e20daa7d6a9b29e45424b88391fc6326d365907a750ab50fda534b49d1df80dccf0e18467a4
This commit is contained in:
laanwj
2022-04-13 22:32:45 +02:00
5 changed files with 11 additions and 8 deletions

View File

@@ -7,6 +7,7 @@
#define BITCOIN_UTIL_EPOCHGUARD_H
#include <threadsafety.h>
#include <util/macros.h>
#include <cassert>
@@ -96,6 +97,6 @@ public:
}
};
#define WITH_FRESH_EPOCH(epoch) const Epoch::Guard PASTE2(epoch_guard_, __COUNTER__)(epoch)
#define WITH_FRESH_EPOCH(epoch) const Epoch::Guard UNIQUE_NAME(epoch_guard_)(epoch)
#endif // BITCOIN_UTIL_EPOCHGUARD_H

View File

@@ -8,6 +8,8 @@
#define PASTE(x, y) x ## y
#define PASTE2(x, y) PASTE(x, y)
#define UNIQUE_NAME(name) PASTE2(name, __COUNTER__)
/**
* Converts the parameter X to a string after macro replacement on X has been performed.
* Don't merge these into one macro!