aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libevent/evutil_time.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:12 +0300
commit49116032d905455a7b1c994e4a696afc885c1e71 (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/libevent/evutil_time.c
parent4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff)
downloadydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/libevent/evutil_time.c')
-rw-r--r--contrib/libs/libevent/evutil_time.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/contrib/libs/libevent/evutil_time.c b/contrib/libs/libevent/evutil_time.c
index 798d5fe7eb..c327218227 100644
--- a/contrib/libs/libevent/evutil_time.c
+++ b/contrib/libs/libevent/evutil_time.c
@@ -65,9 +65,9 @@
#ifndef EVENT__HAVE_GETTIMEOFDAY
/* No gettimeofday; this must be windows. */
-
-typedef void (WINAPI *GetSystemTimePreciseAsFileTime_fn_t) (LPFILETIME);
-
+
+typedef void (WINAPI *GetSystemTimePreciseAsFileTime_fn_t) (LPFILETIME);
+
int
evutil_gettimeofday(struct timeval *tv, struct timezone *tz)
{
@@ -93,23 +93,23 @@ evutil_gettimeofday(struct timeval *tv, struct timezone *tz)
if (tv == NULL)
return -1;
- static GetSystemTimePreciseAsFileTime_fn_t GetSystemTimePreciseAsFileTime_fn = NULL;
- static int check_precise = 1;
-
- if (EVUTIL_UNLIKELY(check_precise)) {
- HMODULE h = evutil_load_windows_system_library_(TEXT("kernel32.dll"));
- if (h != NULL)
- GetSystemTimePreciseAsFileTime_fn =
- (GetSystemTimePreciseAsFileTime_fn_t)
- GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
- check_precise = 0;
- }
-
- if (GetSystemTimePreciseAsFileTime_fn != NULL)
- GetSystemTimePreciseAsFileTime_fn(&ft.ft_ft);
- else
- GetSystemTimeAsFileTime(&ft.ft_ft);
-
+ static GetSystemTimePreciseAsFileTime_fn_t GetSystemTimePreciseAsFileTime_fn = NULL;
+ static int check_precise = 1;
+
+ if (EVUTIL_UNLIKELY(check_precise)) {
+ HMODULE h = evutil_load_windows_system_library_(TEXT("kernel32.dll"));
+ if (h != NULL)
+ GetSystemTimePreciseAsFileTime_fn =
+ (GetSystemTimePreciseAsFileTime_fn_t)
+ GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
+ check_precise = 0;
+ }
+
+ if (GetSystemTimePreciseAsFileTime_fn != NULL)
+ GetSystemTimePreciseAsFileTime_fn(&ft.ft_ft);
+ else
+ GetSystemTimeAsFileTime(&ft.ft_ft);
+
if (EVUTIL_UNLIKELY(ft.ft_64 < EPOCH_BIAS)) {
/* Time before the unix epoch. */
return -1;
@@ -144,22 +144,22 @@ evutil_usleep_(const struct timeval *tv)
return;
#if defined(_WIN32)
{
- __int64 usec;
- LARGE_INTEGER li;
- HANDLE timer;
-
- usec = tv->tv_sec * 1000000LL + tv->tv_usec;
- if (!usec)
- return;
-
- li.QuadPart = -10LL * usec;
- timer = CreateWaitableTimer(NULL, TRUE, NULL);
- if (!timer)
- return;
-
- SetWaitableTimer(timer, &li, 0, NULL, NULL, 0);
- WaitForSingleObject(timer, INFINITE);
- CloseHandle(timer);
+ __int64 usec;
+ LARGE_INTEGER li;
+ HANDLE timer;
+
+ usec = tv->tv_sec * 1000000LL + tv->tv_usec;
+ if (!usec)
+ return;
+
+ li.QuadPart = -10LL * usec;
+ timer = CreateWaitableTimer(NULL, TRUE, NULL);
+ if (!timer)
+ return;
+
+ SetWaitableTimer(timer, &li, 0, NULL, NULL, 0);
+ WaitForSingleObject(timer, INFINITE);
+ CloseHandle(timer);
}
#elif defined(EVENT__HAVE_NANOSLEEP)
{
@@ -190,28 +190,28 @@ evutil_date_rfc1123(char *date, const size_t datelen, const struct tm *tm)
time_t t = time(NULL);
-#if defined(EVENT__HAVE__GMTIME64_S) || !defined(_WIN32)
+#if defined(EVENT__HAVE__GMTIME64_S) || !defined(_WIN32)
struct tm sys;
#endif
/* If `tm` is null, set system's current time. */
if (tm == NULL) {
-#if !defined(_WIN32)
+#if !defined(_WIN32)
gmtime_r(&t, &sys);
tm = &sys;
- /** detect _gmtime64()/_gmtime64_s() */
-#elif defined(EVENT__HAVE__GMTIME64_S)
- errno_t err;
- err = _gmtime64_s(&sys, &t);
- if (err) {
- event_errx(1, "Invalid argument to _gmtime64_s");
- } else {
- tm = &sys;
- }
-#elif defined(EVENT__HAVE__GMTIME64)
- tm = _gmtime64(&t);
-#else
- tm = gmtime(&t);
+ /** detect _gmtime64()/_gmtime64_s() */
+#elif defined(EVENT__HAVE__GMTIME64_S)
+ errno_t err;
+ err = _gmtime64_s(&sys, &t);
+ if (err) {
+ event_errx(1, "Invalid argument to _gmtime64_s");
+ } else {
+ tm = &sys;
+ }
+#elif defined(EVENT__HAVE__GMTIME64)
+ tm = _gmtime64(&t);
+#else
+ tm = gmtime(&t);
#endif
}