Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-07 Thread Kagamin via Digitalmars-d-learn
Because it's used with C `time` function 
https://github.com/dlang/druntime/blob/master/src/core/stdc/time.d#L37 which is provided by msvcrt as 32-bit function. 64-bit variant has a different name.


Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-07 Thread Petar via Digitalmars-d-learn

On Friday, 7 August 2020 at 05:37:32 UTC, Andrej Mitrovic wrote:
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic 
wrote:

```
C:\dev> rdmd -m64 --eval="import core.stdc.time; 
writeln(time_t.sizeof);"

4
```

According to MSDN this should not be the case:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019

time is a wrapper for _time64 and **time_t is, by default, 
equivalent to __time64_t**.


But in Druntime it's defined as a 32-bit type: 
https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42


I filed it as an issue to get more eyes / feedback: 
https://issues.dlang.org/show_bug.cgi?id=21134



As far as I gather, this was changed with MSVC 2005 [0], so 
perhaps the relevent change wasn't applied to the druntime 
windows bindings. Also keep in mind that we revamped a large 
portion of the Windows bindins in 2015 [1], whose code was based 
on MinGW IIRC.


In versions of Visual C++ and Microsoft C/C++ before Visual 
Studio 2005, time_t was a long int (32 bits) and hence could 
not be used for dates past 3:14:07 January 19, 2038, UTC. 
time_t is now equivalent to __time64_t by default, but defining 
_USE_32BIT_TIME_T changes time_t to __time32_t and forces many 
time functions to call versions that take the 32-bit time_t. 
For more information, see Standard Types and comments in the 
documentation for the individual time functions.


(^ Source [0])

[0]:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/time-management?view=vs-2019
[1]: https://github.com/dlang/druntime/pull/1402

Edit: I see you're discussing core.stdc.time, which actually 
wasn't part of the changes in [1]. In any case, druntime should 
offer both time_t, __time32_t, and __time64_t, and have time_t 
time() default to 64-bit. I do wonder what exactly is exported 
from UCRT as time(), as from the docs it looks it should be just 
a macro, but if anyone had used time() one Windows (from D) and 
didn't get linker errors or memory corruption, then I suppose 
they're still defaulting it to 32-bit to avoid ABI breakages.


Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-06 Thread Andrej Mitrovic via Digitalmars-d-learn
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic 
wrote:

```
C:\dev> rdmd -m64 --eval="import core.stdc.time; 
writeln(time_t.sizeof);"

4
```

According to MSDN this should not be the case:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019

time is a wrapper for _time64 and **time_t is, by default, 
equivalent to __time64_t**.


But in Druntime it's defined as a 32-bit type: 
https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42


I filed it as an issue to get more eyes / feedback: 
https://issues.dlang.org/show_bug.cgi?id=21134


Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-05 Thread Andrej Mitrovic via Digitalmars-d-learn
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic 
wrote:

```
C:\dev> rdmd -m64 --eval="import core.stdc.time; 
writeln(time_t.sizeof);"

4
```

According to MSDN this should not be the case:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019

time is a wrapper for _time64 and **time_t is, by default, 
equivalent to __time64_t**.


But in Druntime it's defined as a 32-bit type: 
https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42


It looks like this definition was there from at least 2008 (!!), 
and probably earlier than that but I don't have the SVN sources: 
https://github.com/dlang/druntime/blob/6837c0cd426f7e828aec1a2bdc941ac9b722dd14/import/stdc/time.d#L49



So basically, just around the time the first 64-bit version of 
Windows was released. I'm guessing it was just neglected..


Why is time_t defined as a 32-bit type on Windows?

2020-08-05 Thread Andrej Mitrovic via Digitalmars-d-learn

```
C:\dev> rdmd -m64 --eval="import core.stdc.time; 
writeln(time_t.sizeof);"

4
```

According to MSDN this should not be the case:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019

time is a wrapper for _time64 and **time_t is, by default, 
equivalent to __time64_t**.


But in Druntime it's defined as a 32-bit type: 
https://github.com/dlang/druntime/blob/349d63750d55d078426d4f433cba512625f8a3a3/src/core/sys/windows/stdc/time.d#L42