This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 420
CRuntime_Musl: fixes for time64 #3383
Open
omerfirmak
wants to merge
1
commit into
dlang:dmd-cxx
Choose a base branch
from
omerfirmak:dmd-cxx-time64
base: dmd-cxx
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Support time64 changes for `CRuntime_Musl` | ||
|
||
Up to v1.1.24, Musl used a 32 bits `time_t` on 32 bits architectures. | ||
Since v1.2.0, `time_t` is now always 64 bits. | ||
From this release, druntime will also default to a 64 bits `time_t` | ||
on 32 bits architecture, unless the `CRuntime_Musl_Pre_Time64` is provided. | ||
|
||
This change should only affect packagers for Musl-based systems who support | ||
32 bits architectures (64 bits architectures already use 64 bits `time_t`), | ||
who now need to define `CRuntime_Musl_Pre_Time64` both when building | ||
druntime / Phobos and in the default configuration, if the linked Musl is < 1.2.0. | ||
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 |
---|---|---|
|
@@ -16,9 +16,17 @@ | |
module core.stdc.time; | ||
|
||
version (Posix) | ||
{ | ||
public import core.sys.posix.stdc.time; | ||
import core.sys.posix.sys.types : CRuntime_Musl_Needs_Time64_Compat_Layer; | ||
} | ||
else version (Windows) | ||
{ | ||
public import core.sys.windows.stdc.time; | ||
// This enum is defined only for Posix, this file is the only one | ||
// needing it in `core.stdc`. | ||
private enum CRuntime_Musl_Needs_Time64_Compat_Layer = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps all function declarations present here should be moved to |
||
} | ||
else | ||
static assert(0, "unsupported system"); | ||
|
||
|
@@ -29,20 +37,45 @@ extern (C): | |
nothrow: | ||
@nogc: | ||
|
||
/// | ||
pure double difftime(time_t time1, time_t time0); // MT-Safe | ||
/// | ||
@system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale | ||
/// | ||
time_t time(scope time_t* timer); | ||
static if (CRuntime_Musl_Needs_Time64_Compat_Layer) | ||
{ | ||
pure double __difftime64(time_t time1, time_t time0); // MT-Safe | ||
@system time_t __mktime64(scope tm* timeptr); // @system: MT-Safe env locale | ||
time_t __time64(scope time_t* timer); | ||
@system char* __ctime64(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale | ||
@system tm* __gmtime64(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
@system tm* __localtime64(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
|
||
/// | ||
alias time = __time64; | ||
/// | ||
alias difftime = __difftime64; | ||
/// | ||
alias mktime = __mktime64; | ||
/// | ||
alias gmtime = __gmtime64; | ||
/// | ||
alias localtime = __localtime64; | ||
/// | ||
alias ctime = __ctime64; | ||
} | ||
else | ||
{ | ||
/// | ||
pure double difftime(time_t time1, time_t time0); // MT-Safe | ||
/// | ||
@system time_t mktime(scope tm* timeptr); // @system: MT-Safe env locale | ||
/// | ||
time_t time(scope time_t* timer); | ||
/// | ||
@system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale | ||
/// | ||
@system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
/// | ||
@system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
} | ||
|
||
/// | ||
@system char* asctime(const scope tm* timeptr); // @system: MT-Unsafe race:asctime locale | ||
/// | ||
@system char* ctime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf race:asctime env locale | ||
/// | ||
@system tm* gmtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
/// | ||
@system tm* localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale | ||
/// | ||
@system size_t strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale | ||
omerfirmak marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
---|---|---|
|
@@ -13,6 +13,22 @@ extern(C): | |
@nogc: | ||
nothrow: | ||
|
||
static if (CRuntime_Musl_Needs_Time64_Compat_Layer) | ||
{ | ||
// SO_TIMESTAMP_OLD & friends | ||
// https://www.kernel.org/doc/Documentation/networking/timestamping.txt | ||
enum SO_TIMESTAMP = 29; | ||
enum SO_TIMESTAMPNS = 35; | ||
enum SO_TIMESTAMPING = 37; | ||
|
||
} | ||
else | ||
{ | ||
enum SO_TIMESTAMP = 63; | ||
enum SO_TIMESTAMPNS = 64; | ||
enum SO_TIMESTAMPING = 65; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, so now there is backwards compatibility with Musl, but not older Linux kernels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably should just ditch backward compatibility for Musl. And that's a mistake, too. |
||
} | ||
|
||
enum | ||
{ | ||
// Protocol families. | ||
|
@@ -123,14 +139,14 @@ enum | |
SO_GET_FILTER = SO_ATTACH_FILTER, | ||
|
||
SO_PEERNAME = 28, | ||
SO_TIMESTAMP = 29, | ||
// SO_TIMESTAMP See above | ||
SCM_TIMESTAMP = SO_TIMESTAMP, | ||
|
||
SO_PASSSEC = 34, | ||
SO_TIMESTAMPNS = 35, | ||
// SO_TIMESTAMPNS See above | ||
SCM_TIMESTAMPNS = SO_TIMESTAMPNS, | ||
SO_MARK = 36, | ||
SO_TIMESTAMPING = 37, | ||
// SO_TIMESTAMPING See above | ||
SCM_TIMESTAMPING = SO_TIMESTAMPING, | ||
SO_RXQ_OVFL = 40, | ||
SO_WIFI_STATUS = 41, | ||
|
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
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
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
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.
Is there a configure test that could be used by gdc for its build system, so that the burden isn't shouldered to the users/client code?
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.
In particular, when running the testsuite.