`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?

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

```
nanosleep = nanosleep@TIME_BITS@
```

where `@TIME_BITS@` is based on value of `SIZEOF_TIME_T`, and possibly

```
nanosleep64 = __nanosleep
```

(given that we remove `static` from internal definitions).

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?

- Kirill Makurin

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

在 2025-4-15 10:22, Kirill Makurin 写道:
> --- a/mingw-w64-libraries/winpthreads/include/pthread_compat.h
> +++ b/mingw-w64-libraries/winpthreads/include/pthread_compat.h
> @@ -98,6 +98,7 @@ typedef unsigned short mode_t;
>   #ifdef __GNUC__
>
>   #define WINPTHREADS_INLINE inline
> +#define WINPTHREADS_ALWAYS_INLINE inline __attribute__((__always_inline__))

For c89 compatibility, `inline` should be `__inline__`.

Ref: https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html


> +#if SIZEOF_TIME_T == 8
> +    return clock_getres64 (clock_id, (struct _timespec64 *) res);
> +#else
> +    return clock_getres32 (clock_id, (struct _timespec32 *) res);
> +#endif

Where is `SIZEOF_TIME_T` defined?

Instead of

    ```
    #ifdef IN_WINPTHREAD
    WINPTHREAD_API int __cdecl nanosleep(const struct timespec *request, struct 
timespec *remain);
    #else
    static WINPTHREADS_ALWAYS_INLINE int __cdecl nanosleep(const struct 
timespec *request, struct
timespec *remain)
    {
      ...
    ```

Is it possible to reuse the inline definitions from headers?

    ```
    #ifdef IN_WINPTHREAD
    WINPTHREAD_API
    #else
    static WINPTHREADS_ALWAYS_INLINE
    #else
    int __cdecl nanosleep(const struct timespec *request, struct timespec 
*remain)
    {
      ...
    ```


> Other notes:
>
> Makefile.am currently unconditionally defines `WINPTHREAD_DBG=1`, maybe it 
> would make sense to add an option which will control whether this macro is 
> defined?

AFAICT it enables functions that are not exported from the DLL (only from the 
static library), so it is
not very useful. Can it be removed?


>
> I would like to move definition of `WIN32_LEAN_AND_MEAN` from Makefile.am to 
> source files (just before `#include <windows.h>`.
>

Yes it makes sense.





--
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