Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: src/IceRNG.h

Issue 456033003: Subzero: Randomize register assignment. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Typo Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceDefs.h ('k') | src/IceRegAlloc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceRNG.h
diff --git a/src/IceRNG.h b/src/IceRNG.h
index 423aee00e233110a5aeb783ffcda8ba07661781a..b132915358da6185b2c8d20713aa1cc4e7094950 100644
--- a/src/IceRNG.h
+++ b/src/IceRNG.h
@@ -16,6 +16,7 @@
#include <stdint.h>
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
namespace Ice {
@@ -25,9 +26,32 @@ public:
uint64_t next(uint64_t Max);
private:
+ RandomNumberGenerator(const RandomNumberGenerator &) LLVM_DELETED_FUNCTION;
+ RandomNumberGenerator &
+ operator=(const RandomNumberGenerator &) LLVM_DELETED_FUNCTION;
+
uint64_t State;
};
+// This class adds additional random number generator utilities. The
+// reason for the wrapper class is that we want to keep the
+// RandomNumberGenerator interface identical to LLVM's.
+class RandomNumberGeneratorWrapper {
+public:
+ uint64_t operator()(uint64_t Max) { return RNG.next(Max); }
+ uint64_t next(uint64_t Max) { return RNG.next(Max); }
+ bool getTrueWithProbability(float Probability);
+ RandomNumberGeneratorWrapper(RandomNumberGenerator &RNG) : RNG(RNG) {}
+
+private:
+ RandomNumberGeneratorWrapper(const RandomNumberGeneratorWrapper &)
+ LLVM_DELETED_FUNCTION;
+ RandomNumberGeneratorWrapper &
+ operator=(const RandomNumberGeneratorWrapper &) LLVM_DELETED_FUNCTION;
+
+ RandomNumberGenerator &RNG;
+};
+
} // end of namespace Ice
#endif // SUBZERO_SRC_ICERNG_H
« no previous file with comments | « src/IceDefs.h ('k') | src/IceRegAlloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698