I wrote:

> LIU Hao wrote:
>
>> Is there a reason why `_POSIX_TIMERS` is no longer defined? In GCC source 
>> code there's a check for it:
>> https://github.com/gnutools/gcc/blob/9c3dc461749a1257b9939625ef59b2b056035311/gcc/timevar.cc#L162,
>>  and
>> also the comment about `_POSIX_CLOCK_SELECTION` says it 'implies the 
>> _POSIX_TIMERS option' so
>> `_POSIX_TIMERS` should be defined.
>
> My understanding is that constant `_POSIX_TIMERS`[1] indicates that function 
> `timer_create`[2] and friends are available, which is not the case for 
> winpthreads.
>
> POSIX describes it as:
>
> ```
> _POSIX_TIMERS
>     The implementation supports timers. This symbol shall always be set to 
> the value 202405L.
> ```
>
> I was unable to find more details about `_POSIX_TIMERS` and what it implies.

Our pthread_unistd.h contradicts itself:

```
/* _SC_TIMERS - not supported
  The functions

  clock_getres(),
  clock_gettime(),
  clock_settime(),
  nanosleep(),
  timer_create(),
  timer_delete(),
  timer_gettime(),
  timer_getoverrun(),
  timer_settime()

  are present.  */
/* #undef _POSIX_TIMERS */

/* _SC_CLOCK_SELECTION
   This option implies the _POSIX_TIMERS option. The functions

   pthread_condattr_getclock(),
   pthread_condattr_setclock(),
   clock_nanosleep()

   are present.
*/
#undef _POSIX_CLOCK_SELECTION
#define _POSIX_CLOCK_SELECTION 200112
```

It explicitly undefs `_POSIX_TIMERS `, but then defines 
`_POSIX_CLOCK_SELECTION` with a comment that it implies `_POSIX_TIMERS `.

POSIX says:

```
_POSIX_CLOCK_SELECTION
    The implementation supports clock selection. This symbol shall always be 
set to the value 202405L.
```

It does not say that it implies `_POSIX_TIMERS`. I think keeping it undefined 
is appropriate.

- Kirill Makurin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to