Skip to content

Commit 4e7a4c9

Browse files
committed
add missing functions defined as inline, remove '_BUILD_STD_MODULE'
1 parent b6bf097 commit 4e7a4c9

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

libcxx/modules/std.compat/ctime.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,44 @@ export {
2727
using ::time _LIBCPP_USING_IF_EXISTS;
2828
using ::timespec_get _LIBCPP_USING_IF_EXISTS;
2929
#endif
30+
31+
// A workaround for UCRT because it defines these functions
32+
// as static and that causes the error "internal linkage cannot be exported"
33+
#ifdef _LIBCPP_ABI_VCRUNTIME
34+
35+
template <int = 0>
36+
inline char* __CRTDECL ctime(_In_ time_t const* const _Time) noexcept {
37+
return _ctime64(_Time);
38+
}
39+
40+
template <int = 0>
41+
inline double __CRTDECL difftime(_In_ time_t const _Time1, _In_ time_t const _Time2) noexcept {
42+
return _difftime64(_Time1, _Time2);
43+
}
44+
45+
template <int = 0>
46+
inline tm* __CRTDECL gmtime(_In_ time_t const* const _Time) noexcept {
47+
return _gmtime64(_Time);
48+
}
49+
50+
template <int = 0>
51+
inline tm* __CRTDECL localtime(_In_ time_t const* const _Time) noexcept {
52+
return _localtime64(_Time);
53+
}
54+
55+
template <int = 0>
56+
inline time_t __CRTDECL mktime(_Inout_ tm* const _Tm) noexcept {
57+
return _mktime64(_Tm);
58+
}
59+
60+
template <int = 0>
61+
inline time_t __CRTDECL time(_Out_opt_ time_t* const _Time) noexcept {
62+
return _time64(_Time);
63+
}
64+
65+
template <int = 0>
66+
inline int __CRTDECL timespec_get(_Out_ timespec* const _Ts, _In_ int const _Base) noexcept {
67+
return _timespec64_get(reinterpret_cast<_timespec64*>(_Ts), _Base);
68+
}
69+
#endif
3070
} // export

libcxx/modules/std.cppm.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ module;
5151
#include <cstdio>
5252
#include <cstdlib>
5353
#include <cstring>
54-
#ifdef _LIBCPP_ABI_VCRUNTIME
55-
#define _BUILD_STD_MODULE
56-
#endif
5754
#include <ctime>
5855
#include <cuchar>
5956
#include <cwchar>

libcxx/modules/std/ctime.inc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export namespace std {
1414

1515
using std::timespec _LIBCPP_USING_IF_EXISTS;
1616
using std::tm _LIBCPP_USING_IF_EXISTS;
17+
1718
using std::asctime _LIBCPP_USING_IF_EXISTS;
1819
using std::clock _LIBCPP_USING_IF_EXISTS;
1920
using std::strftime _LIBCPP_USING_IF_EXISTS;
@@ -27,4 +28,44 @@ export namespace std {
2728
using std::time _LIBCPP_USING_IF_EXISTS;
2829
using std::timespec_get _LIBCPP_USING_IF_EXISTS;
2930
#endif
31+
32+
// A workaround for UCRT because it defines these functions
33+
// as static and that causes the error "internal linkage cannot be exported"
34+
#ifdef _LIBCPP_ABI_VCRUNTIME
35+
36+
template <int = 0>
37+
inline char* __CRTDECL ctime(_In_ time_t const* const _Time) noexcept {
38+
return _ctime64(_Time);
39+
}
40+
41+
template <int = 0>
42+
inline double __CRTDECL difftime(_In_ time_t const _Time1, _In_ time_t const _Time2) noexcept {
43+
return _difftime64(_Time1, _Time2);
44+
}
45+
46+
template <int = 0>
47+
inline tm* __CRTDECL gmtime(_In_ time_t const* const _Time) noexcept {
48+
return _gmtime64(_Time);
49+
}
50+
51+
template <int = 0>
52+
inline tm* __CRTDECL localtime(_In_ time_t const* const _Time) noexcept {
53+
return _localtime64(_Time);
54+
}
55+
56+
template <int = 0>
57+
inline time_t __CRTDECL mktime(_Inout_ tm* const _Tm) noexcept {
58+
return _mktime64(_Tm);
59+
}
60+
61+
template <int = 0>
62+
inline time_t __CRTDECL time(_Out_opt_ time_t* const _Time) noexcept {
63+
return _time64(_Time);
64+
}
65+
66+
template <int = 0>
67+
inline int __CRTDECL timespec_get(_Out_ timespec* const _Ts, _In_ int const _Base) noexcept {
68+
return _timespec64_get(reinterpret_cast<_timespec64*>(_Ts), _Base);
69+
}
70+
#endif
3071
} // namespace std

0 commit comments

Comments
 (0)