Skip to content
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

Eliminate xtime and its member sec, nsec #3594

Merged
merged 6 commits into from
Mar 28, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Mar 26, 2023

This PR is currently trying to replace uses of xtime with _timespec64, because _timespec64 is

  • of a reserved name, and
  • having the same member names as the standard timespec, and
  • already available in all modes via <time.h>, and
  • layout-compatible with xtime.

Definition of _timespec64 (not available in this repo):

struct _timespec64
{
    __time64_t tv_sec;
    long       tv_nsec;
};

Definition of xtime:

STL/stl/inc/xtimec.h

Lines 23 to 26 in 5e60382

struct xtime { // store time with nanosecond resolution
__time64_t sec;
long nsec;
};

Working towards #2206.

Every function in MSVC STL that has external linkage and involves xtime is either extern "C" or inline, so I think this PR doesn't break ABI.

I'm also trying to change the name of every function, except for constructor, involving xtime/_timespec64 in order to avoid polluting overload sets.

For constructor of unique_lock, I'm adding an explicit construction tag type - perhaps we can simply remove that ctor, and some other non-standard functions.

Edit: This PR is now removing non-standard overloads. One non-standard condition_variable::wait_until overload is changed to _Wait_until_sys_time and made private.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner March 26, 2023 06:29
@StephanTLavavej StephanTLavavej added enhancement Something can be improved chrono C++20 chrono labels Mar 26, 2023
@StephanTLavavej
Copy link
Member

StephanTLavavej commented Mar 26, 2023

Thanks! As I mentioned on Discord, I would indeed like to see all of the non-Standard functions be removed, limited only by anything that affects ABI. (Stuff that's separately compiled is generally clear because either the class is marked as exported, or the functions are marked, and there are explicit calling conventions so they look "weird". You can also double-check the export surface with dumpbin /exports and do a before-and-after comparison, if altering anything in stl/src that you're unsure about.)

@StephanTLavavej
Copy link
Member

Thanks, I agree that this should preserve ABI. Leaving the parameter names as xt is fine, likewise for the filename xtime.cpp (too much of a headache to change for too little value).

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit c2527c4 into microsoft:main Mar 28, 2023
@StephanTLavavej
Copy link
Member

Thanks for carefully removing this non-Standard machinery that was allowing calls like try_lock_until(nullptr) to compile! 🙀 🛠️ 😻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrono C++20 chrono enhancement Something can be improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
  翻译: