/usr/share/systemtap/runtime/dyninst
NameSizeModeActions
addr-map.c5650644editdlrm
alloc.c11880644editdlrm
arith.c22910644editdlrm
common_session_state.h69210644editdlrm
copy.c40950644editdlrm
debug.h4130644editdlrm
ilog2.h29430644editdlrm
io.c45410644editdlrm
linux_defs.h56020644editdlrm
linux_hash.h18770644editdlrm
linux_types.h6540644editdlrm
loc2c-runtime.h24940644editdlrm
map_list.h10590644editdlrm
map_runtime.h51600644editdlrm
namespaces.h00644editdlrm
offptr.h47880644editdlrm
offset_list.h44280644editdlrm
perf.c00644editdlrm
print.c27000644editdlrm
probe_lock.h18490644editdlrm
regs.c25570644editdlrm
runtime.h102920644editdlrm
runtime_context.h65560644editdlrm
runtime_defines.h2800644editdlrm
session_attributes.c17170644editdlrm
session_attributes.h7720644editdlrm
shm.c61710644editdlrm
stapdyn.h46170644editdlrm
stat_runtime.h18320644editdlrm
sym.c16210644editdlrm
task_finder.c00644editdlrm
timer.c27700644editdlrm
transport.c311280644editdlrm
transport.h39680644editdlrm
unwind.c00644editdlrm
uprobes-regs.c31630644editdlrm
uprobes.c17980644editdlrm
uprobes.h9530644editdlrm
Edit: /usr/share/systemtap/runtime/dyninst/arith.c (2291B)
/* -*- linux-c -*- */ /* Math functions * Copyright (C) 2005-2012 Red Hat Inc. * * This file is part of systemtap, and is free software. You can * redistribute it and/or modify it under the terms of the GNU General * Public License (GPL); either version 2, or (at your option) any * later version. */ #ifndef _STAPDYN_ARITH_C_ #define _STAPDYN_ARITH_C_ /** @file arith. * @brief Implements various arithmetic-related helper functions */ /** Divide x by y. In case of division-by-zero, * set context error string, and return 0 */ static int64_t _stp_div64 (const char **error, int64_t x, int64_t y) { // check for division-by-zero if (unlikely (y == 0)) { if (error) *error = "division by 0"; return 0; } if (unlikely (y == -1)) return -x; return x/y; } /** Modulo x by y. In case of division-by-zero, * set context error string, and return any 0 */ static int64_t _stp_mod64 (const char **error, int64_t x, int64_t y) { // check for division-by-zero if (unlikely (y == 0)) { if (error) *error = "division by 0"; return 0; } if (unlikely (y == 1 || y == -1)) return 0; return x%y; } static unsigned long _stp_random_u_init(void) { unsigned long seed; ssize_t count = 0; int fd = open("/dev/urandom", O_RDONLY); if (fd >= 0) { count = read(fd, &seed, sizeof(seed)); close(fd); } /* If urandom fails for any reason, this is a crude fallback */ if (count != sizeof(seed)) { struct timespec ts; (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); seed = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; } return seed; } /** Return a random integer between 0 and n - 1. * @param n how far from zero to go. Make it positive but less than a million or so. */ static unsigned long _stp_random_u (unsigned long n) { static unsigned long seed; static int initialized_p = 0; if (unlikely (! initialized_p)) { seed = _stp_random_u_init(); initialized_p = 1; } /* from glibc rand man page */ seed = seed * 1103515245 + 12345; return (n == 0 ? 0 : seed % n); } /** 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. */ static int _stp_random_pm (unsigned n) { return -(int)n + (int)_stp_random_u (2*n + 1); } #endif /* _STAPDYN_ARITH_C_ */