summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/clocks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:44 +0000
commit836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch)
tree1604da8f482d02effa033c94a84be42bc0c848c3 /src/libnetdata/clocks
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz
netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/libnetdata/clocks/README.md10
-rw-r--r--src/libnetdata/clocks/clocks.c (renamed from libnetdata/clocks/clocks.c)10
-rw-r--r--src/libnetdata/clocks/clocks.h (renamed from libnetdata/clocks/clocks.h)7
3 files changed, 18 insertions, 9 deletions
diff --git a/src/libnetdata/clocks/README.md b/src/libnetdata/clocks/README.md
new file mode 100644
index 000000000..0ede05e83
--- /dev/null
+++ b/src/libnetdata/clocks/README.md
@@ -0,0 +1,10 @@
+<!--
+custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/libnetdata/clocks/README.md"
+title: "Clocks"
+sidebar_label: "Clocks"
+learn_status: "Published"
+learn_topic_type: "References"
+learn_rel_path: "Developers/libnetdata"
+-->
+
+# Clocks \ No newline at end of file
diff --git a/libnetdata/clocks/clocks.c b/src/libnetdata/clocks/clocks.c
index adbad045f..e1a3e64cb 100644
--- a/libnetdata/clocks/clocks.c
+++ b/src/libnetdata/clocks/clocks.c
@@ -60,7 +60,7 @@ static usec_t get_clock_resolution(clockid_t clock) {
if(clock_getres(clock, &ts) == 0) {
usec_t ret = (usec_t)ts.tv_sec * USEC_PER_SEC + (usec_t)ts.tv_nsec / NSEC_PER_USEC;
- if(!ret && ts.tv_nsec > 0 && ts.tv_nsec < NSEC_PER_USEC)
+ if(!ret && ts.tv_nsec > 0 && ts.tv_nsec < (long int)NSEC_PER_USEC)
return (usec_t)1;
else if(ret > MAX_CLOCK_RESOLUTION_UT) {
@@ -92,7 +92,7 @@ void clocks_init(void) {
inline time_t now_sec(clockid_t clk_id) {
struct timespec ts;
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
- netdata_log_error("clock_gettime(%d, &timespec) failed.", clk_id);
+ netdata_log_error("clock_gettime(%ld, &timespec) failed.", (long int)clk_id);
return 0;
}
return ts.tv_sec;
@@ -101,7 +101,7 @@ inline time_t now_sec(clockid_t clk_id) {
inline usec_t now_usec(clockid_t clk_id) {
struct timespec ts;
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
- netdata_log_error("clock_gettime(%d, &timespec) failed.", clk_id);
+ netdata_log_error("clock_gettime(%ld, &timespec) failed.", (long int)clk_id);
return 0;
}
return (usec_t)ts.tv_sec * USEC_PER_SEC + (usec_t)(ts.tv_nsec % NSEC_PER_SEC) / NSEC_PER_USEC;
@@ -111,7 +111,7 @@ inline int now_timeval(clockid_t clk_id, struct timeval *tv) {
struct timespec ts;
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
- netdata_log_error("clock_gettime(%d, &timespec) failed.", clk_id);
+ netdata_log_error("clock_gettime(%ld, &timespec) failed.", (long int)clk_id);
tv->tv_sec = 0;
tv->tv_usec = 0;
return -1;
@@ -243,7 +243,7 @@ void sleep_to_absolute_time(usec_t usec) {
sleep_usec(usec);
}
}
-};
+}
#endif
#define HEARTBEAT_ALIGNMENT_STATISTICS_SIZE 10
diff --git a/libnetdata/clocks/clocks.h b/src/libnetdata/clocks/clocks.h
index 2beb14ed9..f989fd6b8 100644
--- a/libnetdata/clocks/clocks.h
+++ b/src/libnetdata/clocks/clocks.h
@@ -5,15 +5,14 @@
#include "../libnetdata.h"
-#ifndef HAVE_STRUCT_TIMESPEC
+#ifndef HAVE_CLOCK_GETTIME
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
-#ifndef HAVE_CLOCKID_T
-typedef int clockid_t;
+#ifndef HAVE_CLOCK_GETTIME
#endif
typedef uint64_t nsec_t;
@@ -143,7 +142,7 @@ usec_t heartbeat_next(heartbeat_t *hb, usec_t tick);
void heartbeat_statistics(usec_t *min_ptr, usec_t *max_ptr, usec_t *average_ptr, size_t *count_ptr);
void sleep_usec_with_now(usec_t usec, usec_t started_ut);
-#define sleep_usec(usec) sleep_usec_with_now(usec, 0);
+#define sleep_usec(usec) sleep_usec_with_now(usec, 0)
void clocks_init(void);