]> git.cworth.org Git - apitrace/blobdiff - common/os.hpp
Use rand() on windows.
[apitrace] / common / os.hpp
index 985ff6b9ccb84e8a291941017f76f4f9f7c873dc..741d345bf18b30d1c702a1770db3e245f7276611 100644 (file)
@@ -84,6 +84,18 @@ void abort(void);
 void setExceptionCallback(void (*callback)(void));
 void resetExceptionCallback(void);
 
+/**
+ * Returns a pseudo-random integer in the range 0 to RAND_MAX.
+ */
+static inline int
+random(void) {
+#ifdef _WIN32
+    return ::rand();
+#else
+    return ::random();
+#endif
+}
+
 } /* namespace os */
 
 #endif /* _OS_HPP_ */