mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
libnm: add nm_utils_get_timestamp_msec()
This commit is contained in:
parent
07fd0502f6
commit
0132da1ddb
|
@ -6223,6 +6223,40 @@ nm_utils_format_variant_attributes (GHashTable *attributes,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* nm_utils_get_timestamp_msec():
|
||||
*
|
||||
* Gets current time in milliseconds of CLOCK_BOOTTIME.
|
||||
*
|
||||
* Returns: time in milliseconds
|
||||
*
|
||||
* Since: 1.12
|
||||
*/
|
||||
gint64
|
||||
nm_utils_get_timestamp_msec (void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
if (clock_gettime (CLOCK_BOOTTIME, &ts) != -1)
|
||||
goto success;
|
||||
|
||||
if (errno == EINVAL) {
|
||||
/* The fallback to CLOCK_MONOTONIC is taken only if we're running on a
|
||||
* criminally old kernel, prior to 2.6.39 (released on 18 May, 2011).
|
||||
* That happens during buildcheck on old builders, we don't expect to
|
||||
* be actually runs on kernels that old. */
|
||||
if (clock_gettime (CLOCK_MONOTONIC, &ts) != -1)
|
||||
goto success;
|
||||
}
|
||||
|
||||
g_return_val_if_reached (-1);
|
||||
|
||||
success:
|
||||
return (((gint64) ts.tv_sec) * 1000) + (ts.tv_nsec / 1000000);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_utils_version:
|
||||
*
|
||||
|
|
|
@ -248,6 +248,11 @@ NMTCTfilter *nm_utils_tc_tfilter_from_str (const char *str, GError **error);
|
|||
NM_AVAILABLE_IN_1_12
|
||||
char *nm_utils_tc_tfilter_to_str (NMTCTfilter *tfilter, GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NM_AVAILABLE_IN_1_12
|
||||
gint64 nm_utils_get_timestamp_msec (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_UTILS_H__ */
|
||||
|
|
|
@ -1366,5 +1366,6 @@ global:
|
|||
nm_setting_wireless_get_wake_on_wlan;
|
||||
nm_setting_wireless_wake_on_wlan_get_type;
|
||||
nm_settings_connection_flags_get_type;
|
||||
nm_utils_get_timestamp_msec;
|
||||
nm_vpn_service_plugin_shutdown;
|
||||
} libnm_1_10_0;
|
||||
|
|
|
@ -70,8 +70,10 @@ nm_checkpoint_get_devices (NMCheckpoint *checkpoint)
|
|||
* nm_checkpoint_get_created:
|
||||
* @checkpoint: a #NMCheckpoint
|
||||
*
|
||||
* Gets the timestamp (in CLOCK_BOOTTIME milliseconds)
|
||||
* of checkpoint creation.
|
||||
* Gets the timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
|
||||
*
|
||||
* Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
|
||||
* comparing to this value.
|
||||
*
|
||||
* Returns: the timestamp of checkpoint creation.
|
||||
*
|
||||
|
|
|
@ -276,6 +276,9 @@ nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device,
|
|||
* Returns the timestamp (in CLOCK_BOOTTIME milliseconds) for the last finished
|
||||
* network scan. A value of -1 means the device never scanned for access points.
|
||||
*
|
||||
* Use nm_utils_get_timestamp_msec() to obtain current time value suitable for
|
||||
* comparing to this value.
|
||||
*
|
||||
* Returns: the last scan time in seconds
|
||||
*
|
||||
* Since: 1.12
|
||||
|
|
Loading…
Reference in a new issue