aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/t_test1/lran2.h
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-05-15 21:27:05 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-05-15 21:27:05 +0200
commit05b8e3e6dcb12df1e6897bbfc6ace6d5e6740c06 (patch)
tree0aa57b58f76788584e1ae205d3290df2a42a3fa8 /src/benchmarks/t_test1/lran2.h
parent342764869b7cab91a24a998003fbbff032eea25d (diff)
downloadallocbench-05b8e3e6dcb12df1e6897bbfc6ace6d5e6740c06.tar.gz
allocbench-05b8e3e6dcb12df1e6897bbfc6ace6d5e6740c06.zip
add ttest1 from ptmalloc
Diffstat (limited to 'src/benchmarks/t_test1/lran2.h')
-rw-r--r--src/benchmarks/t_test1/lran2.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/benchmarks/t_test1/lran2.h b/src/benchmarks/t_test1/lran2.h
new file mode 100644
index 0000000..cea9920
--- /dev/null
+++ b/src/benchmarks/t_test1/lran2.h
@@ -0,0 +1,51 @@
+/* lran2.h
+ * by Wolfram Gloger 1996.
+ *
+ * A small, portable pseudo-random number generator.
+ */
+
+#ifndef _LRAN2_H
+#define _LRAN2_H
+
+#define LRAN2_MAX 714025l /* constants for portable */
+#define IA 1366l /* random number generator */
+#define IC 150889l /* (see e.g. `Numerical Recipes') */
+
+struct lran2_st {
+ long x, y, v[97];
+};
+
+static void
+lran2_init(struct lran2_st* d, long seed)
+{
+ long x;
+ int j;
+
+ x = (IC - seed) % LRAN2_MAX;
+ if(x < 0) x = -x;
+ for(j=0; j<97; j++) {
+ x = (IA*x + IC) % LRAN2_MAX;
+ d->v[j] = x;
+ }
+ d->x = (IA*x + IC) % LRAN2_MAX;
+ d->y = d->x;
+}
+
+#ifdef __GNUC__
+__inline__
+#endif
+static long
+lran2(struct lran2_st* d)
+{
+ int j = (d->y % 97);
+
+ d->y = d->v[j];
+ d->x = (IA*d->x + IC) % LRAN2_MAX;
+ d->v[j] = d->x;
+ return d->y;
+}
+
+#undef IA
+#undef IC
+
+#endif