Skip to content

Commit

Permalink
#1470: use a Cythonized monotonic time by default
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@15366 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 23, 2017
1 parent ddc063a commit 92fb32c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include COPYING NEWS README
include xpra/monotonic_ctime.h
include xpra/monotonic_ctime.c
include xpra/buffers/memalign.h
include xpra/buffers/memalign.c
include xpra/buffers/buffers.h
Expand Down
11 changes: 11 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ def pkgconfig(*pkgs_options, **ekw):
#ensure we remove the files we generate:
CLEAN_FILES = [
"xpra/build_info.py",
"xpra/monotonic_time.c",
"xpra/gtk_common/gdk_atoms.c",
"xpra/x11/gtk2/constants.pxi",
"xpra/x11/gtk2/gdk_bindings.c",
Expand Down Expand Up @@ -1650,6 +1651,16 @@ def osx_pkgconfig(*pkgs_options, **ekw):
**quartz_pkgconfig
))

if not WIN32:
monotonic_time_pkgconfig = pkgconfig()
if not OSX:
add_to_keywords(monotonic_time_pkgconfig, 'extra_link_args', "-lrt")
cython_add(Extension("xpra.monotonic_time",
["xpra/monotonic_time.pyx", "xpra/monotonic_ctime.c"],
**monotonic_time_pkgconfig
))


toggle_packages(x11_ENABLED, "xpra.x11", "xpra.x11.bindings")
if x11_ENABLED:
make_constants("xpra", "x11", "bindings", "constants")
Expand Down
18 changes: 2 additions & 16 deletions src/xpra/os_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,9 @@ def uupdate(ustr):


monotonic_time = time.time
if os.environ.get("XPRA_MONOTONIC_TIME") and not (WIN32 or OSX):
if os.environ.get("XPRA_MONOTONIC_TIME", "1")=="1" and not WIN32:
try:
CLOCK_MONOTONIC_RAW = 4 # 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 _monotonic_time():
t = timespec()
if clock_gettime(CLOCK_MONOTONIC_RAW , ctypes.pointer(t)) != 0:
errno_ = ctypes.get_errno()
raise OSError(errno_, os.strerror(errno_))
return t.tv_sec + t.tv_nsec * 1e-9
from xpra.monotonic_time import monotonic_time as _monotonic_time
_monotonic_time()
monotonic_time = _monotonic_time
except Exception as e:
Expand Down

0 comments on commit 92fb32c

Please sign in to comment.