2021-10-08 03:33:24 -04:00
|
|
|
/*
|
|
|
|
|
* include/haproxy/clock.h
|
|
|
|
|
* Exported parts for time-keeping
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2000-2021 Willy Tarreau - w@1wt.eu
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
|
* exclusively.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _HAPROXY_CLOCK_H
|
|
|
|
|
#define _HAPROXY_CLOCK_H
|
|
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <haproxy/api.h>
|
|
|
|
|
|
|
|
|
|
extern struct timeval start_date; /* the process's start date in wall-clock time */
|
2023-05-17 03:02:21 -04:00
|
|
|
extern struct timeval ready_date; /* date when the process was considered ready */
|
2023-04-28 08:50:29 -04:00
|
|
|
extern ullong start_time_ns; /* the process's start date in internal monotonic time (ns) */
|
2023-04-28 03:16:15 -04:00
|
|
|
extern volatile ullong global_now_ns; /* common monotonic date between all threads, in ns (wraps every 585 yr) */
|
2021-10-08 03:33:24 -04:00
|
|
|
|
2023-04-28 03:16:15 -04:00
|
|
|
extern THREAD_LOCAL ullong now_ns; /* internal monotonic date derived from real clock, in ns (wraps every 585 yr) */
|
2021-10-08 03:33:24 -04:00
|
|
|
extern THREAD_LOCAL struct timeval date; /* the real current date (wall-clock time) */
|
|
|
|
|
|
2021-10-08 09:09:17 -04:00
|
|
|
uint64_t now_cpu_time_thread(int thr);
|
2021-10-08 03:33:24 -04:00
|
|
|
uint64_t now_mono_time(void);
|
2022-11-25 02:56:46 -05:00
|
|
|
uint64_t now_mono_time_fast(void);
|
2021-10-08 03:33:24 -04:00
|
|
|
uint64_t now_cpu_time(void);
|
2023-04-04 11:21:40 -04:00
|
|
|
uint64_t now_cpu_time_fast(void);
|
2021-10-08 06:27:54 -04:00
|
|
|
void clock_set_local_source(void);
|
2022-09-21 01:37:27 -04:00
|
|
|
void clock_update_local_date(int max_wait, int interrupted);
|
|
|
|
|
void clock_update_global_date();
|
2021-10-08 03:33:24 -04:00
|
|
|
void clock_init_process_date(void);
|
|
|
|
|
void clock_init_thread_date(void);
|
2021-10-08 08:48:30 -04:00
|
|
|
int clock_setup_signal_timer(void *timer, int sig, int val);
|
2021-10-08 03:33:24 -04:00
|
|
|
char *timeofday_as_iso_us(int pad);
|
2021-10-08 04:43:59 -04:00
|
|
|
uint clock_report_idle(void);
|
|
|
|
|
void clock_leaving_poll(int timeout, int interrupted);
|
|
|
|
|
void clock_entering_poll(void);
|
2023-05-16 13:01:55 -04:00
|
|
|
void clock_adjust_now_offset(void);
|
2021-10-08 03:33:24 -04:00
|
|
|
|
2022-09-21 01:37:27 -04:00
|
|
|
static inline void clock_update_date(int max_wait, int interrupted)
|
|
|
|
|
{
|
|
|
|
|
clock_update_local_date(max_wait, interrupted);
|
|
|
|
|
clock_update_global_date();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-08 03:33:24 -04:00
|
|
|
#endif
|