On Sat, Nov 15, 2025 at 10:22 PM Collin Funk <[email protected]> wrote: > > Using the reproduction steps Tim shared [1], this patch fixes the > redeclaration on MinGW: > > depbase=`echo nanosleep.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ > x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. > -DGNULIB_STRICT_CHECKING=1 -g -O2 -MT nanosleep.o -MD -MP -MF $depbase.Tpo > -c -o nanosleep.o nanosleep.c &&\ > mv -f $depbase.Tpo $depbase.Po > nanosleep.c:97:1: error: redefinition of 'nanosleep' > 97 | nanosleep (const struct timespec *requested_delay, > | ^~~~~~~~~ > In file included from /usr/share/mingw-w64/include/time.h:323, > from ./time.h:54, > from nanosleep.c:23: > /usr/share/mingw-w64/include/pthread_time.h:79:39: note: previous > definition of 'nanosleep' with type 'int(const struct timespec *, struct > timespec *)' > 79 | WINPTHREAD_NANOSLEEP_DECL int __cdecl nanosleep(const struct > timespec *request, struct timespec *remain) > | ^~~~~~~~~ > make[4]: *** [Makefile:2248: nanosleep.o] Error 1 > > I left the cross guess as "no" so the function gets replaced. This is > because MinGW does not use QueryPerformanceCounter, so I assume that > does not work as well for small durations [2].
QueryPerformanceCounter is not monotonically increasing in practice. Time can appear to run backwards if subsequent QueryPerformanceCounter is run on a different core. See <https://stackoverflow.com/questions/27419223/time-running-backwards-with-queryperformancecounter>. > I'm not sure if that is correct and/or if it should be documented. So I > will hold off pushing for review. > > [1] https://savannah.gnu.org/bugs/?67704 > [2] > https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-libraries/winpthreads/src/nanosleep.c Jeff
