diff options
author | David Smith <dsmith@redhat.com> | 2009-09-24 08:11:09 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2009-09-24 08:11:09 -0500 |
commit | c7687aa3f93a1c831b1c8f3f2e6271b9802923a5 (patch) | |
tree | 85a132723be8d07a4b806d7168b6cc83ae529e5f /tapset | |
parent | d3e3db27d3410fe52e826ff4f76e5a84d192cbb2 (diff) | |
parent | 1c625307539ca5a0bae6a7a6e297f8d8841a8911 (diff) | |
download | systemtap-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.stp | 14 |
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 +%} |