summaryrefslogtreecommitdiff
path: root/src/basic/time-util.c
AgeCommit message (Collapse)Author
2016-06-06time-util: add triple timestamp objectLennart Poettering
We already have a double timestamp object that we use whenever we need both a MONOTONIC and a REALTIME timestamp taken and stored. With this change we also add a triple timestamp object that in addition stores a BOOTTIME timestamp, which is useful for a few usecases. Note that we keep dual_timestamp around, as it is useful in many cases where triple_timestamp is not, in particular because retrieving the monotonic and realtime timestamps is much cheaper on Linux that getting the boottime timestamp.
2016-04-22tree-wide: don't assume CLOCK_BOOTIME is generally availableLennart Poettering
Before we invoke now(CLOCK_BOOTTIME), let's make sure we actually have that clock, since now() will otherwise hit an assert. Specifically, let's refuse CLOCK_BOOTTIME early in sd-event if the kernel doesn't actually support it. This is a follow-up for #3037, and specifically: https://github.com/systemd/systemd/pull/3037#issuecomment-210199167
2016-04-01Revert "time-util: fall back to CLOCK_MONOTONIC if CLOCK_BOOTTIME unsupported"Lennart Poettering
2016-03-15time-util: fall back to CLOCK_MONOTONIC if CLOCK_BOOTTIME unsupportedLubomir Rintel
It was added in 2.6.39, and causes an assertion to fail when running in mock hosted on 2.6.23-based RHEL-6: Assertion 'clock_gettime(map_clock_id(clock_id), &ts) == 0' failed at systemd/src/basic/time-util.c:70, function now(). Aborting.
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
2016-02-20time-util: check for overflow in conversion from ts to nsec_tZbigniew Jędrzejewski-Szmek
CID #1320855.
2016-02-18time-util: rewrite check in a way that does not confuse gccZbigniew Jędrzejewski-Szmek
gcc thinks that multiplier might be unitialized. Split out the inner loop to make the function easier to grok.
2016-02-15time-util: Rename and fix call of deserialize_timestamp_value()Benjamin Robin
The deserialize_timestamp_value() is renamed timestamp_deserialize() to be more consistent with dual_timestamp_deserialize() And add the NULL check back on realtime and monotonic
2016-02-16time-util: introduce deserialize_timestamp_value()Alexander Kuleshov
The time-util.c provides dual_timestamp_deserialize() function to convert value to usec_t and set it as value of ts->monotonic and ts->realtime. There are some places in code which do the same but only for one clockid_t (realtime or monotonic), when dual_timestamp_deserialize() sets value of both. This patch introduces the deserialize_timestamp_value() which converts a given value to usec_t and write it to a given timestamp.
2016-02-12time-util: map ALARM clockids to non-ALARM clockids in now()Lennart Poettering
Fixes: #2597
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-02-10time-util: make timespec_load_nsec() staticAlexander Kuleshov
The timespec_load_nsec() function has no callers outside of the time-util.c, so we can make it static.
2016-02-09Merge pull request #2542 from 0xAX/get_ts_deltaLennart Poettering
time-util: cleanups
2016-02-09time-util: introduce usec_sub()Alexander Kuleshov
The dual_timestamp_from_realtime(), dual_timestamp_from_monotonic() and dual_timestamp_from_boottime_or_monotonic() shares the same code for comparison given ts with delta. Let's move it to the separate inline function to prevent code duplication.
2016-02-09time-util: merge format_timestamp_internal() and format_timestamp_internal_us()Alexander Kuleshov
The time_util.c provides format_timestamp_internal() and format_timestamp_internal_us() functions for a timestamp formating. Both functions are very similar and differ only in formats handling. We can add additional boolean parameter to the format_timestamp_internal() function which will represent is a format for us timestamp or not. This allows us to get rid of format_timestamp_internal_us() that is prevent code duplication. We can remove format_timestamp_internal_us() safely, because it is static and has no users outside of the time_util.c. New fourth parameter will be passed inside of the format_timestamp(), format_timestamp_us() and etc, functions, but the public API is not changed.
2016-02-06time-util: use dual_timestamp_get()Alexander Kuleshov
The time-util.c provides dual_timestamp_get() function for getting realtime and monotonic timestamps. Let's use it instead of direct realtime/monotonic calculation.
2015-12-01basic: re-sort includesThomas Hindoe Paaboel Andersen
My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
2015-11-30basic: include only what we useThomas Hindoe Paaboel Andersen
This is a cleaned up result of running iwyu but without forward declarations on src/basic.
2015-11-17calendarspec: sub-second support, v3Hristo Venev
2015-11-13util-lib: when parsing time values, accept "M" as short for "month"Lennart Poettering
nginx defines an uppercase "M" that way (in contrast to the lowercase "m" for "minute"), and it sounds like an OK logic to follow, so that we understand a true superset of time values nginx understands. http://nginx.org/en/docs/syntax.html
2015-11-10time-util: add parse_time(), which is like parse_sec() but allows ↵Lennart Poettering
specification of default time unit if none is specified This is useful if we want to parse RLIMIT_RTTIME values where the common UNIX syntax is without any units but refers to a non-second unit (µs in this case), but where we want to allow specification of units.
2015-11-03Time-util: introduce usec to jiffiesSusant Sahani
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move a number of fs operations into fs-util.[ch]Lennart Poettering
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering
2015-10-25basic: use the return value of endswithHristo Venev
It returns the position where the suffix begins, which can be used for strndup to extract the prefix without calling strlen.
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-10-15basic: parse_timestamp UTC and fractional seconds supportHristo Venev
2015-10-15basic: add mktime_or_timegm and localtime_or_gmtime_rHristo Venev
to time-util.h. They take an extra argument `bool utc`.
2015-09-01tree-wide: do not shadow the global var timezoneThomas Hindoe Paaboel Andersen
2015-08-28Merge pull request #1063 from poettering/dbus-interface-from-typeTom Gundersen
cgls/cgtop: a variety of modernizations
2015-08-28cgtop: major modernizationsLennart Poettering
In preparation of the unified cgroup support, let's clean up cgtop: a) rework time code to be based on "nsec_t" rather than "struct timespec" b) Introduce long option --order= for selecting ordering c) count number of processes only in the main hierarchy, don't bother with the controller hierarchies. We don't allow orthogonal hierarchies in systemd anymore, hence there's no point to check the other hierarchies. d) Deal with non-monotonic cpuacct values (see #749) e) When sorting groups, don't do prefix compare when ordering by number of tasks, since this is not accumulative for all children. f) Actually make --cpu without parameter work g) Don't output control characters when we get them as input. Fixes #749.
2015-08-26time-util: add new get_timezone() call to get local timezoneLennart Poettering
Let's move the timedated-specific code to time-util.h and make it generic.
2015-08-24machined: introduce pseudo-machine ".host" refererring to the host systemLennart Poettering
Some of the operations machined/machinectl implement are also very useful when applied to the host system (such as machinectl login, machinectl shell or machinectl status), hence introduce a pseudo-machine by the name of ".host" in machined that refers to the host system, and may be used top execute operations on the host system with. This copies the pseudo-image ".host" machined already implements for image related commands. (This commit also adds a PK privilege for opening a PTY in a container, which was previously not accessible for non-root.)
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/