Hi Bruno, Bruno Haible <br...@clisp.org> writes:
> It's a matter of effort. Disabling the signature test means that code that > uses the function via a function pointer (as opposed to direct invocation) > may run into trouble. Whereas enabling it forces you to fix that case as well, > at the cost of more code in gnulib. > > Use a code search [1] to determine whether getservbyname and getservbyport > frequently get used via function pointer. Thanks for the information. That makes sense. I have chosen the lazy option and just disabled the tests. From my quick search I don't see it used as a function pointer and 32-bit Windows doesn't seem worth the effort. Pushed the attached patch to disable the tests there and document the declaration. Collin
>From 71fbdb50ab5b0da7053a93975612b42f0d2e591b Mon Sep 17 00:00:00 2001 From: Collin Funk <collin.fu...@gmail.com> Date: Mon, 6 Jan 2025 13:56:40 -0800 Subject: [PATCH] servent tests: Fix failure on 32-bit native Windows. * tests/test-servent.c (getservbyname, getservbyport) [_WIN64 && !__CYGWIN__]: Disable signature check. * doc/posix-functions/getservbyname.texi: Document the incompatible __stdcall function signature. * doc/posix-functions/getservbyport.texi: Likewise. --- ChangeLog | 9 +++++++++ doc/posix-functions/getservbyname.texi | 3 +++ doc/posix-functions/getservbyport.texi | 3 +++ tests/test-servent.c | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index d9819dbc50..601407cce3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-01-06 Collin Funk <collin.fu...@gmail.com> + + servent tests: Fix failure on 32-bit native Windows. + * tests/test-servent.c (getservbyname, getservbyport) + [_WIN64 && !__CYGWIN__]: Disable signature check. + * doc/posix-functions/getservbyname.texi: Document the incompatible + __stdcall function signature. + * doc/posix-functions/getservbyport.texi: Likewise. + 2025-01-05 Paul Eggert <egg...@cs.ucla.edu> parse-datetime-tests: port to Gnulib mktime diff --git a/doc/posix-functions/getservbyname.texi b/doc/posix-functions/getservbyname.texi index f52be6dab8..93eddab92e 100644 --- a/doc/posix-functions/getservbyname.texi +++ b/doc/posix-functions/getservbyname.texi @@ -17,4 +17,7 @@ @node getservbyname Portability problems not fixed by Gnulib: @itemize +@item +On Windows, in 32-bit mode, this function is defined with a calling +convention that is different from @code{cdecl}. @end itemize diff --git a/doc/posix-functions/getservbyport.texi b/doc/posix-functions/getservbyport.texi index 03c04e6769..01665136c4 100644 --- a/doc/posix-functions/getservbyport.texi +++ b/doc/posix-functions/getservbyport.texi @@ -17,4 +17,7 @@ @node getservbyport Portability problems not fixed by Gnulib: @itemize +@item +On Windows, in 32-bit mode, this function is defined with a calling +convention that is different from @code{cdecl}. @end itemize diff --git a/tests/test-servent.c b/tests/test-servent.c index fb93e1ae83..0e774bdfcc 100644 --- a/tests/test-servent.c +++ b/tests/test-servent.c @@ -22,9 +22,15 @@ #include <netdb.h> #include "signature.h" + +#if defined _WIN64 && !defined __CYGWIN__ +/* On 32-bit native Windows, these two functions may have the __stdcall calling + convention. But the SIGNATURE_CHECK works only for functions with __cdecl + calling convention. */ SIGNATURE_CHECK (getservbyname, struct servent *, (char const *, char const *)); SIGNATURE_CHECK (getservbyport, struct servent *, (int, char const *)); +#endif #include <stdio.h> #include <arpa/inet.h> -- 2.47.1