| 1 |
// Copyright (C) 2012 Red Hat Inc. |
| 2 |
// |
| 3 |
// This file is part of systemtap, and is free software. You can |
| 4 |
// redistribute it and/or modify it under the terms of the GNU General |
| 5 |
// Public License (GPL); either version 2, or (at your option) any |
| 6 |
// later version. |
| 7 |
// |
| 8 |
|
| 9 |
// NB: functionally equivalent to linux/guru-delay.stp |
| 10 |
|
| 11 |
%{ |
| 12 |
#include <time.h> |
| 13 |
%} |
| 14 |
|
| 15 |
function mdelay(ms:long) |
| 16 |
{ |
| 17 |
udelay(ms * 1000); |
| 18 |
} |
| 19 |
|
| 20 |
function udelay(us:long) |
| 21 |
%{ /* guru */ |
| 22 |
struct timespec ts = { |
| 23 |
STAP_ARG_us / 1000000, |
| 24 |
STAP_ARG_us % 1000000, |
| 25 |
}; |
| 26 |
nanosleep(&ts, NULL); |
| 27 |
// XXX spin on EINTR? |
| 28 |
%} |