Thanks for the link related to `clock_gettime`.

Is `_USE_32BIT_TIME_T` reliable to determine size of time_t?

I know mingw-w64 header files define `_USE_32BIT_TIME_T`, so it should be ok? 
Also, AFAIK Microsoft header files for UCRT always use 64-bit time_t unless 
`_USE_32BIT_TIME_T` is explicitly defined, so `_USE_32BIT_TIME_T` should be 
sufficient.

It just seemed to me that use of `SIZEOF_TIME_T` would be a bit cleaner, but it 
seems `_USE_32BIT_TIME_T` is as good.

If I remove `AC_CHECK_SIZEOF(time_t)`, should I keep `#include "config.h` in 
source files? I think it is good to have config.h included in case more checks 
added in future.

(Just some reasoning to make sure we're on the same page here).

The reason to provide external symbol without the suffix is to not break 
existing binaries/static libraries. It makes sense to me that unsuffixed 
version would use the same size of time_t as during the compilation. New 
clients will use explicitly sized version through inline definitions in header 
files.

I think if someone would build `winpthreads` with either 
`__MINGW_USE_VC2005_COMPAT` (with 32-bit msvcr*.dll) or `_USE_32BIT_TIME_T` 
(UCRT + MSVC) they would expect unsuffixed versions to use time_t of the 
corresponding size.

- Kirill Makurin

________________________________
From: LIU Hao
Sent: Saturday, April 19, 2025 11:05 PM
To: Kirill Makurin; mingw-w64-public@lists.sourceforge.net
Subject: Re: [Mingw-w64-public] winpthreads: add support for _USE_32BIT_TIME_T 
and _TIME_BITS macros

在 2025-4-19 21:45, Kirill Makurin 写道:
> `SIZEOF_TIME_T` is defined in config.h as the result of 
> `AC_CHECK_SIZEOF(time_t)` added to configure.ac.
> (I did not included result from running `autoreconf` in the patches).
>
> Thanks for noticing usage of `inline`, I think it also makes sense for 
> existing `WINPTHREADS_INLINE `.
>
> The `WINPTHREAD_DBG` seems to be used to enable some additional debug output. 
> I didn't notice that
> function protected with this macro are not used at all. I think we're good to 
> get rid of this macro?

In source files we can check for `_USE_32BIT_TIME_T`.

I kinda think it's not correct to use configure to check for size of `time_t`, 
as it's part of ABI and
can't be changed; had better be hard-coded.


> Reuse of inline definitions should be possible, I think. If not the libtool 
> issue, I would prefer to have
> a .def file which has something like this

DEF is for the shared library only, so doesn't seem an option.


> I also forgot to mention setting of `errno` to `ERANGE` in clock_gettime32 if 
> time does not fit in 32bit
> time_t. Is there any better `errno` value for this?

https://pubs.opengroup.org/onlinepubs/9799919799/functions/clock_gettime.html

    The clock_gettime() function shall fail if:

    [EOVERFLOW]
    The number of seconds will not fit in an object of type time_t.


--
Best regards,
LIU Hao

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to