Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(BSD) util.py:boottime: make finding libc platform independent #366

Merged
merged 2 commits into from
May 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,7 @@ def time_rfc2822():
return ts


@lru_cache()
def boottime():
"""Use sysctlbyname(3) via ctypes to find kern.boottime

Expand All @@ -1875,6 +1876,7 @@ def boottime():
@return boottime: float to be compatible with linux
"""
import ctypes
import ctypes.util

NULL_BYTES = b"\x00"

Expand All @@ -1883,7 +1885,7 @@ class timeval(ctypes.Structure):
("tv_sec", ctypes.c_int64),
("tv_usec", ctypes.c_int64)
]
libc = ctypes.CDLL('libc.so')
libc = ctypes.CDLL(ctypes.util.find_library('c'))
size = ctypes.c_size_t()
size.value = ctypes.sizeof(timeval)
buf = timeval()
Expand Down