-
-
Couldn't load subscription status.
- Fork 414
CRuntime_Musl: fixes for time64 #3383
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. | ||
| 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
|
||
| 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, | ||
|
|
||
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.