Collin Funk <[email protected]> writes:

> Tim Rühsen <[email protected]> writes:
>
>> Thanks for looking into it. Is there any ongoing work or planned?
>>
>> Is there possibly a work-around that can be applied after unpacking
>> libunistring (or after cloning the git reository) and before building?
>
> Oops, I got sidetracked with other things and forgot about this. Sorry
> about that.
>
> Let me review Bruno's comments on my previous patch and propose another
> one. I don't think Bruno has another unistring release planned (no new
> Unicode release), but I think you should be able to apply the patch.

Bruno, can you please check the attached patch? I tested it using Tim's
Dockerfile and 'make check' passes using Wine.

The value of $ac_cv_search_nanosleep will remain "no" since we do not
add winpthreads to the library search. Then we check if a static inline
function allows a simple program to compile. If so, then we have to use
rpl_nanosleep instead of nanosleep for our definition.

I think that matches your explanation earlier [1].

Collin

[1] https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00181.html

>From f49d7cca84c38a347aae0d6b7280b5de39e67b2f Mon Sep 17 00:00:00 2001
Message-ID: <f49d7cca84c38a347aae0d6b7280b5de39e67b2f.1765750271.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 14 Dec 2025 14:01:53 -0800
Subject: [PATCH] nanosleep: Avoid a redefinition on mingw.

Reported by Tim Ruehsen in
<https://savannah.gnu.org/bugs/?67704>.

* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check for a static inline
nanosleep on mingw.
---
 ChangeLog       |  8 ++++++++
 m4/nanosleep.m4 | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e5e67e7a8c..2b724a9742 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-12-14  Collin Funk  <[email protected]>
+
+	nanosleep: Avoid a redefinition on mingw.
+	Reported by Tim Ruehsen in
+	<https://savannah.gnu.org/bugs/?67704>.
+	* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check for a static inline
+	nanosleep on mingw.
+
 2025-12-12  Paul Eggert  <[email protected]>
 
 	extern-inline: #define AAA_INLINE pre-<config.h>
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
index 81c45d8a31..1dbf0b4560 100644
--- a/m4/nanosleep.m4
+++ b/m4/nanosleep.m4
@@ -144,6 +144,25 @@ AC_DEFUN([gl_FUNC_NANOSLEEP]
        ;;
    esac
  else
+   # Replace the static inline function on mingw which requires linking to
+   # libwinpthreads.
+   AC_CACHE_CHECK([for static inline nanosleep],
+     [gl_cv_static_inline_nanosleep],
+     [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#include <time.h>]],
+           [[
+              static struct timespec ts1;
+              static struct timespec ts2;
+              return nanosleep (&ts1, &ts2);
+           ]])
+        ],
+     [gl_cv_static_inline_nanosleep=yes],
+     [gl_cv_static_inline_nanosleep=no])
+   ])
+   if test $gl_cv_static_inline_nanosleep = yes; then
+     REPLACE_NANOSLEEP=1
+   fi
    HAVE_NANOSLEEP=0
  fi
  LIBS=$gl_saved_LIBS
-- 
2.52.0

Reply via email to