diff options
author | Roland Grunberg <rgrunber@redhat.com> | 2009-09-23 13:46:05 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-09-23 14:04:26 -0400 |
commit | 09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36 (patch) | |
tree | 7134c0eb69051baf563a474048c7096bcc7dcfa4 /tapset/random.stp | |
parent | dc0c46f5f74a9e0468236b31c8d9364eb24c3624 (diff) | |
download | systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.tar.gz systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.tar.xz systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.zip |
PR10632: tapset: randint() function + tests
Diffstat (limited to 'tapset/random.stp')
-rw-r--r-- | tapset/random.stp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tapset/random.stp b/tapset/random.stp new file mode 100644 index 00000000..e0a89d19 --- /dev/null +++ b/tapset/random.stp @@ -0,0 +1,18 @@ +/** @addtogroup library +* The library tapset is a collection of standard functions. +* @{ +*/ + +function randint:long(min:long, max:long) +%{ + + unsigned long difference = (unsigned long)(THIS->max - THIS->min); + + if ( THIS->min >= THIS->max || (THIS->max -THIS->min) > (1024*1024) ){ + CONTEXT->last_error = "either first argument was not strictly less than the second argument, or their difference was greater than (1024*1024)"; + } + THIS->__retvalue = THIS->min + ( _stp_random_pm_u(2147483646) % (difference + 1) ); + +%} + +/** @} */ |