-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging [time.zone]
, [time.clock]
, and [time.parse]
pieces of P0355R7
#1789
Merged
StephanTLavavej
merged 24 commits into
microsoft:main
from
mnatsuhara:bye_feature_chrono
Apr 6, 2021
Merged
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5f4c4ba
Merge pull request #1716 from microsoft/main
StephanTLavavej 6c87eac
<chrono>: C++20 clocks, clock_cast, tzdb::leap_seconds (#1671)
MattStephanson bf56ad9
Loading `time_zone` and `time_zone_link` names (#1723)
d-winsor 2bc79d2
Logic for time_zone sys to local conversion (#1732)
d-winsor cb2b985
Support for zoned_time (#1752)
d-winsor 74abbc2
Misc items for tzdb (#1765)
d-winsor 027fc9f
<chrono> [time.parse] (#1768)
MattStephanson 3017b91
chrono cleanups (#1779)
StephanTLavavej dde4623
`<chrono>`: Avoid unnecessary use of concepts (#1787)
StephanTLavavej 6bcb4eb
stl/msbuild: Link advapi32.lib.
StephanTLavavej 0c34af6
static_cast from int to bool to avoid warning C4800.
StephanTLavavej 37c43ed
Add run_tz_test() to report exceptions and handle old OSes.
StephanTLavavej b0f132d
Remove _Invalid_time_string to fix the objsize test.
StephanTLavavej fd6ecdb
Work around VSO-1303556, an is_constructible_v ICE.
StephanTLavavej aa54dc4
Fix memory leaks.
StephanTLavavej 620d71a
Code review feedback.
StephanTLavavej 213fced
extract time_since_epoch()
mnatsuhara e885fd0
early returns
mnatsuhara cbadcdf
small restructuring
mnatsuhara a6b6a2c
pull _For_time into an enum template parameter
mnatsuhara 10b9a70
Merge branch 'bye_feature_chrono' of https://github.com/mnatsuhara/ST…
mnatsuhara e83116e
Refactor another early-ish return.
StephanTLavavej c5a46da
Reorder _Parse_tp_or_duration, deducing _DurationType.
StephanTLavavej 20fea0a
Test a later leap second.
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
// __msvc_tzdb.hpp internal header | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#pragma once | ||
#ifndef __MSVC_TZDB_HPP | ||
#define __MSVC_TZDB_HPP | ||
#include <yvals.h> | ||
#if _STL_COMPILER_PREPROCESSOR | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <type_traits> | ||
#include <xutility> | ||
|
||
#pragma pack(push, _CRT_PACKING) | ||
#pragma warning(push, _STL_WARNING_LEVEL) | ||
#pragma warning(disable : _STL_DISABLED_WARNINGS) | ||
_STL_DISABLE_CLANG_WARNINGS | ||
#pragma push_macro("new") | ||
#undef new | ||
|
||
using __std_tzdb_epoch_milli = double; | ||
|
||
struct __std_tzdb_leap_info { | ||
uint16_t _Year; | ||
uint16_t _Month; | ||
uint16_t _Day; | ||
uint16_t _Hour; | ||
uint16_t _Negative; | ||
uint16_t _Reserved; | ||
}; | ||
|
||
enum class __std_tzdb_error { | ||
_Success = 0, | ||
_Win_error = 1, | ||
_Icu_error = 2, | ||
}; | ||
|
||
struct __std_tzdb_time_zones_info { | ||
__std_tzdb_error _Err; | ||
// timezone data version currently being used | ||
const char* _Version; | ||
size_t _Num_time_zones; | ||
// ordered list of null-terminated time_zone/time_zone_link names | ||
const char** _Names; | ||
// contains corresponding entry for every name, if: | ||
// (_Links[i] == nullptr) then _Names[i] is a time_zone | ||
// (_Links[i] != nullptr) then _Names[i] is a time_zone_link to time_zone with name _Links[i] | ||
const char** _Links; | ||
}; | ||
|
||
struct __std_tzdb_current_zone_info { | ||
__std_tzdb_error _Err; | ||
const char* _Tz_name; | ||
}; | ||
|
||
struct __std_tzdb_sys_info { | ||
__std_tzdb_error _Err; | ||
__std_tzdb_epoch_milli _Begin; | ||
__std_tzdb_epoch_milli _End; | ||
int32_t _Offset; | ||
int32_t _Save; | ||
const char* _Abbrev; | ||
}; | ||
|
||
_EXTERN_C | ||
|
||
_NODISCARD __std_tzdb_time_zones_info* __stdcall __std_tzdb_get_time_zones() noexcept; | ||
void __stdcall __std_tzdb_delete_time_zones(__std_tzdb_time_zones_info* _Info) noexcept; | ||
|
||
_NODISCARD __std_tzdb_current_zone_info* __stdcall __std_tzdb_get_current_zone() noexcept; | ||
void __stdcall __std_tzdb_delete_current_zone(__std_tzdb_current_zone_info* _Info) noexcept; | ||
|
||
_NODISCARD __std_tzdb_sys_info* __stdcall __std_tzdb_get_sys_info( | ||
const char* _Tz, size_t _Tz_len, __std_tzdb_epoch_milli _Local) noexcept; | ||
void __stdcall __std_tzdb_delete_sys_info(__std_tzdb_sys_info* _Info) noexcept; | ||
|
||
_NODISCARD __std_tzdb_leap_info* __stdcall __std_tzdb_get_leap_seconds( | ||
size_t _Prev_ls_size, size_t* _Current_ls_size) noexcept; | ||
void __stdcall __std_tzdb_delete_leap_seconds(__std_tzdb_leap_info* _Info) noexcept; | ||
|
||
_NODISCARD void* __stdcall __std_calloc_crt(size_t _Count, size_t _Size) noexcept; | ||
void __stdcall __std_free_crt(void* _Ptr) noexcept; | ||
|
||
_END_EXTERN_C | ||
|
||
_STD_BEGIN | ||
|
||
template <class _Ty> | ||
struct _Tzdb_deleter; | ||
|
||
template <> | ||
struct _Tzdb_deleter<__std_tzdb_time_zones_info> { | ||
void operator()(__std_tzdb_time_zones_info* _Info) const noexcept { | ||
__std_tzdb_delete_time_zones(_Info); | ||
} | ||
}; | ||
|
||
template <> | ||
struct _Tzdb_deleter<__std_tzdb_current_zone_info> { | ||
void operator()(__std_tzdb_current_zone_info* _Info) const noexcept { | ||
__std_tzdb_delete_current_zone(_Info); | ||
} | ||
}; | ||
|
||
template <> | ||
struct _Tzdb_deleter<__std_tzdb_sys_info> { | ||
void operator()(__std_tzdb_sys_info* _Info) const noexcept { | ||
__std_tzdb_delete_sys_info(_Info); | ||
} | ||
}; | ||
|
||
template <> | ||
struct _Tzdb_deleter<__std_tzdb_leap_info[]> { | ||
void operator()(__std_tzdb_leap_info* _Info) const noexcept { | ||
__std_tzdb_delete_leap_seconds(_Info); | ||
} | ||
}; | ||
|
||
template <class _Ty> | ||
class _Crt_allocator { | ||
public: | ||
using value_type = _Ty; | ||
using propagate_on_container_move_assignment = true_type; | ||
using is_always_equal = true_type; | ||
|
||
constexpr _Crt_allocator() noexcept = default; | ||
|
||
constexpr _Crt_allocator(const _Crt_allocator&) noexcept = default; | ||
template <class _Other> | ||
constexpr _Crt_allocator(const _Crt_allocator<_Other>&) noexcept {} | ||
|
||
_NODISCARD __declspec(allocator) _Ty* allocate(_CRT_GUARDOVERFLOW const size_t _Count) { | ||
const auto _Ptr = __std_calloc_crt(_Count, sizeof(_Ty)); | ||
if (!_Ptr) { | ||
_Xbad_alloc(); | ||
} | ||
return static_cast<_Ty*>(_Ptr); | ||
} | ||
|
||
void deallocate(_Ty* const _Ptr, size_t) noexcept { | ||
__std_free_crt(_Ptr); | ||
} | ||
}; | ||
|
||
_STD_END | ||
|
||
#pragma pop_macro("new") | ||
_STL_RESTORE_CLANG_WARNINGS | ||
#pragma warning(pop) | ||
#pragma pack(pop) | ||
#endif // _STL_COMPILER_PREPROCESSOR | ||
#endif // __MSVC_TZDB_HPP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm disturbed by having a
_Meow_allocator
type in product code that doesn't satisfy the allocator requirements. It might be overkill to actually implementtemplate <class _Ty1, class _Ty2> bool operator==(const _Crt_allocator<_Ty1>&, const _Crt_allocator<_Ty2>&)
, however - could we at least have a comment to the effect that this isn't really an allocator because==
is missing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have a properly implemented
==
(as product code should hold itself to a high standard), even though we aren't actually using it yet.