]> gitweb.factorcode.org Git - factor.git/commitdiff
random.c: adding a "libc" version of random for performance testing.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 04:03:29 +0000 (20:03 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Feb 2013 04:04:06 +0000 (20:04 -0800)
extra/random/c/authors.txt [new file with mode: 0644]
extra/random/c/c.factor [new file with mode: 0644]
extra/random/c/platforms.txt [new file with mode: 0644]

diff --git a/extra/random/c/authors.txt b/extra/random/c/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/random/c/c.factor b/extra/random/c/c.factor
new file mode 100644 (file)
index 0000000..1782cb2
--- /dev/null
@@ -0,0 +1,17 @@
+! Copyright (C) 2013 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+
+USING: alien.c-types alien.syntax kernel random ;
+
+IN: random.c
+
+LIBRARY: libc
+
+FUNCTION: int rand ( ) ;
+
+SINGLETON: c-random
+
+M: c-random random-32* drop rand ;
+
+: with-c-random ( quot -- )
+    [ c-random ] dip with-random ; inline
diff --git a/extra/random/c/platforms.txt b/extra/random/c/platforms.txt
new file mode 100644 (file)
index 0000000..509143d
--- /dev/null
@@ -0,0 +1 @@
+unix