summaryrefslogtreecommitdiffstats
path: root/tapset
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-09-24 08:11:09 -0500
committerDavid Smith <dsmith@redhat.com>2009-09-24 08:11:09 -0500
commitc7687aa3f93a1c831b1c8f3f2e6271b9802923a5 (patch)
tree85a132723be8d07a4b806d7168b6cc83ae529e5f /tapset
parentd3e3db27d3410fe52e826ff4f76e5a84d192cbb2 (diff)
parent1c625307539ca5a0bae6a7a6e297f8d8841a8911 (diff)
downloadsystemtap-steved-c7687aa3f93a1c831b1c8f3f2e6271b9802923a5.tar.gz
systemtap-steved-c7687aa3f93a1c831b1c8f3f2e6271b9802923a5.tar.xz
systemtap-steved-c7687aa3f93a1c831b1c8f3f2e6271b9802923a5.zip
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Diffstat (limited to 'tapset')
-rw-r--r--tapset/random.stp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tapset/random.stp b/tapset/random.stp
new file mode 100644
index 00000000..9b2fdc70
--- /dev/null
+++ b/tapset/random.stp
@@ -0,0 +1,14 @@
+/**
+ * sfunction randint - Return a random number between [0,n)
+ * @n: Number past upper limit of range, not larger than 2**20.
+ */
+function randint:long(n:long)
+%{ /* unprivileged */
+#define RANDMAX (1024*1024)
+ if (THIS->n > RANDMAX)
+ CONTEXT->last_error = "range too wide";
+ else {
+ THIS->__retvalue = (uint64_t) _stp_random_u((unsigned long) THIS->n);
+ }
+#undef RANDMAX
+%}