From 98afd80eb5038542fa3a98c75528524b5d4287b6 Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 19 Aug 2005 21:50:42 +0000 Subject: 2005-08-19 Frank Ch. Eigler PR systemtap/1209 * tapsets.cxx * elaborate.cxx (derived_probe_builder): Add get_param function. * elaborate.h: Declare them. * tapsets.cxx (dwarf_query::get_*_param): Call them. (timer_derived_probe, timer_builder): New classes. (register_standard_tapsets): Register timer.jiffies(N) and friend. * translate.cxx (translate_pass): #include . * stap.1.in: Document timer.jiffies(N) probe points. * testsuite/buildok/fourteen.stp: New test. 2005-08-19 Frank Ch. Eigler * arith.c (_stp_random_pm): New function. --- runtime/arith.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'runtime/arith.c') diff --git a/runtime/arith.c b/runtime/arith.c index 175cc4e8..0200afa6 100644 --- a/runtime/arith.c +++ b/runtime/arith.c @@ -2,9 +2,10 @@ #define _ARITH_C_ /** @file arith. - * @brief Implements 64-bit signed division/multiplication. + * @brief Implements various arithmetic-related helper functions */ + struct context; void _stp_divmod64 (unsigned *errorcount, int64_t x, int64_t y, int64_t *quo, int64_t *rem); @@ -75,5 +76,26 @@ void _stp_divmod64 (unsigned *errorcount, int64_t x, int64_t y, } +/** Return a random integer between -n and n. + * @param n how far from zero to go. Make it positive but less than a million or so. + */ +int _stp_random_pm (int n) +{ + static unsigned long seed; + static int initialized_p = 0; + + if (unlikely (! initialized_p)) + { + seed = (unsigned long) jiffies; + initialized_p = 1; + } + + /* from glibc rand man page */ + seed = seed * 1103515245 + 12345; + + return (seed % (2*n+1)-n); +} + + #endif /* _ARITH_C_ */ -- cgit