• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- Time units conversion ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC___SUPPORT_TIME_UNITS_H
10 #define LLVM_LIBC_SRC___SUPPORT_TIME_UNITS_H
11 
12 #include "hdr/types/time_t.h"
13 #include "src/__support/common.h"
14 
15 namespace LIBC_NAMESPACE {
16 namespace time_units {
17 LIBC_INLINE constexpr time_t operator""_s_ns(unsigned long long s) {
18   return static_cast<time_t>(s * 1'000'000'000);
19 }
20 LIBC_INLINE constexpr time_t operator""_s_us(unsigned long long s) {
21   return static_cast<time_t>(s * 1'000'000);
22 }
23 LIBC_INLINE constexpr time_t operator""_s_ms(unsigned long long s) {
24   return static_cast<time_t>(s * 1'000);
25 }
26 LIBC_INLINE constexpr time_t operator""_ms_ns(unsigned long long ms) {
27   return static_cast<time_t>(ms * 1'000'000);
28 }
29 LIBC_INLINE constexpr time_t operator""_ms_us(unsigned long long ms) {
30   return static_cast<time_t>(ms * 1'000);
31 }
32 LIBC_INLINE constexpr time_t operator""_us_ns(unsigned long long us) {
33   return static_cast<time_t>(us * 1'000);
34 }
35 } // namespace time_units
36 } // namespace LIBC_NAMESPACE
37 
38 #endif // LLVM_LIBC_SRC___SUPPORT_TIME_UNITS_H
39