diff options
author | Christian Franke <nobody@nowhere.ws> | 2013-03-18 01:14:18 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2013-03-18 01:14:18 +0100 |
commit | 42979379e37bbf08af8a0725f2d54748f2858699 (patch) | |
tree | 8b1a86098102e9ccfda2abe2997654d424089337 /clock.py | |
parent | a99a574cae03541c75918b6874b6a05405ee8469 (diff) |
rename clock.py to linux.py and add if_nametoindex
Diffstat (limited to 'clock.py')
-rw-r--r-- | clock.py | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/clock.py b/clock.py deleted file mode 100644 index 3e97dbf..0000000 --- a/clock.py +++ /dev/null @@ -1,23 +0,0 @@ -# Courtesy of Armin Ronacher, found at StackOverflow - -import ctypes -import os - -CLOCK_MONOTONIC = 1 # see <linux/time.h> - -class timespec(ctypes.Structure): - _fields_ = [ - ('tv_sec', ctypes.c_long), - ('tv_nsec', ctypes.c_long) - ] - -librt = ctypes.CDLL('librt.so.1', use_errno=True) -clock_gettime = librt.clock_gettime -clock_gettime.argtypes = [ctypes.c_int, ctypes.POINTER(timespec)] - -def now(): - t = timespec() - if clock_gettime(CLOCK_MONOTONIC, ctypes.pointer(t)) != 0: - errno_ = ctypes.get_errno() - raise OSError(errno_, os.strerror(errno_)) - return t.tv_sec + t.tv_nsec * 1e-9 |