Coverage Report

Created: 2025-10-26 07:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rocksdb/port/sys_time.h
Line
Count
Source
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
//
6
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7
// Use of this source code is governed by a BSD-style license that can be
8
// found in the LICENSE file. See the AUTHORS file for names of contributors.
9
10
// This file is a portable substitute for sys/time.h which does not exist on
11
// Windows
12
13
#pragma once
14
15
#include "rocksdb/rocksdb_namespace.h"
16
17
#if defined(OS_WIN) && (defined(_MSC_VER) || defined(__MINGW32__))
18
19
#include <time.h>
20
21
namespace ROCKSDB_NAMESPACE {
22
23
namespace port {
24
25
struct TimeVal {
26
  long tv_sec;
27
  long tv_usec;
28
};
29
30
void GetTimeOfDay(TimeVal* tv, struct timezone* tz);
31
32
inline struct tm* LocalTimeR(const time_t* timep, struct tm* result) {
33
  errno_t ret = localtime_s(result, timep);
34
  return (ret == 0) ? result : NULL;
35
}
36
37
}  // namespace port
38
39
}  // namespace ROCKSDB_NAMESPACE
40
41
#else
42
#include <sys/time.h>
43
#include <time.h>
44
45
namespace ROCKSDB_NAMESPACE {
46
47
namespace port {
48
49
using TimeVal = struct timeval;
50
51
45.1M
inline void GetTimeOfDay(TimeVal* tv, struct timezone* tz) {
52
45.1M
  gettimeofday(tv, tz);
53
45.1M
}
54
55
22.1M
inline struct tm* LocalTimeR(const time_t* timep, struct tm* result) {
56
22.1M
  return localtime_r(timep, result);
57
22.1M
}
58
59
}  // namespace port
60
61
}  // namespace ROCKSDB_NAMESPACE
62
63
#endif