* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
@ 2018-08-16 12:13 Noam Postavsky
2018-08-16 12:49 ` Noam Postavsky
2018-08-16 13:41 ` Eli Zaretskii
0 siblings, 2 replies; 53+ messages in thread
From: Noam Postavsky @ 2018-08-16 12:13 UTC (permalink / raw)
To: 32452
Severity: minor
Recently the debbugs.gnu.org server is slow to respond. I notice this
both when opening bug reports in Firefox, and from Emacs. However,
Emacs uses 100% cpu while waiting for the server. I added a message
call in gnutls_try_handshake (see patch below), and got "gnutls
non-fatal: Resource temporarily unavailable, try again. [190088 times]"
in *Messages*. This was from doing M-x gnus-read-ephemeral-bug-group,
it took 5 or 10 seconds to (eventually successfully) complete.
We should have some kind of delay to avoid sending so many useless
retries.
--- i/src/gnutls.c
+++ w/src/gnutls.c
@@ -65,6 +65,7 @@ your option) any later version.
static bool gnutls_global_initialized;
+static char const * emacs_gnutls_strerror (int err);
static void gnutls_log_function (int, const char *);
static void gnutls_log_function2 (int, const char *, const char *);
# ifdef HAVE_GNUTLS3
@@ -558,7 +559,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
}
while (ret < 0
&& gnutls_error_is_fatal (ret) == 0
- && ! non_blocking);
+ && ! non_blocking
+ && (message ("gnutls non-fatal: %s", emacs_gnutls_strerror (ret)),
+ true));
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-16 12:13 bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy Noam Postavsky
@ 2018-08-16 12:49 ` Noam Postavsky
2018-08-16 13:41 ` Eli Zaretskii
1 sibling, 0 replies; 53+ messages in thread
From: Noam Postavsky @ 2018-08-16 12:49 UTC (permalink / raw)
To: 32452
Noam Postavsky <npostavs@gmail.com> writes:
> I added a message call in gnutls_try_handshake (see patch below)
> + && (message ("gnutls non-fatal: %s", emacs_gnutls_strerror (ret)),
> + true));
Ah, this patch isn't needed, (setq gnutls-log-level 1) suffices:
gnutls.c: [1] (Emacs) non-fatal error: Resource temporarily unavailable, try again. [329434 times]
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-16 12:13 bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy Noam Postavsky
2018-08-16 12:49 ` Noam Postavsky
@ 2018-08-16 13:41 ` Eli Zaretskii
2018-08-16 14:45 ` Noam Postavsky
1 sibling, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-16 13:41 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Thu, 16 Aug 2018 08:13:40 -0400
>
> Recently the debbugs.gnu.org server is slow to respond. I notice this
> both when opening bug reports in Firefox, and from Emacs. However,
> Emacs uses 100% cpu while waiting for the server. I added a message
> call in gnutls_try_handshake (see patch below), and got "gnutls
> non-fatal: Resource temporarily unavailable, try again. [190088 times]"
> in *Messages*. This was from doing M-x gnus-read-ephemeral-bug-group,
> it took 5 or 10 seconds to (eventually successfully) complete.
Does anything change if you disable asynchronous DNS and connection
establishment?
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-16 13:41 ` Eli Zaretskii
@ 2018-08-16 14:45 ` Noam Postavsky
2018-08-16 17:33 ` Eli Zaretskii
0 siblings, 1 reply; 53+ messages in thread
From: Noam Postavsky @ 2018-08-16 14:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452
[-- Attachment #1: Type: text/plain, Size: 290 bytes --]
On 16 August 2018 at 09:41, Eli Zaretskii <eliz@gnu.org> wrote:
> Does anything change if you disable asynchronous DNS and connection
> establishment?
Um, how should I do that? The :nowait argument to open-network-stream
is already nil, if that's what you meant (see attached backtrace).
[-- Attachment #2: gnutls-boot-stacktrace.txt --]
[-- Type: text/plain, Size: 2764 bytes --]
Debugger entered--Lisp error: (quit)
gnutls-boot(#<process debbugs.gnu.org> gnutls-x509pki (:complete-negotiation t :priority "NORMAL:%DUMBFW" :hostname "debbugs.gnu.org" :loglevel 1 :min-prime-bits 256 :trustfiles nil :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil))
gnutls-negotiate(:process #<process debbugs.gnu.org> :type gnutls-x509pki :hostname "debbugs.gnu.org")
open-gnutls-stream("debbugs.gnu.org" #<buffer *url-http-temp*> "debbugs.gnu.org" 443 nil)
network-stream-open-tls("debbugs.gnu.org" #<buffer *url-http-temp*> "debbugs.gnu.org" 443 (:type tls :nowait nil))
open-network-stream("debbugs.gnu.org" #<buffer *url-http-temp*> "debbugs.gnu.org" 443 :type tls :nowait nil)
url-open-stream("debbugs.gnu.org" #<buffer *url-http-temp*> "debbugs.gnu.org" 443 tls)
url-http-find-free-connection("debbugs.gnu.org" 443 tls)
url-http(#s(url :type "https" :user nil :password nil :host "debbugs.gnu.org" :portspec nil :filename "/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) #f(compiled-function (&rest ignored) #<bytecode 0x1910821>) (nil) nil tls)
url-https(#s(url :type "https" :user nil :password nil :host "debbugs.gnu.org" :portspec nil :filename "/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous nil) #f(compiled-function (&rest ignored) #<bytecode 0x1910821>) (nil))
url-retrieve-internal("https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes" #f(compiled-function (&rest ignored) #<bytecode 0x1910821>) (nil) nil nil)
url-retrieve("https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes" #f(compiled-function (&rest ignored) #<bytecode 0x1910821>) nil nil nil)
url-retrieve-synchronously("https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes")
url-insert-file-contents("https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32444;mboxmaint=yes;mboxstat=yes" t)
gnus-read-ephemeral-bug-group("32444" "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
funcall-interactively(gnus-read-ephemeral-bug-group "32444" "https://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s;mboxmaint=yes;mboxstat=yes")
call-interactively(gnus-read-ephemeral-bug-group record nil)
command-execute(gnus-read-ephemeral-bug-group record)
execute-extended-command(nil "gnus-read-ephemeral-bug-group" "gnus-read-ephemeral-b")
funcall-interactively(execute-extended-command nil "gnus-read-ephemeral-bug-group" "gnus-read-ephemeral-b")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-16 14:45 ` Noam Postavsky
@ 2018-08-16 17:33 ` Eli Zaretskii
2018-08-17 1:02 ` Noam Postavsky
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-16 17:33 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Thu, 16 Aug 2018 10:45:12 -0400
> Cc: 32452@debbugs.gnu.org
>
> > Does anything change if you disable asynchronous DNS and connection
> > establishment?
>
> Um, how should I do that?
Compile with HAVE_GETADDRINFO_A undefined? Although if :nowait is
nil, then I'm not sure such a compilation will change anything. But I
think it's worth trying, as at least some of the related code doesn't
seem to be disabled by :nowait being nil, if my reading of the code is
correct.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-16 17:33 ` Eli Zaretskii
@ 2018-08-17 1:02 ` Noam Postavsky
2018-08-17 5:59 ` Eli Zaretskii
0 siblings, 1 reply; 53+ messages in thread
From: Noam Postavsky @ 2018-08-17 1:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452
Eli Zaretskii <eliz@gnu.org> writes:
> Compile with HAVE_GETADDRINFO_A undefined? Although if :nowait is
> nil, then I'm not sure such a compilation will change anything. But I
> think it's worth trying, as at least some of the related code doesn't
> seem to be disabled by :nowait being nil, if my reading of the code is
> correct.
No, it doesn't seem to make a difference (though the server is answering
a bit faster at the moment, I'm only getting the 20~30k "Resource
temporarily unavailable..." messages with both HAVE_GETADDRINFO_A
defined and undefined).
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 1:02 ` Noam Postavsky
@ 2018-08-17 5:59 ` Eli Zaretskii
2018-08-17 11:55 ` Noam Postavsky
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-17 5:59 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Cc: 32452@debbugs.gnu.org
> Date: Thu, 16 Aug 2018 21:02:29 -0400
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Compile with HAVE_GETADDRINFO_A undefined? Although if :nowait is
> > nil, then I'm not sure such a compilation will change anything. But I
> > think it's worth trying, as at least some of the related code doesn't
> > seem to be disabled by :nowait being nil, if my reading of the code is
> > correct.
>
> No, it doesn't seem to make a difference (though the server is answering
> a bit faster at the moment, I'm only getting the 20~30k "Resource
> temporarily unavailable..." messages with both HAVE_GETADDRINFO_A
> defined and undefined).
OK, so do you understand the sequence of the events well enough to
describe what happens, and explain why we get so many EAGAIN errors?
I'm not yet sure this is bug, maybe it's just how things are in this
case (modulo exerting less CPU load, something that we certainly
should try).
Also, does this happen with every server, or just with some?
Thanks.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 5:59 ` Eli Zaretskii
@ 2018-08-17 11:55 ` Noam Postavsky
2018-08-17 12:25 ` Eli Zaretskii
0 siblings, 1 reply; 53+ messages in thread
From: Noam Postavsky @ 2018-08-17 11:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452
Eli Zaretskii <eliz@gnu.org> writes:
> OK, so do you understand the sequence of the events well enough to
> describe what happens, and explain why we get so many EAGAIN errors?
> I'm not yet sure this is bug, maybe it's just how things are in this
> case (modulo exerting less CPU load, something that we certainly
> should try).
I haven't really traced things through properly, but my current
understanding/guess is that we're using non-blocking sockets even though
we actually want blocking behaviour. So to get the blocking behaviour
we just spin in a loop.
> Also, does this happen with every server, or just with some?
debbugs.gnu.org seems to be the most extreme case (at the moment), with
other servers I see only about a hundred "Resource temporarily
unavailable" messages (I'm noticing this now because I switched on
gnutls-log-level, but it's not enough to cause a noticable CPU spike).
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 11:55 ` Noam Postavsky
@ 2018-08-17 12:25 ` Eli Zaretskii
2018-08-17 22:10 ` Noam Postavsky
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-17 12:25 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Cc: 32452@debbugs.gnu.org
> Date: Fri, 17 Aug 2018 07:55:44 -0400
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > OK, so do you understand the sequence of the events well enough to
> > describe what happens, and explain why we get so many EAGAIN errors?
> > I'm not yet sure this is bug, maybe it's just how things are in this
> > case (modulo exerting less CPU load, something that we certainly
> > should try).
>
> I haven't really traced things through properly, but my current
> understanding/guess is that we're using non-blocking sockets even though
> we actually want blocking behaviour. So to get the blocking behaviour
> we just spin in a loop.
In which case it's fine, we just need to do something in the loop to
yield the CPU, like some nanosleep, perhaps? And maybe enlarge the
sleep period as time goes on?
> > Also, does this happen with every server, or just with some?
>
> debbugs.gnu.org seems to be the most extreme case (at the moment), with
> other servers I see only about a hundred "Resource temporarily
> unavailable" messages (I'm noticing this now because I switched on
> gnutls-log-level, but it's not enough to cause a noticable CPU spike).
debbugs is terribly slow in a browser as well, right now. But
hundreds of attempts sounds excessive to me.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 12:25 ` Eli Zaretskii
@ 2018-08-17 22:10 ` Noam Postavsky
2018-08-18 6:34 ` Eli Zaretskii
2019-09-24 5:39 ` Lars Ingebrigtsen
0 siblings, 2 replies; 53+ messages in thread
From: Noam Postavsky @ 2018-08-17 22:10 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452
Eli Zaretskii <eliz@gnu.org> writes:
> In which case it's fine, we just need to do something in the loop to
> yield the CPU, like some nanosleep, perhaps? And maybe enlarge the
> sleep period as time goes on?
>
> debbugs is terribly slow in a browser as well, right now. But
> hundreds of attempts sounds excessive to me.
The debbugs server seems back to normal speeds now, I'm getting ~200
hits with it just like other servers. The patch below brings it down to
15~20. nanosleep isn't portable though right? Not sure what to put
instead, it seems existing wait functions in Emacs are all tied up with
threads and processes, so I don't know if it's safe to call them here.
--- i/src/gnutls.c
+++ w/src/gnutls.c
@@ -550,6 +550,8 @@ gnutls_try_handshake (struct Lisp_Process *proc)
if (non_blocking)
proc->gnutls_p = true;
+ enum { MAX_DELAY_NS = 100 * 1000 * 1000 }; // Max 100ms delay.
+ struct timespec delay = { 0, 1000 };
do
{
ret = gnutls_handshake (state);
@@ -558,7 +560,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
}
while (ret < 0
&& gnutls_error_is_fatal (ret) == 0
- && ! non_blocking);
+ && ! non_blocking
+ && (nanosleep (&delay, NULL),
+ delay.tv_nsec = min (delay.tv_nsec * 2, MAX_DELAY_NS)));
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 22:10 ` Noam Postavsky
@ 2018-08-18 6:34 ` Eli Zaretskii
2018-08-21 0:52 ` Noam Postavsky
2019-09-24 5:39 ` Lars Ingebrigtsen
1 sibling, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-18 6:34 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Cc: 32452@debbugs.gnu.org
> Date: Fri, 17 Aug 2018 18:10:32 -0400
>
> The debbugs server seems back to normal speeds now, I'm getting ~200
> hits with it just like other servers. The patch below brings it down to
> 15~20.
Good.
> nanosleep isn't portable though right?
We could use usleep instead, it's part of Posix, AFAIK. And MinGW has
it as well, AFAICT. Sorry I didn't mention it in the first place.
Thanks.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-18 6:34 ` Eli Zaretskii
@ 2018-08-21 0:52 ` Noam Postavsky
2018-08-21 2:42 ` Eli Zaretskii
0 siblings, 1 reply; 53+ messages in thread
From: Noam Postavsky @ 2018-08-21 0:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452
Eli Zaretskii <eliz@gnu.org> writes:
>> nanosleep isn't portable though right?
>
> We could use usleep instead, it's part of Posix, AFAIK. And MinGW has
> it as well, AFAICT. Sorry I didn't mention it in the first place.
My usleep(3) man page says it's obsolete:
CONFORMING TO
4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete; use nanosleep(2)
instead. POSIX.1-2008 removes the specification of usleep().
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-21 0:52 ` Noam Postavsky
@ 2018-08-21 2:42 ` Eli Zaretskii
2022-02-21 15:20 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2018-08-21 2:42 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
> From: Noam Postavsky <npostavs@gmail.com>
> Cc: 32452@debbugs.gnu.org
> Date: Mon, 20 Aug 2018 20:52:58 -0400
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> nanosleep isn't portable though right?
> >
> > We could use usleep instead, it's part of Posix, AFAIK. And MinGW has
> > it as well, AFAICT. Sorry I didn't mention it in the first place.
>
> My usleep(3) man page says it's obsolete:
Then I guess use nanosleep if it's available and usleep if it isn't?
Alternatively, we could make nanosleep fopr Windows using usleep, and
use nanosleep from Gnulib if platforms other than Windows don't have
it.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-17 22:10 ` Noam Postavsky
2018-08-18 6:34 ` Eli Zaretskii
@ 2019-09-24 5:39 ` Lars Ingebrigtsen
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-24 5:39 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32452
Noam Postavsky <npostavs@gmail.com> writes:
> + enum { MAX_DELAY_NS = 100 * 1000 * 1000 }; // Max 100ms delay.
> + struct timespec delay = { 0, 1000 };
> do
> {
> ret = gnutls_handshake (state);
> @@ -558,7 +560,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
> }
> while (ret < 0
> && gnutls_error_is_fatal (ret) == 0
> - && ! non_blocking);
> + && ! non_blocking
> + && (nanosleep (&delay, NULL),
> + delay.tv_nsec = min (delay.tv_nsec * 2, MAX_DELAY_NS)));
This code has changed somewhat since the proposed patch:
while ((ret = gnutls_handshake (state)) < 0)
{
do
ret = gnutls_handshake (state);
while (ret == GNUTLS_E_INTERRUPTED);
if (0 <= ret || emacs_gnutls_handle_error (state, ret) == 0
|| non_blocking)
break;
maybe_quit ();
}
But perhaps adding some sleep here would be a good idea, anyway. On the
other hand, 100ms seems way too long -- that's a noticeable slow-down in
network set-up.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2018-08-21 2:42 ` Eli Zaretskii
@ 2022-02-21 15:20 ` Lars Ingebrigtsen
2022-02-23 19:45 ` Paul Eggert
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-21 15:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32452, Noam Postavsky, Paul Eggert
Eli Zaretskii <eliz@gnu.org> writes:
> Alternatively, we could make nanosleep fopr Windows using usleep, and
> use nanosleep from Gnulib if platforms other than Windows don't have
> it.
I thought I could have a look at this (i.e., adding nanosleep from
Gnulib and then implement this).
I've never done a Gnulib merge, so I just tried running
admin/merge-gnulib first to bring us up to date... and this resulted in
a vc-dir buffer that's 114 lines long and starts with:
build-aux/
edited build-aux/config.guess
edited build-aux/config.sub
edited build-aux/gitlog-to-changelog
edited build-aux/update-copyright
lib/
edited lib/acl-errno-valid.c
edited lib/acl-internal.c
edited lib/acl-internal.h
edited lib/acl.h
edited lib/acl_entries.c
[...]
edited lib/filevercmp.h
edited lib/fpending.c
edited lib/fpending.h
unregistered lib/fpurge.c
unregistered lib/freading.c
unregistered lib/freading.h
And fails with:
configure:42647: error: possibly undefined macro: gl_PREREQ_RAWMEMCHR
configure:42918: error: possibly undefined macro: gl_PREREQ_STRTOLL
autoreconf: error: /usr/bin/autoconf failed with exit status: 1
So... er... I'm guessing something's not quite right here. 🙃
Paul, do you have any advice?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-21 15:20 ` Lars Ingebrigtsen
@ 2022-02-23 19:45 ` Paul Eggert
2022-02-23 19:48 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Paul Eggert @ 2022-02-23 19:45 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, Noam Postavsky
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
On 2/21/22 07:20, Lars Ingebrigtsen wrote:
> Paul, do you have any advice?
I think the problem was mostly due to Gnulib's recent changing of how it
handles conditionally-generated directories like lib/alloca.h. I
installed the first attached patch to try to fix this. The second patch
is the result of running admin/merge-gnulib, and the third does a minor
cleanup of two new Gnulib files that Emacs doesn't need.
Also, I installed the fourth attached patch to port Emacs's Git hooks to
Git 2.35.1, the current Git version, as Emacs was relying on an
undocumented Git feature that Git removed. (Am I the only Emacs
developer using up-to-date Git?)
[-- Attachment #2: 0001-Port-to-current-Gnulib.patch --]
[-- Type: text/x-patch, Size: 874 bytes --]
From 995aed477dc9be708920cc46442673126ed75760 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 23 Feb 2022 10:52:27 -0800
Subject: [PATCH 1/4] Port to current Gnulib
* configure.ac (AM_COND_IF): New macro, needed because Gnulib
normally assumes Automake and now uses this Automake macro.
Problem reported by Lars Ingebrigtsen (Bug#32452#47).
---
configure.ac | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configure.ac b/configure.ac
index 00711cccd5..a315eeb6bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1201,6 +1201,8 @@ AC_DEFUN
AC_DEFUN([AM_CONDITIONAL],
[$2 && $1_CONDITION=1 || $1_CONDITION=
AC_SUBST([$1_CONDITION])])
+AC_DEFUN([AM_COND_IF],
+ [AS_IF([test "$$1_CONDITION"], [$2], [$3])])
dnl Prefer silent make output. For verbose output, use
dnl 'configure --disable-silent-rules' or 'make V=1' .
--
2.32.0
[-- Attachment #3: 0002-Update-from-Gnulib-by-running-admin-merge-gnulib.patch --]
[-- Type: text/x-patch, Size: 119028 bytes --]
From 308e63ccfcc6a6b1285bb17eff641f48639fb329 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 23 Feb 2022 11:11:52 -0800
Subject: [PATCH 2/4] Update from Gnulib by running admin/merge-gnulib
---
build-aux/config.guess | 11 +-
build-aux/config.sub | 2 +-
build-aux/gitlog-to-changelog | 2 +-
build-aux/update-copyright | 2 +-
lib/acl-errno-valid.c | 2 +-
lib/acl-internal.c | 2 +-
lib/acl-internal.h | 2 +-
lib/acl.h | 2 +-
lib/acl_entries.c | 2 +-
lib/at-func.c | 2 +-
lib/cdefs.h | 3 +-
lib/close-stream.c | 2 +-
lib/close-stream.h | 2 +-
lib/copy-file-range.c | 34 +++
lib/diffseq.h | 2 +-
lib/dtoastr.c | 2 +-
lib/dtotimespec.c | 2 +-
lib/faccessat.c | 2 +-
lib/fchmodat.c | 2 +-
lib/fdopendir.c | 2 +-
lib/file-has-acl.c | 2 +-
lib/filemode.c | 2 +-
lib/filemode.h | 2 +-
lib/filevercmp.c | 189 ++++++++--------
lib/filevercmp.h | 68 ++++--
lib/fpending.c | 2 +-
lib/fpending.h | 2 +-
lib/fstatat.c | 2 +-
lib/fsusage.c | 2 +-
lib/fsusage.h | 2 +-
lib/ftoastr.c | 2 +-
lib/ftoastr.h | 2 +-
lib/futimens.c | 2 +-
lib/get-permissions.c | 2 +-
lib/getloadavg.c | 2 +-
lib/gettime.c | 2 +-
lib/gnulib.mk.in | 411 ++++++++++++++++++++--------------
lib/intprops.h | 8 +-
lib/lchmod.c | 2 +-
lib/memrchr.c | 2 +-
lib/mini-gmp-gnulib.c | 2 +-
lib/mini-gmp.c | 2 +-
lib/mini-gmp.h | 2 +-
lib/mktime.c | 28 ++-
lib/nstrftime.c | 3 +-
lib/openat-priv.h | 2 +-
lib/openat-proc.c | 2 +-
lib/openat.h | 2 +-
lib/qcopy-acl.c | 2 +-
lib/readlinkat.c | 2 +-
lib/save-cwd.h | 2 +-
lib/set-permissions.c | 2 +-
lib/sig2str.c | 2 +-
lib/sig2str.h | 2 +-
lib/strftime.h | 2 +-
lib/string.in.h | 29 ++-
lib/strtoimax.c | 2 +-
lib/strtol.c | 2 +-
lib/strtoll.c | 2 +-
lib/symlink.c | 2 +-
lib/time-internal.h | 2 +-
lib/time_rz.c | 2 +-
lib/timespec-add.c | 2 +-
lib/timespec-sub.c | 2 +-
lib/timespec.c | 2 +-
lib/timespec.h | 2 +-
lib/unistd.in.h | 16 +-
lib/unlocked-io.h | 2 +-
lib/utimens.c | 2 +-
lib/utimens.h | 2 +-
lib/utimensat.c | 2 +-
lib/vla.h | 2 +-
m4/copy-file-range.m4 | 25 ++-
m4/extern-inline.m4 | 19 +-
m4/gnulib-common.m4 | 95 +++++++-
m4/gnulib-comp.m4 | 312 ++++++++++++++------------
m4/libgmp.m4 | 6 +-
m4/mktime.m4 | 29 ++-
m4/stdio_h.m4 | 29 +--
m4/unistd_h.m4 | 1 +
80 files changed, 896 insertions(+), 542 deletions(-)
diff --git a/build-aux/config.guess b/build-aux/config.guess
index 1105a74983..7f76b6228f 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -1,14 +1,14 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2021 Free Software Foundation, Inc.
+# Copyright 1992-2022 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
-timestamp='2021-11-30'
+timestamp='2022-01-09'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -60,7 +60,7 @@ version=
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2021 Free Software Foundation, Inc.
+Copyright 1992-2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -929,6 +929,9 @@ main ()
i*:PW*:*)
GUESS=$UNAME_MACHINE-pc-pw32
;;
+ *:SerenityOS:*:*)
+ GUESS=$UNAME_MACHINE-pc-serenity
+ ;;
*:Interix*:*)
case $UNAME_MACHINE in
x86)
diff --git a/build-aux/config.sub b/build-aux/config.sub
index 5ba9a97d2c..9b62e37c43 100755
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -8,7 +8,7 @@ timestamp=
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 1c6847ae3b..82d9f97336 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -35,7 +35,7 @@
eval 'exec perl -wSx "$0" "$@"'
if 0;
-my $VERSION = '2021-02-24 23:42'; # UTC
+my $VERSION = '2022-01-27 18:49'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index 51b25dd0a5..81b691e857 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -7,7 +7,7 @@
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
+# the Free Software Foundation, either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
diff --git a/lib/acl-errno-valid.c b/lib/acl-errno-valid.c
index 39717c3517..a364e41325 100644
--- a/lib/acl-errno-valid.c
+++ b/lib/acl-errno-valid.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index 75a80bf0df..be244c67a2 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 582f9e1c1a..93533762dd 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/acl.h b/lib/acl.h
index 8b933c20b9..f4d0df8061 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/acl_entries.c b/lib/acl_entries.c
index e4c014ce71..677de23e0c 100644
--- a/lib/acl_entries.c
+++ b/lib/acl_entries.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/at-func.c b/lib/at-func.c
index 92d65f6341..afcc819beb 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/cdefs.h b/lib/cdefs.h
index abf13a9086..44d3826bca 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -143,7 +143,8 @@ #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
-#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
+ || __GNUC_PREREQ (12, 0))
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
diff --git a/lib/close-stream.c b/lib/close-stream.c
index 54f3e3c3d0..9b0e97b271 100644
--- a/lib/close-stream.c
+++ b/lib/close-stream.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/close-stream.h b/lib/close-stream.h
index 537506c489..2b4c8ed8f5 100644
--- a/lib/close-stream.h
+++ b/lib/close-stream.h
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
+ by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/copy-file-range.c b/lib/copy-file-range.c
index 96f1ec7c5e..1ec7f4de67 100644
--- a/lib/copy-file-range.c
+++ b/lib/copy-file-range.c
@@ -20,11 +20,45 @@
#include <errno.h>
+#if defined __linux__ && HAVE_COPY_FILE_RANGE
+# include <sys/utsname.h>
+#endif
+
ssize_t
copy_file_range (int infd, off_t *pinoff,
int outfd, off_t *poutoff,
size_t length, unsigned int flags)
{
+#undef copy_file_range
+
+#if defined __linux__ && HAVE_COPY_FILE_RANGE
+ /* The implementation of copy_file_range (which first appeared in
+ Linux kernel release 4.5) had many issues before release 5.3
+ <https://lwn.net/Articles/789527/>, so fail with ENOSYS for Linux
+ kernels 5.2 and earlier.
+
+ This workaround, and the configure-time check for Linux, can be
+ removed when such kernels (released March 2016 through September
+ 2019) are no longer a consideration. As of January 2021, the
+ furthest-future planned kernel EOL is December 2024 for kernel
+ release 4.19. */
+
+ static signed char ok;
+
+ if (! ok)
+ {
+ struct utsname name;
+ uname (&name);
+ char *p = name.release;
+ ok = ((p[1] != '.' || '5' < p[0]
+ || (p[0] == '5' && (p[3] != '.' || '2' < p[2])))
+ ? 1 : -1);
+ }
+
+ if (0 < ok)
+ return copy_file_range (infd, pinoff, outfd, poutoff, length, flags);
+#endif
+
/* There is little need to emulate copy_file_range with read+write,
since programs that use copy_file_range must fall back on
read+write anyway. */
diff --git a/lib/diffseq.h b/lib/diffseq.h
index 0c901a6ecf..0f76ea1d5a 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -5,7 +5,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/dtoastr.c b/lib/dtoastr.c
index eaade8fa01..71af14c9df 100644
--- a/lib/dtoastr.c
+++ b/lib/dtoastr.c
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
+ by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index 225a2be67c..b62a8bd6cf 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/faccessat.c b/lib/faccessat.c
index 2c0c07aac1..c1737d03a1 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/fchmodat.c b/lib/fchmodat.c
index 506e6badd7..dc53583366 100644
--- a/lib/fchmodat.c
+++ b/lib/fchmodat.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
index a61bad66e2..c2b0e1ed34 100644
--- a/lib/fdopendir.c
+++ b/lib/fdopendir.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 2b6f91ff20..e02f0626ad 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/filemode.c b/lib/filemode.c
index cb508ad12d..a8cbea844c 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -5,7 +5,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/filemode.h b/lib/filemode.h
index 7c645c16b5..bf38181cdc 100644
--- a/lib/filemode.h
+++ b/lib/filemode.h
@@ -5,7 +5,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index b3e6e2f3cb..d546e79054 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -1,11 +1,12 @@
-/*
+/* Compare file names containing version numbers.
+
Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au>
Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
@@ -19,60 +20,65 @@
#include <config.h>
#include "filevercmp.h"
-#include <sys/types.h>
-#include <stdlib.h>
#include <stdbool.h>
-#include <string.h>
#include <c-ctype.h>
#include <limits.h>
-
-/* Match a file suffix defined by this regular expression:
- /(\.[A-Za-z~][A-Za-z0-9~]*)*$/
- Scan the string *STR and return a pointer to the matching suffix, or
- NULL if not found. Upon return, *STR points to terminating NUL. */
-static const char *
-match_suffix (const char **str)
+#include <idx.h>
+#include <verify.h>
+
+/* Return the length of a prefix of S that corresponds to the suffix
+ defined by this extended regular expression in the C locale:
+ (\.[A-Za-z~][A-Za-z0-9~]*)*$
+ If *LEN is -1, S is a string; set *LEN to S's length.
+ Otherwise, *LEN should be nonnegative, S is a char array,
+ and *LEN does not change. */
+static idx_t
+file_prefixlen (char const *s, ptrdiff_t *len)
{
- const char *match = NULL;
- bool read_alpha = false;
- while (**str)
+ size_t n = *len; /* SIZE_MAX if N == -1. */
+
+ for (idx_t i = 0; ; i++)
{
- if (read_alpha)
- {
- read_alpha = false;
- if (!c_isalpha (**str) && '~' != **str)
- match = NULL;
- }
- else if ('.' == **str)
+ idx_t prefixlen = i;
+ while (i + 1 < n && s[i] == '.' && (c_isalpha (s[i + 1])
+ || s[i + 1] == '~'))
+ for (i += 2; i < n && (c_isalnum (s[i]) || s[i] == '~'); i++)
+ continue;
+
+ if (*len < 0 ? !s[i] : i == n)
{
- read_alpha = true;
- if (!match)
- match = *str;
+ *len = i;
+ return prefixlen;
}
- else if (!c_isalnum (**str) && '~' != **str)
- match = NULL;
- (*str)++;
}
- return match;
}
-/* verrevcmp helper function */
+/* Return a version sort comparison value for S's byte at position POS.
+ S has length LEN. If POS == LEN, sort before all non-'~' bytes. */
+
static int
-order (unsigned char c)
+order (char const *s, idx_t pos, idx_t len)
{
+ if (pos == len)
+ return -1;
+
+ unsigned char c = s[pos];
if (c_isdigit (c))
return 0;
else if (c_isalpha (c))
return c;
else if (c == '~')
- return -1;
+ return -2;
else
- return (int) c + UCHAR_MAX + 1;
+ {
+ verify (UCHAR_MAX <= (INT_MAX - 1 - 2) / 2);
+ return c + UCHAR_MAX + 1;
+ }
}
/* slightly modified verrevcmp function from dpkg
- S1, S2 - compared string
- S1_LEN, S2_LEN - length of strings to be scanned
+ S1, S2 - compared char array
+ S1_LEN, S2_LEN - length of arrays to be scanned
This implements the algorithm for comparison of version strings
specified by Debian and now widely adopted. The detailed
@@ -81,37 +87,38 @@ order (unsigned char c)
implements that from s5.6.12 of Debian Policy v3.8.0.1
https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */
static int _GL_ATTRIBUTE_PURE
-verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
+verrevcmp (const char *s1, idx_t s1_len, const char *s2, idx_t s2_len)
{
- size_t s1_pos = 0;
- size_t s2_pos = 0;
+ idx_t s1_pos = 0;
+ idx_t s2_pos = 0;
while (s1_pos < s1_len || s2_pos < s2_len)
{
int first_diff = 0;
while ((s1_pos < s1_len && !c_isdigit (s1[s1_pos]))
|| (s2_pos < s2_len && !c_isdigit (s2[s2_pos])))
{
- int s1_c = (s1_pos == s1_len) ? 0 : order (s1[s1_pos]);
- int s2_c = (s2_pos == s2_len) ? 0 : order (s2[s2_pos]);
+ int s1_c = order (s1, s1_pos, s1_len);
+ int s2_c = order (s2, s2_pos, s2_len);
if (s1_c != s2_c)
return s1_c - s2_c;
s1_pos++;
s2_pos++;
}
- while (s1[s1_pos] == '0')
+ while (s1_pos < s1_len && s1[s1_pos] == '0')
s1_pos++;
- while (s2[s2_pos] == '0')
+ while (s2_pos < s2_len && s2[s2_pos] == '0')
s2_pos++;
- while (c_isdigit (s1[s1_pos]) && c_isdigit (s2[s2_pos]))
+ while (s1_pos < s1_len && s2_pos < s2_len
+ && c_isdigit (s1[s1_pos]) && c_isdigit (s2[s2_pos]))
{
if (!first_diff)
first_diff = s1[s1_pos] - s2[s2_pos];
s1_pos++;
s2_pos++;
}
- if (c_isdigit (s1[s1_pos]))
+ if (s1_pos < s1_len && c_isdigit (s1[s1_pos]))
return 1;
- if (c_isdigit (s2[s2_pos]))
+ if (s2_pos < s2_len && c_isdigit (s2[s2_pos]))
return -1;
if (first_diff)
return first_diff;
@@ -124,58 +131,56 @@ verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
int
filevercmp (const char *s1, const char *s2)
{
- const char *s1_pos;
- const char *s2_pos;
- const char *s1_suffix, *s2_suffix;
- size_t s1_len, s2_len;
- int result;
-
- /* easy comparison to see if strings are identical */
- int simple_cmp = strcmp (s1, s2);
- if (simple_cmp == 0)
- return 0;
+ return filenvercmp (s1, -1, s2, -1);
+}
- /* special handle for "", "." and ".." */
- if (!*s1)
- return -1;
- if (!*s2)
- return 1;
- if (0 == strcmp (".", s1))
- return -1;
- if (0 == strcmp (".", s2))
- return 1;
- if (0 == strcmp ("..", s1))
- return -1;
- if (0 == strcmp ("..", s2))
+/* Compare versions A (of length ALEN) and B (of length BLEN).
+ See filevercmp.h for function description. */
+int
+filenvercmp (char const *a, ptrdiff_t alen, char const *b, ptrdiff_t blen)
+{
+ /* Special case for empty versions. */
+ bool aempty = alen < 0 ? !a[0] : !alen;
+ bool bempty = blen < 0 ? !b[0] : !blen;
+ if (aempty)
+ return -!bempty;
+ if (bempty)
return 1;
- /* special handle for other hidden files */
- if (*s1 == '.' && *s2 != '.')
- return -1;
- if (*s1 != '.' && *s2 == '.')
- return 1;
- if (*s1 == '.' && *s2 == '.')
+ /* Special cases for leading ".": "." sorts first, then "..", then
+ other names with leading ".", then other names. */
+ if (a[0] == '.')
{
- s1++;
- s2++;
- }
+ if (b[0] != '.')
+ return -1;
- /* "cut" file suffixes */
- s1_pos = s1;
- s2_pos = s2;
- s1_suffix = match_suffix (&s1_pos);
- s2_suffix = match_suffix (&s2_pos);
- s1_len = (s1_suffix ? s1_suffix : s1_pos) - s1;
- s2_len = (s2_suffix ? s2_suffix : s2_pos) - s2;
-
- /* restore file suffixes if strings are identical after "cut" */
- if ((s1_suffix || s2_suffix) && (s1_len == s2_len)
- && 0 == strncmp (s1, s2, s1_len))
- {
- s1_len = s1_pos - s1;
- s2_len = s2_pos - s2;
+ bool adot = alen < 0 ? !a[1] : alen == 1;
+ bool bdot = blen < 0 ? !b[1] : blen == 1;
+ if (adot)
+ return -!bdot;
+ if (bdot)
+ return 1;
+
+ bool adotdot = a[1] == '.' && (alen < 0 ? !a[2] : alen == 2);
+ bool bdotdot = b[1] == '.' && (blen < 0 ? !b[2] : blen == 2);
+ if (adotdot)
+ return -!bdotdot;
+ if (bdotdot)
+ return 1;
}
+ else if (b[0] == '.')
+ return 1;
+
+ /* Cut file suffixes. */
+ idx_t aprefixlen = file_prefixlen (a, &alen);
+ idx_t bprefixlen = file_prefixlen (b, &blen);
+
+ /* If both suffixes are empty, a second pass would return the same thing. */
+ bool one_pass_only = aprefixlen == alen && bprefixlen == blen;
+
+ int result = verrevcmp (a, aprefixlen, b, bprefixlen);
- result = verrevcmp (s1, s1_len, s2, s2_len);
- return result == 0 ? simple_cmp : result;
+ /* Return the initial result if nonzero, or if no second pass is needed.
+ Otherwise, restore the suffixes and try again. */
+ return result || one_pass_only ? result : verrevcmp (a, alen, b, blen);
}
diff --git a/lib/filevercmp.h b/lib/filevercmp.h
index 98020e6667..5a33677671 100644
--- a/lib/filevercmp.h
+++ b/lib/filevercmp.h
@@ -1,11 +1,12 @@
-/*
+/* Compare file names containing version numbers.
+
Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au>
Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
@@ -19,24 +20,57 @@
#ifndef FILEVERCMP_H
#define FILEVERCMP_H
-/* Compare version strings:
+#include <stddef.h>
+
+/* Compare strings A and B as file names containing version numbers,
+ and return an integer that is negative, zero, or positive depending
+ on whether A compares less than, equal to, or greater than B.
+
+ Use the following version sort algorithm:
+
+ 1. Compare the strings' maximal-length non-digit prefixes lexically.
+ If there is a difference return that difference.
+ Otherwise discard the prefixes and continue with the next step.
+
+ 2. Compare the strings' maximal-length digit prefixes, using
+ numeric comparison of the numbers represented by each prefix.
+ (Treat an empty prefix as zero; this can happen only at string end.)
+ If there is a difference, return that difference.
+ Otherwise discard the prefixes and continue with the next step.
+
+ 3. If both strings are empty, return 0. Otherwise continue with step 1.
+
+ In version sort, lexical comparison is left to right, byte by byte,
+ using the byte's numeric value (0-255), except that:
+
+ 1. ASCII letters sort before other bytes.
+ 2. A tilde sorts before anything, even an empty string.
+
+ In addition to the version sort rules, the following strings have
+ special priority and sort before all other strings (listed in order):
- This function compares strings S1 and S2:
- 1) By PREFIX in the same way as strcmp.
- 2) Then by VERSION (most similarly to version compare of Debian's dpkg).
- Leading zeros in version numbers are ignored.
- 3) If both (PREFIX and VERSION) are equal, strcmp function is used for
- comparison. So this function can return 0 if (and only if) strings S1
- and S2 are identical.
+ 1. The empty string.
+ 2. ".".
+ 3. "..".
+ 4. Strings starting with "." sort before other strings.
- It returns number >0 for S1 > S2, 0 for S1 == S2 and number <0 for S1 < S2.
+ Before comparing two strings where both begin with non-".",
+ or where both begin with "." but neither is "." or "..",
+ suffixes matching the C-locale extended regular expression
+ (\.[A-Za-z~][A-Za-z0-9~]*)*$ are removed and the strings compared
+ without them, using version sort without special priority;
+ if they do not compare equal, this comparison result is used and
+ the suffixes are effectively ignored. Otherwise, the entire
+ strings are compared using version sort.
- This function compares strings, in a way that if VER1 and VER2 are version
- numbers and PREFIX and SUFFIX (SUFFIX defined as (\.[A-Za-z~][A-Za-z0-9~]*)*)
- are strings then VER1 < VER2 implies filevercmp (PREFIX VER1 SUFFIX,
- PREFIX VER2 SUFFIX) < 0.
+ This function is intended to be a replacement for strverscmp. */
+int filevercmp (char const *a, char const *b) _GL_ATTRIBUTE_PURE;
- This function is intended to be a replacement for strverscmp. */
-int filevercmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE;
+/* Like filevercmp, except compare the byte arrays A (of length ALEN)
+ and B (of length BLEN) so that A and B can contain '\0', which
+ sorts just before '\1'. But if ALEN is -1 treat A as a string
+ terminated by '\0', and similarly for BLEN. */
+int filenvercmp (char const *a, ptrdiff_t alen, char const *b, ptrdiff_t blen)
+ _GL_ATTRIBUTE_PURE;
#endif /* FILEVERCMP_H */
diff --git a/lib/fpending.c b/lib/fpending.c
index 617f3977f8..6408cff464 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/fpending.h b/lib/fpending.h
index 2b45e9031b..43542c5b8a 100644
--- a/lib/fpending.h
+++ b/lib/fpending.h
@@ -5,7 +5,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/fstatat.c b/lib/fstatat.c
index 56de0cab4b..6e8344964b 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/fsusage.c b/lib/fsusage.c
index 734f0fc746..18f790f6e7 100644
--- a/lib/fsusage.c
+++ b/lib/fsusage.c
@@ -5,7 +5,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/fsusage.h b/lib/fsusage.h
index f4f50aba29..0443d19f92 100644
--- a/lib/fsusage.h
+++ b/lib/fsusage.h
@@ -5,7 +5,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index 4349c8c561..9105752922 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 065574a9ff..bac32a387e 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/futimens.c b/lib/futimens.c
index 97228242b1..bc3e41a943 100644
--- a/lib/futimens.c
+++ b/lib/futimens.c
@@ -3,7 +3,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index a17b791c8d..ff79adae72 100644
--- a/lib/get-permissions.c
+++ b/lib/get-permissions.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 53d1b81a3b..37e8280867 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -8,7 +8,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/gettime.c b/lib/gettime.c
index a44a69dfc4..541af18bbf 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index a8a6cd782d..6b90a80f64 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -3,7 +3,7 @@
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
@@ -191,6 +191,10 @@ BUILD_DETAILS = @BUILD_DETAILS@
BYTESWAP_H = @BYTESWAP_H@
CAIRO_CFLAGS = @CAIRO_CFLAGS@
CAIRO_LIBS = @CAIRO_LIBS@
+CAIRO_XCB_CFLAGS = @CAIRO_XCB_CFLAGS@
+CAIRO_XCB_LIBS = @CAIRO_XCB_LIBS@
+CAIRO_XLIB_CFLAGS = @CAIRO_XLIB_CFLAGS@
+CAIRO_XLIB_LIBS = @CAIRO_XLIB_LIBS@
CC = @CC@
CFLAGS = @CFLAGS@
CFLAGS_SOUND = @CFLAGS_SOUND@
@@ -247,7 +251,59 @@ GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
GETOPT_H = @GETOPT_H@
GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@
GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@
+GL_CFLAG_ALLOW_WARNINGS = @GL_CFLAG_ALLOW_WARNINGS@
+GL_CFLAG_GNULIB_WARNINGS = @GL_CFLAG_GNULIB_WARNINGS@
GL_COND_LIBTOOL_CONDITION = @GL_COND_LIBTOOL_CONDITION@
+GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION = @GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION@
+GL_COND_OBJ_COPY_FILE_RANGE_CONDITION = @GL_COND_OBJ_COPY_FILE_RANGE_CONDITION@
+GL_COND_OBJ_DIRFD_CONDITION = @GL_COND_OBJ_DIRFD_CONDITION@
+GL_COND_OBJ_DUP2_CONDITION = @GL_COND_OBJ_DUP2_CONDITION@
+GL_COND_OBJ_EUIDACCESS_CONDITION = @GL_COND_OBJ_EUIDACCESS_CONDITION@
+GL_COND_OBJ_EXECINFO_CONDITION = @GL_COND_OBJ_EXECINFO_CONDITION@
+GL_COND_OBJ_EXPLICIT_BZERO_CONDITION = @GL_COND_OBJ_EXPLICIT_BZERO_CONDITION@
+GL_COND_OBJ_FACCESSAT_CONDITION = @GL_COND_OBJ_FACCESSAT_CONDITION@
+GL_COND_OBJ_FCHMODAT_CONDITION = @GL_COND_OBJ_FCHMODAT_CONDITION@
+GL_COND_OBJ_FCNTL_CONDITION = @GL_COND_OBJ_FCNTL_CONDITION@
+GL_COND_OBJ_FDOPENDIR_CONDITION = @GL_COND_OBJ_FDOPENDIR_CONDITION@
+GL_COND_OBJ_FPENDING_CONDITION = @GL_COND_OBJ_FPENDING_CONDITION@
+GL_COND_OBJ_FREE_CONDITION = @GL_COND_OBJ_FREE_CONDITION@
+GL_COND_OBJ_FSTATAT_CONDITION = @GL_COND_OBJ_FSTATAT_CONDITION@
+GL_COND_OBJ_FSUSAGE_CONDITION = @GL_COND_OBJ_FSUSAGE_CONDITION@
+GL_COND_OBJ_FSYNC_CONDITION = @GL_COND_OBJ_FSYNC_CONDITION@
+GL_COND_OBJ_FUTIMENS_CONDITION = @GL_COND_OBJ_FUTIMENS_CONDITION@
+GL_COND_OBJ_GETDTABLESIZE_CONDITION = @GL_COND_OBJ_GETDTABLESIZE_CONDITION@
+GL_COND_OBJ_GETGROUPS_CONDITION = @GL_COND_OBJ_GETGROUPS_CONDITION@
+GL_COND_OBJ_GETLOADAVG_CONDITION = @GL_COND_OBJ_GETLOADAVG_CONDITION@
+GL_COND_OBJ_GETOPT_CONDITION = @GL_COND_OBJ_GETOPT_CONDITION@
+GL_COND_OBJ_GETRANDOM_CONDITION = @GL_COND_OBJ_GETRANDOM_CONDITION@
+GL_COND_OBJ_GETTIMEOFDAY_CONDITION = @GL_COND_OBJ_GETTIMEOFDAY_CONDITION@
+GL_COND_OBJ_GROUP_MEMBER_CONDITION = @GL_COND_OBJ_GROUP_MEMBER_CONDITION@
+GL_COND_OBJ_LCHMOD_CONDITION = @GL_COND_OBJ_LCHMOD_CONDITION@
+GL_COND_OBJ_LSTAT_CONDITION = @GL_COND_OBJ_LSTAT_CONDITION@
+GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@
+GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@
+GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION = @GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION@
+GL_COND_OBJ_MKOSTEMP_CONDITION = @GL_COND_OBJ_MKOSTEMP_CONDITION@
+GL_COND_OBJ_OPEN_CONDITION = @GL_COND_OBJ_OPEN_CONDITION@
+GL_COND_OBJ_PSELECT_CONDITION = @GL_COND_OBJ_PSELECT_CONDITION@
+GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@
+GL_COND_OBJ_RAWMEMCHR_CONDITION = @GL_COND_OBJ_RAWMEMCHR_CONDITION@
+GL_COND_OBJ_READLINKAT_CONDITION = @GL_COND_OBJ_READLINKAT_CONDITION@
+GL_COND_OBJ_READLINK_CONDITION = @GL_COND_OBJ_READLINK_CONDITION@
+GL_COND_OBJ_REGEX_CONDITION = @GL_COND_OBJ_REGEX_CONDITION@
+GL_COND_OBJ_SIG2STR_CONDITION = @GL_COND_OBJ_SIG2STR_CONDITION@
+GL_COND_OBJ_SIGDESCR_NP_CONDITION = @GL_COND_OBJ_SIGDESCR_NP_CONDITION@
+GL_COND_OBJ_STDIO_READ_CONDITION = @GL_COND_OBJ_STDIO_READ_CONDITION@
+GL_COND_OBJ_STDIO_WRITE_CONDITION = @GL_COND_OBJ_STDIO_WRITE_CONDITION@
+GL_COND_OBJ_STPCPY_CONDITION = @GL_COND_OBJ_STPCPY_CONDITION@
+GL_COND_OBJ_STRNLEN_CONDITION = @GL_COND_OBJ_STRNLEN_CONDITION@
+GL_COND_OBJ_STRTOIMAX_CONDITION = @GL_COND_OBJ_STRTOIMAX_CONDITION@
+GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@
+GL_COND_OBJ_SYMLINK_CONDITION = @GL_COND_OBJ_SYMLINK_CONDITION@
+GL_COND_OBJ_TIMEGM_CONDITION = @GL_COND_OBJ_TIMEGM_CONDITION@
+GL_COND_OBJ_TIME_RZ_CONDITION = @GL_COND_OBJ_TIME_RZ_CONDITION@
+GL_COND_OBJ_TIME_R_CONDITION = @GL_COND_OBJ_TIME_R_CONDITION@
+GL_COND_OBJ_UTIMENSAT_CONDITION = @GL_COND_OBJ_UTIMENSAT_CONDITION@
GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@
GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@
@@ -974,6 +1030,7 @@ REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
REPLACE_CHOWN = @REPLACE_CHOWN@
REPLACE_CLOSE = @REPLACE_CLOSE@
REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
+REPLACE_COPY_FILE_RANGE = @REPLACE_COPY_FILE_RANGE@
REPLACE_CREAT = @REPLACE_CREAT@
REPLACE_CTIME = @REPLACE_CTIME@
REPLACE_DIRFD = @REPLACE_DIRFD@
@@ -1197,6 +1254,8 @@ XOBJ = @XOBJ@
XRANDR_CFLAGS = @XRANDR_CFLAGS@
XRANDR_LIBS = @XRANDR_LIBS@
XRENDER_LIBS = @XRENDER_LIBS@
+XSYNC_CFLAGS = @XSYNC_CFLAGS@
+XSYNC_LIBS = @XSYNC_LIBS@
XWIDGETS_OBJ = @XWIDGETS_OBJ@
X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@
ac_ct_CC = @ac_ct_CC@
@@ -1251,8 +1310,10 @@ gl_GNULIB_ENABLED_rawmemchr_CONDITION = @gl_GNULIB_ENABLED_rawmemchr_CONDITION@
gl_GNULIB_ENABLED_scratch_buffer_CONDITION = @gl_GNULIB_ENABLED_scratch_buffer_CONDITION@
gl_GNULIB_ENABLED_strtoll_CONDITION = @gl_GNULIB_ENABLED_strtoll_CONDITION@
gl_GNULIB_ENABLED_utimens_CONDITION = @gl_GNULIB_ENABLED_utimens_CONDITION@
+gl_LIBOBJDEPS = @gl_LIBOBJDEPS@
gl_LIBOBJS = @gl_LIBOBJS@
gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJDEPS = @gltests_LIBOBJDEPS@
gltests_LIBOBJS = @gltests_LIBOBJS@
gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
gltests_WITNESS = @gltests_WITNESS@
@@ -1303,6 +1364,7 @@ x_default_search_path = @x_default_search_path@
noinst_LIBRARIES += libgnu.a
libgnu_a_SOURCES =
+libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES =
@@ -1432,10 +1494,9 @@ endif
## begin gnulib module canonicalize-lgpl
ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl))
-
-EXTRA_DIST += canonicalize-lgpl.c
-
-EXTRA_libgnu_a_SOURCES += canonicalize-lgpl.c
+ifneq (,$(GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION))
+libgnu_a_SOURCES += canonicalize-lgpl.c
+endif
endif
## end gnulib module canonicalize-lgpl
@@ -1475,10 +1536,9 @@ endif
## begin gnulib module copy-file-range
ifeq (,$(OMIT_GNULIB_MODULE_copy-file-range))
-
-EXTRA_DIST += copy-file-range.c
-
-EXTRA_libgnu_a_SOURCES += copy-file-range.c
+ifneq (,$(GL_COND_OBJ_COPY_FILE_RANGE_CONDITION))
+libgnu_a_SOURCES += copy-file-range.c
+endif
endif
## end gnulib module copy-file-range
@@ -1621,12 +1681,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_dirfd))
ifneq (,$(gl_GNULIB_ENABLED_dirfd_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_DIRFD_CONDITION))
+libgnu_a_SOURCES += dirfd.c
endif
-EXTRA_DIST += dirfd.c
-
-EXTRA_libgnu_a_SOURCES += dirfd.c
+endif
endif
## end gnulib module dirfd
@@ -1653,10 +1712,9 @@ endif
## begin gnulib module dup2
ifeq (,$(OMIT_GNULIB_MODULE_dup2))
-
-EXTRA_DIST += dup2.c
-
-EXTRA_libgnu_a_SOURCES += dup2.c
+ifneq (,$(GL_COND_OBJ_DUP2_CONDITION))
+libgnu_a_SOURCES += dup2.c
+endif
endif
## end gnulib module dup2
@@ -1747,12 +1805,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_euidaccess))
ifneq (,$(gl_GNULIB_ENABLED_euidaccess_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_EUIDACCESS_CONDITION))
+libgnu_a_SOURCES += euidaccess.c
endif
-EXTRA_DIST += euidaccess.c
-
-EXTRA_libgnu_a_SOURCES += euidaccess.c
+endif
endif
## end gnulib module euidaccess
@@ -1773,9 +1830,11 @@ execinfo.h: $(top_builddir)/config.status
endif
MOSTLYCLEANFILES += execinfo.h execinfo.h-t
-EXTRA_DIST += execinfo.c execinfo.in.h
+ifneq (,$(GL_COND_OBJ_EXECINFO_CONDITION))
+libgnu_a_SOURCES += execinfo.c
+endif
-EXTRA_libgnu_a_SOURCES += execinfo.c
+EXTRA_DIST += execinfo.in.h
endif
## end gnulib module execinfo
@@ -1783,10 +1842,9 @@ endif
## begin gnulib module explicit_bzero
ifeq (,$(OMIT_GNULIB_MODULE_explicit_bzero))
-
-EXTRA_DIST += explicit_bzero.c
-
-EXTRA_libgnu_a_SOURCES += explicit_bzero.c
+ifneq (,$(GL_COND_OBJ_EXPLICIT_BZERO_CONDITION))
+libgnu_a_SOURCES += explicit_bzero.c
+endif
endif
## end gnulib module explicit_bzero
@@ -1794,10 +1852,13 @@ endif
## begin gnulib module faccessat
ifeq (,$(OMIT_GNULIB_MODULE_faccessat))
+ifneq (,$(GL_COND_OBJ_FACCESSAT_CONDITION))
+libgnu_a_SOURCES += faccessat.c
+endif
-EXTRA_DIST += at-func.c faccessat.c
+EXTRA_DIST += at-func.c
-EXTRA_libgnu_a_SOURCES += at-func.c faccessat.c
+EXTRA_libgnu_a_SOURCES += at-func.c
endif
## end gnulib module faccessat
@@ -1805,10 +1866,13 @@ endif
## begin gnulib module fchmodat
ifeq (,$(OMIT_GNULIB_MODULE_fchmodat))
+ifneq (,$(GL_COND_OBJ_FCHMODAT_CONDITION))
+libgnu_a_SOURCES += fchmodat.c
+endif
-EXTRA_DIST += at-func.c fchmodat.c
+EXTRA_DIST += at-func.c
-EXTRA_libgnu_a_SOURCES += at-func.c fchmodat.c
+EXTRA_libgnu_a_SOURCES += at-func.c
endif
## end gnulib module fchmodat
@@ -1816,10 +1880,9 @@ endif
## begin gnulib module fcntl
ifeq (,$(OMIT_GNULIB_MODULE_fcntl))
-
-EXTRA_DIST += fcntl.c
-
-EXTRA_libgnu_a_SOURCES += fcntl.c
+ifneq (,$(GL_COND_OBJ_FCNTL_CONDITION))
+libgnu_a_SOURCES += fcntl.c
+endif
endif
## end gnulib module fcntl
@@ -1866,10 +1929,9 @@ endif
## begin gnulib module fdopendir
ifeq (,$(OMIT_GNULIB_MODULE_fdopendir))
-
-EXTRA_DIST += fdopendir.c
-
-EXTRA_libgnu_a_SOURCES += fdopendir.c
+ifneq (,$(GL_COND_OBJ_FDOPENDIR_CONDITION))
+libgnu_a_SOURCES += fdopendir.c
+endif
endif
## end gnulib module fdopendir
@@ -1925,10 +1987,11 @@ endif
## begin gnulib module fpending
ifeq (,$(OMIT_GNULIB_MODULE_fpending))
+ifneq (,$(GL_COND_OBJ_FPENDING_CONDITION))
+libgnu_a_SOURCES += fpending.c
+endif
-EXTRA_DIST += fpending.c fpending.h stdio-impl.h
-
-EXTRA_libgnu_a_SOURCES += fpending.c
+EXTRA_DIST += fpending.h stdio-impl.h
endif
## end gnulib module fpending
@@ -1936,10 +1999,9 @@ endif
## begin gnulib module free-posix
ifeq (,$(OMIT_GNULIB_MODULE_free-posix))
-
-EXTRA_DIST += free.c
-
-EXTRA_libgnu_a_SOURCES += free.c
+ifneq (,$(GL_COND_OBJ_FREE_CONDITION))
+libgnu_a_SOURCES += free.c
+endif
endif
## end gnulib module free-posix
@@ -1947,10 +2009,13 @@ endif
## begin gnulib module fstatat
ifeq (,$(OMIT_GNULIB_MODULE_fstatat))
+ifneq (,$(GL_COND_OBJ_FSTATAT_CONDITION))
+libgnu_a_SOURCES += fstatat.c
+endif
-EXTRA_DIST += at-func.c fstatat.c
+EXTRA_DIST += at-func.c
-EXTRA_libgnu_a_SOURCES += at-func.c fstatat.c
+EXTRA_libgnu_a_SOURCES += at-func.c
endif
## end gnulib module fstatat
@@ -1958,10 +2023,11 @@ endif
## begin gnulib module fsusage
ifeq (,$(OMIT_GNULIB_MODULE_fsusage))
+ifneq (,$(GL_COND_OBJ_FSUSAGE_CONDITION))
+libgnu_a_SOURCES += fsusage.c
+endif
-EXTRA_DIST += fsusage.c fsusage.h
-
-EXTRA_libgnu_a_SOURCES += fsusage.c
+EXTRA_DIST += fsusage.h
endif
## end gnulib module fsusage
@@ -1969,10 +2035,9 @@ endif
## begin gnulib module fsync
ifeq (,$(OMIT_GNULIB_MODULE_fsync))
-
-EXTRA_DIST += fsync.c
-
-EXTRA_libgnu_a_SOURCES += fsync.c
+ifneq (,$(GL_COND_OBJ_FSYNC_CONDITION))
+libgnu_a_SOURCES += fsync.c
+endif
endif
## end gnulib module fsync
@@ -1980,10 +2045,9 @@ endif
## begin gnulib module futimens
ifeq (,$(OMIT_GNULIB_MODULE_futimens))
-
-EXTRA_DIST += futimens.c
-
-EXTRA_libgnu_a_SOURCES += futimens.c
+ifneq (,$(GL_COND_OBJ_FUTIMENS_CONDITION))
+libgnu_a_SOURCES += futimens.c
+endif
endif
## end gnulib module futimens
@@ -2013,12 +2077,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_getdtablesize))
ifneq (,$(gl_GNULIB_ENABLED_getdtablesize_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_GETDTABLESIZE_CONDITION))
+libgnu_a_SOURCES += getdtablesize.c
endif
-EXTRA_DIST += getdtablesize.c
-
-EXTRA_libgnu_a_SOURCES += getdtablesize.c
+endif
endif
## end gnulib module getdtablesize
@@ -2026,22 +2089,20 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_getgroups))
ifneq (,$(gl_GNULIB_ENABLED_getgroups_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_GETGROUPS_CONDITION))
+libgnu_a_SOURCES += getgroups.c
endif
-EXTRA_DIST += getgroups.c
-
-EXTRA_libgnu_a_SOURCES += getgroups.c
+endif
endif
## end gnulib module getgroups
## begin gnulib module getloadavg
ifeq (,$(OMIT_GNULIB_MODULE_getloadavg))
-
-EXTRA_DIST += getloadavg.c
-
-EXTRA_libgnu_a_SOURCES += getloadavg.c
+ifneq (,$(GL_COND_OBJ_GETLOADAVG_CONDITION))
+libgnu_a_SOURCES += getloadavg.c
+endif
endif
## end gnulib module getloadavg
@@ -2083,9 +2144,11 @@ endif
MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
-EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.c getopt.in.h getopt1.c getopt_int.h
+ifneq (,$(GL_COND_OBJ_GETOPT_CONDITION))
+libgnu_a_SOURCES += getopt.c getopt1.c
+endif
-EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
+EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.in.h getopt_int.h
endif
## end gnulib module getopt-posix
@@ -2093,10 +2156,9 @@ endif
## begin gnulib module getrandom
ifeq (,$(OMIT_GNULIB_MODULE_getrandom))
-
-EXTRA_DIST += getrandom.c
-
-EXTRA_libgnu_a_SOURCES += getrandom.c
+ifneq (,$(GL_COND_OBJ_GETRANDOM_CONDITION))
+libgnu_a_SOURCES += getrandom.c
+endif
endif
## end gnulib module getrandom
@@ -2122,10 +2184,9 @@ endif
## begin gnulib module gettimeofday
ifeq (,$(OMIT_GNULIB_MODULE_gettimeofday))
-
-EXTRA_DIST += gettimeofday.c
-
-EXTRA_libgnu_a_SOURCES += gettimeofday.c
+ifneq (,$(GL_COND_OBJ_GETTIMEOFDAY_CONDITION))
+libgnu_a_SOURCES += gettimeofday.c
+endif
endif
## end gnulib module gettimeofday
@@ -2143,12 +2204,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_group-member))
ifneq (,$(gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_GROUP_MEMBER_CONDITION))
+libgnu_a_SOURCES += group-member.c
endif
-EXTRA_DIST += group-member.c
-
-EXTRA_libgnu_a_SOURCES += group-member.c
+endif
endif
## end gnulib module group-member
@@ -2249,12 +2309,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_lchmod))
ifneq (,$(gl_GNULIB_ENABLED_lchmod_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_LCHMOD_CONDITION))
+libgnu_a_SOURCES += lchmod.c
endif
-EXTRA_DIST += lchmod.c
-
-EXTRA_libgnu_a_SOURCES += lchmod.c
+endif
endif
## end gnulib module lchmod
@@ -2291,9 +2350,13 @@ gmp.h: $(top_builddir)/config.status
endif
MOSTLYCLEANFILES += gmp.h gmp.h-t
-EXTRA_DIST += mini-gmp-gnulib.c mini-gmp.c mini-gmp.h
+ifneq (,$(GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION))
+libgnu_a_SOURCES += mini-gmp-gnulib.c
+endif
+
+EXTRA_DIST += mini-gmp.c mini-gmp.h
-EXTRA_libgnu_a_SOURCES += mini-gmp-gnulib.c mini-gmp.c
+EXTRA_libgnu_a_SOURCES += mini-gmp.c
endif
## end gnulib module libgmp
@@ -2329,10 +2392,9 @@ endif
## begin gnulib module lstat
ifeq (,$(OMIT_GNULIB_MODULE_lstat))
-
-EXTRA_DIST += lstat.c
-
-EXTRA_libgnu_a_SOURCES += lstat.c
+ifneq (,$(GL_COND_OBJ_LSTAT_CONDITION))
+libgnu_a_SOURCES += lstat.c
+endif
endif
## end gnulib module lstat
@@ -2377,10 +2439,9 @@ endif
## begin gnulib module mempcpy
ifeq (,$(OMIT_GNULIB_MODULE_mempcpy))
-
-EXTRA_DIST += mempcpy.c
-
-EXTRA_libgnu_a_SOURCES += mempcpy.c
+ifneq (,$(GL_COND_OBJ_MEMPCPY_CONDITION))
+libgnu_a_SOURCES += mempcpy.c
+endif
endif
## end gnulib module mempcpy
@@ -2388,10 +2449,9 @@ endif
## begin gnulib module memrchr
ifeq (,$(OMIT_GNULIB_MODULE_memrchr))
-
-EXTRA_DIST += memrchr.c
-
-EXTRA_libgnu_a_SOURCES += memrchr.c
+ifneq (,$(GL_COND_OBJ_MEMRCHR_CONDITION))
+libgnu_a_SOURCES += memrchr.c
+endif
endif
## end gnulib module memrchr
@@ -2407,10 +2467,9 @@ endif
## begin gnulib module mkostemp
ifeq (,$(OMIT_GNULIB_MODULE_mkostemp))
-
-EXTRA_DIST += mkostemp.c
-
-EXTRA_libgnu_a_SOURCES += mkostemp.c
+ifneq (,$(GL_COND_OBJ_MKOSTEMP_CONDITION))
+libgnu_a_SOURCES += mkostemp.c
+endif
endif
## end gnulib module mkostemp
@@ -2463,12 +2522,11 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_open))
ifneq (,$(gl_GNULIB_ENABLED_open_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_OPEN_CONDITION))
+libgnu_a_SOURCES += open.c
endif
-EXTRA_DIST += open.c
-
-EXTRA_libgnu_a_SOURCES += open.c
+endif
endif
## end gnulib module open
@@ -2503,10 +2561,9 @@ endif
## begin gnulib module pselect
ifeq (,$(OMIT_GNULIB_MODULE_pselect))
-
-EXTRA_DIST += pselect.c
-
-EXTRA_libgnu_a_SOURCES += pselect.c
+ifneq (,$(GL_COND_OBJ_PSELECT_CONDITION))
+libgnu_a_SOURCES += pselect.c
+endif
endif
## end gnulib module pselect
@@ -2514,10 +2571,9 @@ endif
## begin gnulib module pthread_sigmask
ifeq (,$(OMIT_GNULIB_MODULE_pthread_sigmask))
-
-EXTRA_DIST += pthread_sigmask.c
-
-EXTRA_libgnu_a_SOURCES += pthread_sigmask.c
+ifneq (,$(GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION))
+libgnu_a_SOURCES += pthread_sigmask.c
+endif
endif
## end gnulib module pthread_sigmask
@@ -2534,11 +2590,12 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_rawmemchr))
ifneq (,$(gl_GNULIB_ENABLED_rawmemchr_CONDITION))
-
+ifneq (,$(GL_COND_OBJ_RAWMEMCHR_CONDITION))
+libgnu_a_SOURCES += rawmemchr.c
endif
-EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
-EXTRA_libgnu_a_SOURCES += rawmemchr.c
+endif
+EXTRA_DIST += rawmemchr.valgrind
endif
## end gnulib module rawmemchr
@@ -2546,10 +2603,9 @@ endif
## begin gnulib module readlink
ifeq (,$(OMIT_GNULIB_MODULE_readlink))
-
-EXTRA_DIST += readlink.c
-
-EXTRA_libgnu_a_SOURCES += readlink.c
+ifneq (,$(GL_COND_OBJ_READLINK_CONDITION))
+libgnu_a_SOURCES += readlink.c
+endif
endif
## end gnulib module readlink
@@ -2557,10 +2613,13 @@ endif
## begin gnulib module readlinkat
ifeq (,$(OMIT_GNULIB_MODULE_readlinkat))
+ifneq (,$(GL_COND_OBJ_READLINKAT_CONDITION))
+libgnu_a_SOURCES += readlinkat.c
+endif
-EXTRA_DIST += at-func.c readlinkat.c
+EXTRA_DIST += at-func.c
-EXTRA_libgnu_a_SOURCES += at-func.c readlinkat.c
+EXTRA_libgnu_a_SOURCES += at-func.c
endif
## end gnulib module readlinkat
@@ -2594,10 +2653,13 @@ endif
## begin gnulib module regex
ifeq (,$(OMIT_GNULIB_MODULE_regex))
+ifneq (,$(GL_COND_OBJ_REGEX_CONDITION))
+libgnu_a_SOURCES += regex.c
+endif
-EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c
+EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c
-EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
+EXTRA_libgnu_a_SOURCES += regcomp.c regex_internal.c regexec.c
endif
## end gnulib module regex
@@ -2641,10 +2703,11 @@ endif
## begin gnulib module sig2str
ifeq (,$(OMIT_GNULIB_MODULE_sig2str))
+ifneq (,$(GL_COND_OBJ_SIG2STR_CONDITION))
+libgnu_a_SOURCES += sig2str.c
+endif
-EXTRA_DIST += sig2str.c sig2str.h
-
-EXTRA_libgnu_a_SOURCES += sig2str.c
+EXTRA_DIST += sig2str.h
endif
## end gnulib module sig2str
@@ -2652,10 +2715,9 @@ endif
## begin gnulib module sigdescr_np
ifeq (,$(OMIT_GNULIB_MODULE_sigdescr_np))
-
-EXTRA_DIST += sigdescr_np.c
-
-EXTRA_libgnu_a_SOURCES += sigdescr_np.c
+ifneq (,$(GL_COND_OBJ_SIGDESCR_NP_CONDITION))
+libgnu_a_SOURCES += sigdescr_np.c
+endif
endif
## end gnulib module sigdescr_np
@@ -3004,6 +3066,13 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
$(AM_V_at)mv $@-t $@
MOSTLYCLEANFILES += stdio.h stdio.h-t
+ifneq (,$(GL_COND_OBJ_STDIO_READ_CONDITION))
+libgnu_a_SOURCES += stdio-read.c
+endif
+ifneq (,$(GL_COND_OBJ_STDIO_WRITE_CONDITION))
+libgnu_a_SOURCES += stdio-write.c
+endif
+
EXTRA_DIST += stdio.in.h
endif
@@ -3163,10 +3232,9 @@ endif
## begin gnulib module stpcpy
ifeq (,$(OMIT_GNULIB_MODULE_stpcpy))
-
-EXTRA_DIST += stpcpy.c
-
-EXTRA_libgnu_a_SOURCES += stpcpy.c
+ifneq (,$(GL_COND_OBJ_STPCPY_CONDITION))
+libgnu_a_SOURCES += stpcpy.c
+endif
endif
## end gnulib module stpcpy
@@ -3287,10 +3355,9 @@ endif
## begin gnulib module strnlen
ifeq (,$(OMIT_GNULIB_MODULE_strnlen))
-
-EXTRA_DIST += strnlen.c
-
-EXTRA_libgnu_a_SOURCES += strnlen.c
+ifneq (,$(GL_COND_OBJ_STRNLEN_CONDITION))
+libgnu_a_SOURCES += strnlen.c
+endif
endif
## end gnulib module strnlen
@@ -3298,10 +3365,9 @@ endif
## begin gnulib module strtoimax
ifeq (,$(OMIT_GNULIB_MODULE_strtoimax))
-
-EXTRA_DIST += strtoimax.c
-
-EXTRA_libgnu_a_SOURCES += strtoimax.c
+ifneq (,$(GL_COND_OBJ_STRTOIMAX_CONDITION))
+libgnu_a_SOURCES += strtoimax.c
+endif
endif
## end gnulib module strtoimax
@@ -3310,11 +3376,14 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_strtoll))
ifneq (,$(gl_GNULIB_ENABLED_strtoll_CONDITION))
+ifneq (,$(GL_COND_OBJ_STRTOLL_CONDITION))
+libgnu_a_SOURCES += strtoll.c
+endif
endif
-EXTRA_DIST += strtol.c strtoll.c
+EXTRA_DIST += strtol.c
-EXTRA_libgnu_a_SOURCES += strtol.c strtoll.c
+EXTRA_libgnu_a_SOURCES += strtol.c
endif
## end gnulib module strtoll
@@ -3322,10 +3391,9 @@ endif
## begin gnulib module symlink
ifeq (,$(OMIT_GNULIB_MODULE_symlink))
-
-EXTRA_DIST += symlink.c
-
-EXTRA_libgnu_a_SOURCES += symlink.c
+ifneq (,$(GL_COND_OBJ_SYMLINK_CONDITION))
+libgnu_a_SOURCES += symlink.c
+endif
endif
## end gnulib module symlink
@@ -3602,10 +3670,9 @@ endif
## begin gnulib module time_r
ifeq (,$(OMIT_GNULIB_MODULE_time_r))
-
-EXTRA_DIST += time_r.c
-
-EXTRA_libgnu_a_SOURCES += time_r.c
+ifneq (,$(GL_COND_OBJ_TIME_R_CONDITION))
+libgnu_a_SOURCES += time_r.c
+endif
endif
## end gnulib module time_r
@@ -3613,10 +3680,11 @@ endif
## begin gnulib module time_rz
ifeq (,$(OMIT_GNULIB_MODULE_time_rz))
+ifneq (,$(GL_COND_OBJ_TIME_RZ_CONDITION))
+libgnu_a_SOURCES += time_rz.c
+endif
-EXTRA_DIST += time-internal.h time_rz.c
-
-EXTRA_libgnu_a_SOURCES += time_rz.c
+EXTRA_DIST += time-internal.h
endif
## end gnulib module time_rz
@@ -3624,10 +3692,11 @@ endif
## begin gnulib module timegm
ifeq (,$(OMIT_GNULIB_MODULE_timegm))
+ifneq (,$(GL_COND_OBJ_TIMEGM_CONDITION))
+libgnu_a_SOURCES += timegm.c
+endif
-EXTRA_DIST += mktime-internal.h timegm.c
-
-EXTRA_libgnu_a_SOURCES += timegm.c
+EXTRA_DIST += mktime-internal.h
endif
## end gnulib module timegm
@@ -3821,6 +3890,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+ -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
-e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
@@ -3909,10 +3979,13 @@ endif
## begin gnulib module utimensat
ifeq (,$(OMIT_GNULIB_MODULE_utimensat))
+ifneq (,$(GL_COND_OBJ_UTIMENSAT_CONDITION))
+libgnu_a_SOURCES += utimensat.c
+endif
-EXTRA_DIST += at-func.c utimensat.c
+EXTRA_DIST += at-func.c
-EXTRA_libgnu_a_SOURCES += at-func.c utimensat.c
+EXTRA_libgnu_a_SOURCES += at-func.c
endif
## end gnulib module utimensat
@@ -3954,3 +4027,7 @@ mostlyclean-local: mostlyclean-generic
fi; \
done; \
:
+distclean-local: distclean-gnulib-libobjs
+distclean-gnulib-libobjs:
+ -rm -f @gl_LIBOBJDEPS@
+maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/lib/intprops.h b/lib/intprops.h
index 68d6daa570..d4a917f72a 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -229,11 +229,15 @@ #define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
-#if defined __has_builtin
+#ifdef __EDG__
+/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
+ <https://bugs.gnu.org/53256>. */
+# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
+#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
-#elif 7 <= __GNUC__ && !defined __EDG__
+#elif 7 <= __GNUC__
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#else
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
diff --git a/lib/lchmod.c b/lib/lchmod.c
index 479ed776cb..706dddff7b 100644
--- a/lib/lchmod.c
+++ b/lib/lchmod.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/memrchr.c b/lib/memrchr.c
index e853996ad0..90fdb86f1f 100644
--- a/lib/memrchr.c
+++ b/lib/memrchr.c
@@ -11,7 +11,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/mini-gmp-gnulib.c b/lib/mini-gmp-gnulib.c
index 7620da38db..a18ee8f6ab 100644
--- a/lib/mini-gmp-gnulib.c
+++ b/lib/mini-gmp-gnulib.c
@@ -6,7 +6,7 @@
It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
You can redistribute it and/or modify it under either
- the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3, or (at your
+ by the Free Software Foundation, either version 3, or (at your
option) any later version, or
- the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option)
diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c
index 8577b59ef6..e7a320a642 100644
--- a/lib/mini-gmp.c
+++ b/lib/mini-gmp.c
@@ -10,7 +10,7 @@
it under the terms of either:
* the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
+ Software Foundation, either version 3 of the License, or (at your
option) any later version.
or
diff --git a/lib/mini-gmp.h b/lib/mini-gmp.h
index 59c24cf511..508712d235 100644
--- a/lib/mini-gmp.h
+++ b/lib/mini-gmp.h
@@ -8,7 +8,7 @@
it under the terms of either:
* the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
+ Software Foundation, either version 3 of the License, or (at your
option) any later version.
or
diff --git a/lib/mktime.c b/lib/mktime.c
index aa12e28e16..7dc9d67ef9 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -429,8 +429,13 @@ __mktime_internal (struct tm *tp,
time with the right value, and use its UTC offset.
Heuristic: probe the adjacent timestamps in both directions,
- looking for the desired isdst. This should work for all real
- time zone histories in the tz database. */
+ looking for the desired isdst. If none is found within a
+ reasonable duration bound, assume a one-hour DST difference.
+ This should work for all real time zone histories in the tz
+ database. */
+
+ /* +1 if we wanted standard time but got DST, -1 if the reverse. */
+ int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
/* Distance between probes when looking for a DST boundary. In
tzdata2003a, the shortest period of DST is 601200 seconds
@@ -441,12 +446,14 @@ __mktime_internal (struct tm *tp,
periods when probing. */
int stride = 601200;
- /* The longest period of DST in tzdata2003a is 536454000 seconds
- (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
- period of non-DST is much longer, but it makes no real sense
- to search for more than a year of non-DST, so use the DST
- max. */
- int duration_max = 536454000;
+ /* In TZDB 2021e, the longest period of DST (or of non-DST), in
+ which the DST (or adjacent DST) difference is not one hour,
+ is 457243209 seconds: e.g., America/Cambridge_Bay with leap
+ seconds, starting 1965-10-31 00:00 in a switch from
+ double-daylight time (-05) to standard time (-07), and
+ continuing to 1980-04-27 02:00 in a switch from standard time
+ (-07) to daylight time (-06). */
+ int duration_max = 457243209;
/* Search in both directions, so the maximum distance is half
the duration; add the stride to avoid off-by-1 problems. */
@@ -483,6 +490,11 @@ __mktime_internal (struct tm *tp,
}
}
+ /* No unusual DST offset was found nearby. Assume one-hour DST. */
+ t += 60 * 60 * dst_difference;
+ if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
+ goto offset_found;
+
__set_errno (EOVERFLOW);
return -1;
}
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 190ff4d8f2..c1dd554247 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -3,7 +3,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
@@ -1158,7 +1158,6 @@ #define DO_NUMBER_SPACEPAD(d, v) \
case L_('q'): /* GNU extension. */
DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1);
- break;
case L_('R'):
subfmt = L_("%H:%M");
diff --git a/lib/openat-priv.h b/lib/openat-priv.h
index 451cac10cc..5d60810709 100644
--- a/lib/openat-priv.h
+++ b/lib/openat-priv.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index d5f4296d47..3bacf7dbd1 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/openat.h b/lib/openat.h
index dcb2864ffc..5c8ff90b80 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
index 42ae68ffc1..37fb179260 100644
--- a/lib/qcopy-acl.c
+++ b/lib/qcopy-acl.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/readlinkat.c b/lib/readlinkat.c
index f3d39604d2..ab45e140b5 100644
--- a/lib/readlinkat.c
+++ b/lib/readlinkat.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/save-cwd.h b/lib/save-cwd.h
index 7aa124c42f..90e8a0747c 100644
--- a/lib/save-cwd.h
+++ b/lib/save-cwd.h
@@ -5,7 +5,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index 7a7c5e4ed0..c1a4b82a0d 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/sig2str.c b/lib/sig2str.c
index f2f01d1f6f..8e2fc0c075 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/sig2str.h b/lib/sig2str.h
index a507170b64..a45af7f968 100644
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/strftime.h b/lib/strftime.h
index 9e5cdc3f32..a9847084f0 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/string.in.h b/lib/string.in.h
index 03e6a17a36..c9432948c1 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -563,22 +563,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
# undef strndup
# define strndup rpl_strndup
# endif
-_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
# else
-# if ! @HAVE_DECL_STRNDUP@
-_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
- _GL_ARG_NONNULL ((1)));
+# if !@HAVE_DECL_STRNDUP@ || __GNUC__ >= 11
+_GL_FUNCDECL_SYS (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
# endif
_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
# endif
_GL_CXXALIASWARN (strndup);
-#elif defined GNULIB_POSIXCHECK
-# undef strndup
-# if HAVE_RAW_DECL_STRNDUP
+#else
+# if __GNUC__ >= 11
+/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
+_GL_FUNCDECL_SYS (strndup, char *,
+ (char const *__s, size_t __n)
+ _GL_ARG_NONNULL ((1))
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
+# endif
+# if defined GNULIB_POSIXCHECK
+# undef strndup
+# if HAVE_RAW_DECL_STRNDUP
_GL_WARN_ON_USE (strndup, "strndup is unportable - "
"use gnulib module strndup for portability");
+# endif
# endif
#endif
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index d562746ee7..cad12d0d9b 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -5,7 +5,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/strtol.c b/lib/strtol.c
index 457f7a5d64..6c2e9333ab 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -8,7 +8,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/strtoll.c b/lib/strtoll.c
index 5124168c1b..acea42ee00 100644
--- a/lib/strtoll.c
+++ b/lib/strtoll.c
@@ -5,7 +5,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/symlink.c b/lib/symlink.c
index 51850b2732..26310af7b1 100644
--- a/lib/symlink.c
+++ b/lib/symlink.c
@@ -3,7 +3,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/time-internal.h b/lib/time-internal.h
index e1bb56e53e..c8a2a8ce6b 100644
--- a/lib/time-internal.h
+++ b/lib/time-internal.h
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/time_rz.c b/lib/time_rz.c
index d0ae717f30..1a91d3778e 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index cd0b5f5f5b..0f270e5bc8 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 2b2aaa5937..36747833e3 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/timespec.c b/lib/timespec.c
index 82630c2f5a..9d136cb803 100644
--- a/lib/timespec.c
+++ b/lib/timespec.c
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/timespec.h b/lib/timespec.h
index e130d2c6e2..9e358289a2 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -5,7 +5,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 3386f0b0f7..57df09ecdf 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -415,16 +415,30 @@ _GL_CXXALIASWARN (close);
#if @GNULIB_COPY_FILE_RANGE@
-# if !@HAVE_COPY_FILE_RANGE@
+# if @REPLACE_COPY_FILE_RANGE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef copy_file_range
+# define copy_file_range rpl_copy_file_range
+# endif
+_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+# else
+# if !@HAVE_COPY_FILE_RANGE@
_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
int ofd, off_t *opos,
size_t len, unsigned flags));
+# endif
_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
int ofd, off_t *opos,
size_t len, unsigned flags));
# endif
_GL_CXXALIASWARN (copy_file_range);
#elif defined GNULIB_POSIXCHECK
+# undef copy_file_range
# if HAVE_RAW_DECL_COPY_FILE_RANGE
_GL_WARN_ON_USE (copy_file_range,
"copy_file_range is unportable - "
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index ce52f8f977..7461d74095 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/utimens.c b/lib/utimens.c
index f4907ae4e6..2fa1251850 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/utimens.h b/lib/utimens.h
index c3054da0c6..2ccc06e5ed 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -4,7 +4,7 @@
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 3 of the
+ published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This file is distributed in the hope that it will be useful,
diff --git a/lib/utimensat.c b/lib/utimensat.c
index 2e4c7bf966..f81b0c790e 100644
--- a/lib/utimensat.c
+++ b/lib/utimensat.c
@@ -3,7 +3,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/lib/vla.h b/lib/vla.h
index adc8f8f68b..ce02428f53 100644
--- a/lib/vla.h
+++ b/lib/vla.h
@@ -4,7 +4,7 @@
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
+ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4
index 4c7ec4eaaf..1b8b9d8858 100644
--- a/m4/copy-file-range.m4
+++ b/m4/copy-file-range.m4
@@ -7,6 +7,7 @@
AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
dnl Persuade glibc <unistd.h> to declare copy_file_range.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -21,7 +22,7 @@ AC_DEFUN
[AC_LANG_PROGRAM(
[[#include <unistd.h>
]],
- [[ssize_t (*func) (int, off_t *, int, off_t, size_t, unsigned)
+ [[ssize_t (*func) (int, off_t *, int, off_t *, size_t, unsigned)
= copy_file_range;
return func (0, 0, 0, 0, 0, 0) & 127;
]])
@@ -32,5 +33,27 @@ AC_DEFUN
if test "$gl_cv_func_copy_file_range" != yes; then
HAVE_COPY_FILE_RANGE=0
+ else
+ AC_DEFINE([HAVE_COPY_FILE_RANGE], 1,
+ [Define to 1 if the function copy_file_range exists.])
+
+ case $host_os in
+ linux*)
+ AC_CACHE_CHECK([whether copy_file_range is known to work],
+ [gl_cv_copy_file_range_known_to_work],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <linux/version.h>
+ ]],
+ [[#if LINUX_VERSION_CODE < KERNEL_VERSION (5, 3, 0)
+ #error "copy_file_range is buggy"
+ #endif
+ ]])],
+ [gl_cv_copy_file_range_known_to_work=yes],
+ [gl_cv_copy_file_range_known_to_work=no])])
+ if test "$gl_cv_copy_file_range_known_to_work" = no; then
+ REPLACE_COPY_FILE_RANGE=1
+ fi;;
+ esac
fi
])
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 2e914dbc07..8a12bddd57 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -7,7 +7,22 @@
AC_DEFUN([gl_EXTERN_INLINE],
[
- AH_VERBATIM([extern_inline],
+ AC_CACHE_CHECK([whether ctype.h defines __header_inline],
+ [gl_cv_have___header_inline],
+ [AC_PREPROC_IFELSE(
+ [AC_LANG_SOURCE([[#include <ctype.h>
+ #ifndef __header_inline
+ #error "<ctype.h> does not define __header_inline"
+ #endif
+ ]])],
+ [gl_cv_have___header_inline=yes],
+ [gl_cv_have___header_inline=no])])
+ if test "$gl_cv_have___header_inline" = yes; then
+ AC_DEFINE([HAVE___HEADER_INLINE], [1],
+ [Define to 1 if ctype.h defines __header_inline.])
+ fi
+
+ AH_VERBATIM([HAVE___HEADER_INLINE_1],
[/* Please see the Gnulib manual for how to use these macros.
Suppress extern inline with HP-UX cc, as it appears to be broken; see
@@ -54,7 +69,7 @@ AC_DEFUN
*/
#if (((defined __APPLE__ && defined __MACH__) \
|| defined __DragonFly__ || defined __FreeBSD__) \
- && (defined __header_inline \
+ && (defined HAVE___HEADER_INLINE \
? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
&& ! defined __clang__) \
: ((! defined _DONT_USE_CTYPE_INLINE_ \
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 87a9a751b6..dbc4079614 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 69
+# gnulib-common.m4 serial 72
dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -181,7 +181,12 @@ AC_DEFUN
#else
# define _GL_ATTRIBUTE_DEALLOC(f, i)
#endif
-#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
+ to use this earlier definition, since <stdlib.h> may not have been included
+ yet. */
+#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+#endif
/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
The compiler may warn if the entity is used. */
@@ -813,6 +818,24 @@ AC_DEFUN
])
])
+# gl_CONDITIONAL(conditional, condition)
+# is like AM_CONDITIONAL(conditional, condition), except that it does not
+# produce an error
+# configure: error: conditional "..." was never defined.
+# Usually this means the macro was only invoked conditionally.
+# when only invoked conditionally. Instead, in that case, both the _TRUE
+# and the _FALSE case are disabled.
+AC_DEFUN([gl_CONDITIONAL],
+[
+ pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
+ AM_CONDITIONAL([$1], [$2])
+ popdef([AC_CONFIG_COMMANDS_PRE])dnl
+ if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
+ [$1]_TRUE='#'
+ [$1]_FALSE='#'
+ fi
+])
+
# gl_CC_ALLOW_WARNINGS
# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
# that reverts a preceding '-Werror' option, if available.
@@ -879,6 +902,72 @@ AC_DEFUN
AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
])
+# gl_CC_GNULIB_WARNINGS
+# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
+# set that enables or disables warnings as suitable for the Gnulib coding style.
+AC_DEFUN([gl_CC_GNULIB_WARNINGS],
+[
+ AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
+ dnl Assume that the compiler supports -Wno-* options only if it also supports
+ dnl -Wno-error.
+ GL_CFLAG_GNULIB_WARNINGS=''
+ if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
+ dnl Enable these warning options:
+ dnl
+ dnl GCC clang
+ dnl -Wno-cast-qual >= 3 >= 3.9
+ dnl -Wno-conversion >= 3 >= 3.9
+ dnl -Wno-float-conversion >= 4.9 >= 3.9
+ dnl -Wno-float-equal >= 3 >= 3.9
+ dnl -Wimplicit-fallthrough >= 7 >= 3.9
+ dnl -Wno-pedantic >= 4.8 >= 3.9
+ dnl -Wno-sign-compare >= 3 >= 3.9
+ dnl -Wno-sign-conversion >= 4.3 >= 3.9
+ dnl -Wno-type-limits >= 4.3 >= 3.9
+ dnl -Wno-undef >= 3 >= 3.9
+ dnl -Wno-unsuffixed-float-constants >= 4.5
+ dnl -Wno-unused-function >= 3 >= 3.9
+ dnl -Wno-unused-parameter >= 3 >= 3.9
+ dnl
+ cat > conftest.c <<\EOF
+ #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
+ -Wno-cast-qual
+ -Wno-conversion
+ -Wno-float-equal
+ -Wno-sign-compare
+ -Wno-undef
+ -Wno-unused-function
+ -Wno-unused-parameter
+ #endif
+ #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
+ -Wno-float-conversion
+ #endif
+ #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
+ -Wimplicit-fallthrough
+ #endif
+ #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
+ -Wno-pedantic
+ #endif
+ #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
+ -Wno-sign-conversion
+ -Wno-type-limits
+ #endif
+ #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
+ -Wno-unsuffixed-float-constants
+ #endif
+EOF
+ gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
+ if AC_TRY_EVAL([gl_command]); then
+ gl_options=`grep -v '#' conftest.out`
+ for word in $gl_options; do
+ GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
+ done
+ fi
+ rm -f conftest.c conftest.out
+ fi
+ AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
+])
+
dnl gl_CONDITIONAL_HEADER([foo.h])
dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
dnl and produces
@@ -903,7 +992,7 @@ AC_DEFUN
*) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
esac
AC_SUBST(gl_header_name)
- AM_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
+ gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
m4_popdef([gl_generate_cond])
m4_popdef([gl_generate_var])
m4_popdef([gl_header_name])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index c47ea915f1..1d31239d2d 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -3,7 +3,7 @@
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
@@ -236,9 +236,8 @@ AC_DEFUN
gl_CONDITIONAL_HEADER([byteswap.h])
AC_PROG_MKDIR_P
gl_CANONICALIZE_LGPL
- if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then
- AC_LIBOBJ([canonicalize-lgpl])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_CANONICALIZE_LGPL],
+ [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1])
gl_MODULE_INDICATOR([canonicalize-lgpl])
gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name])
gl_STDLIB_MODULE_INDICATOR([realpath])
@@ -247,9 +246,9 @@ AC_DEFUN
gl_CLOCK_TIME
gl_MODULE_INDICATOR([close-stream])
gl_FUNC_COPY_FILE_RANGE
- if test $HAVE_COPY_FILE_RANGE = 0; then
- AC_LIBOBJ([copy-file-range])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_COPY_FILE_RANGE],
+ [test $HAVE_COPY_FILE_RANGE = 0 ||
+ test $REPLACE_COPY_FILE_RANGE = 1])
gl_UNISTD_MODULE_INDICATOR([copy-file-range])
AC_REQUIRE([AC_C_RESTRICT])
gl_MD5
@@ -265,10 +264,10 @@ AC_DEFUN
AC_PROG_MKDIR_P
gl_DOUBLE_SLASH_ROOT
gl_FUNC_DUP2
- if test $REPLACE_DUP2 = 1; then
- AC_LIBOBJ([dup2])
+ gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1])
+ AM_COND_IF([GL_COND_OBJ_DUP2], [
gl_PREREQ_DUP2
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([dup2])
gl_ENVIRON
gl_UNISTD_MODULE_INDICATOR([environ])
@@ -278,83 +277,77 @@ AC_DEFUN
gl_EXECINFO_H
gl_CONDITIONAL_HEADER([execinfo.h])
AC_PROG_MKDIR_P
- if $GL_GENERATE_EXECINFO_H; then
- AC_LIBOBJ([execinfo])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_EXECINFO], [$GL_GENERATE_EXECINFO_H])
gl_FUNC_EXPLICIT_BZERO
- if test $HAVE_EXPLICIT_BZERO = 0; then
- AC_LIBOBJ([explicit_bzero])
+ gl_CONDITIONAL([GL_COND_OBJ_EXPLICIT_BZERO], [test $HAVE_EXPLICIT_BZERO = 0])
+ AM_COND_IF([GL_COND_OBJ_EXPLICIT_BZERO], [
gl_PREREQ_EXPLICIT_BZERO
- fi
+ ])
gl_STRING_MODULE_INDICATOR([explicit_bzero])
AC_REQUIRE([gl_EXTERN_INLINE])
gl_FUNC_FACCESSAT
- if test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1; then
- AC_LIBOBJ([faccessat])
+ gl_CONDITIONAL([GL_COND_OBJ_FACCESSAT],
+ [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1])
+ AM_COND_IF([GL_COND_OBJ_FACCESSAT], [
gl_PREREQ_FACCESSAT
- fi
+ ])
gl_MODULE_INDICATOR([faccessat])
gl_UNISTD_MODULE_INDICATOR([faccessat])
gl_FUNC_FCHMODAT
- if test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1; then
- AC_LIBOBJ([fchmodat])
+ gl_CONDITIONAL([GL_COND_OBJ_FCHMODAT],
+ [test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1])
+ AM_COND_IF([GL_COND_OBJ_FCHMODAT], [
gl_PREREQ_FCHMODAT
- fi
+ ])
gl_SYS_STAT_MODULE_INDICATOR([fchmodat])
gl_FUNC_FCNTL
- if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
- AC_LIBOBJ([fcntl])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_FCNTL],
+ [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1])
gl_FCNTL_MODULE_INDICATOR([fcntl])
gl_FCNTL_H
gl_FCNTL_H_REQUIRE_DEFAULTS
AC_PROG_MKDIR_P
gl_FUNC_FDOPENDIR
- if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then
- AC_LIBOBJ([fdopendir])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_FDOPENDIR],
+ [test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1])
gl_DIRENT_MODULE_INDICATOR([fdopendir])
gl_MODULE_INDICATOR([fdopendir])
gl_FILE_HAS_ACL
gl_FILEMODE
AC_C_FLEXIBLE_ARRAY_MEMBER
gl_FUNC_FPENDING
- if test $gl_cv_func___fpending = no; then
- AC_LIBOBJ([fpending])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_FPENDING], [test $gl_cv_func___fpending = no])
gl_FUNC_FREE
- if test $REPLACE_FREE = 1; then
- AC_LIBOBJ([free])
+ gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1])
+ AM_COND_IF([GL_COND_OBJ_FREE], [
gl_PREREQ_FREE
- fi
+ ])
gl_STDLIB_MODULE_INDICATOR([free-posix])
gl_FUNC_FSTATAT
- if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
- AC_LIBOBJ([fstatat])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_FSTATAT],
+ [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1])
gl_SYS_STAT_MODULE_INDICATOR([fstatat])
gl_FSUSAGE
- if test $gl_cv_fs_space = yes; then
- AC_LIBOBJ([fsusage])
+ gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes])
+ AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
gl_PREREQ_FSUSAGE_EXTRA
- fi
+ ])
gl_FUNC_FSYNC
- if test $HAVE_FSYNC = 0; then
- AC_LIBOBJ([fsync])
+ gl_CONDITIONAL([GL_COND_OBJ_FSYNC], [test $HAVE_FSYNC = 0])
+ AM_COND_IF([GL_COND_OBJ_FSYNC], [
gl_PREREQ_FSYNC
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([fsync])
gl_FUNC_FUTIMENS
- if test $HAVE_FUTIMENS = 0 || test $REPLACE_FUTIMENS = 1; then
- AC_LIBOBJ([futimens])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_FUTIMENS],
+ [test $HAVE_FUTIMENS = 0 || test $REPLACE_FUTIMENS = 1])
gl_SYS_STAT_MODULE_INDICATOR([futimens])
AC_REQUIRE([AC_CANONICAL_HOST])
gl_GETLOADAVG
- if test $HAVE_GETLOADAVG = 0; then
- AC_LIBOBJ([getloadavg])
+ gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
+ AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
gl_PREREQ_GETLOADAVG
- fi
+ ])
gl_STDLIB_MODULE_INDICATOR([getloadavg])
gl_FUNC_GETOPT_GNU
dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required
@@ -364,26 +357,25 @@ AC_DEFUN
gl_CONDITIONAL_HEADER([getopt.h])
gl_CONDITIONAL_HEADER([getopt-cdefs.h])
AC_PROG_MKDIR_P
- if test $REPLACE_GETOPT = 1; then
- AC_LIBOBJ([getopt])
- AC_LIBOBJ([getopt1])
+ gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1])
+ AM_COND_IF([GL_COND_OBJ_GETOPT], [
dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1.
gl_UNISTD_H_REQUIRE_DEFAULTS
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([getopt-posix])
AC_REQUIRE([AC_CANONICAL_HOST])
gl_FUNC_GETRANDOM
- if test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1; then
- AC_LIBOBJ([getrandom])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM],
+ [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1])
gl_SYS_RANDOM_MODULE_INDICATOR([getrandom])
gl_GETTIME
gl_FUNC_GETTIMEOFDAY
- if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then
- AC_LIBOBJ([gettimeofday])
+ gl_CONDITIONAL([GL_COND_OBJ_GETTIMEOFDAY],
+ [test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1])
+ AM_COND_IF([GL_COND_OBJ_GETTIMEOFDAY], [
gl_PREREQ_GETTIMEOFDAY
- fi
+ ])
gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
gl_IEEE754_H
gl_CONDITIONAL_HEADER([ieee754.h])
@@ -396,17 +388,15 @@ AC_DEFUN
gl_LIBGMP
gl_CONDITIONAL_HEADER([gmp.h])
AC_PROG_MKDIR_P
- if test $HAVE_LIBGMP != yes; then
- AC_LIBOBJ([mini-gmp-gnulib])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_MINI_GMP_GNULIB], [test $HAVE_LIBGMP != yes])
gl_LIMITS_H
gl_CONDITIONAL_HEADER([limits.h])
AC_PROG_MKDIR_P
gl_FUNC_LSTAT
- if test $REPLACE_LSTAT = 1; then
- AC_LIBOBJ([lstat])
+ gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1])
+ AM_COND_IF([GL_COND_OBJ_LSTAT], [
gl_PREREQ_LSTAT
- fi
+ ])
gl_SYS_STAT_MODULE_INDICATOR([lstat])
gl_FUNC_MEMMEM_SIMPLE
if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then
@@ -414,23 +404,23 @@ AC_DEFUN
fi
gl_STRING_MODULE_INDICATOR([memmem])
gl_FUNC_MEMPCPY
- if test $HAVE_MEMPCPY = 0; then
- AC_LIBOBJ([mempcpy])
+ gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], [test $HAVE_MEMPCPY = 0])
+ AM_COND_IF([GL_COND_OBJ_MEMPCPY], [
gl_PREREQ_MEMPCPY
- fi
+ ])
gl_STRING_MODULE_INDICATOR([mempcpy])
gl_FUNC_MEMRCHR
- if test $ac_cv_func_memrchr = no; then
- AC_LIBOBJ([memrchr])
+ gl_CONDITIONAL([GL_COND_OBJ_MEMRCHR], [test $ac_cv_func_memrchr = no])
+ AM_COND_IF([GL_COND_OBJ_MEMRCHR], [
gl_PREREQ_MEMRCHR
- fi
+ ])
gl_STRING_MODULE_INDICATOR([memrchr])
gl_MINMAX
gl_FUNC_MKOSTEMP
- if test $HAVE_MKOSTEMP = 0; then
- AC_LIBOBJ([mkostemp])
+ gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMP], [test $HAVE_MKOSTEMP = 0])
+ AM_COND_IF([GL_COND_OBJ_MKOSTEMP], [
gl_PREREQ_MKOSTEMP
- fi
+ ])
gl_MODULE_INDICATOR([mkostemp])
gl_STDLIB_MODULE_INDICATOR([mkostemp])
gl_FUNC_MKTIME
@@ -446,41 +436,39 @@ AC_DEFUN
gl_FUNC_PIPE2
gl_UNISTD_MODULE_INDICATOR([pipe2])
gl_FUNC_PSELECT
- if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then
- AC_LIBOBJ([pselect])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_PSELECT],
+ [test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1])
gl_SYS_SELECT_MODULE_INDICATOR([pselect])
gl_FUNC_PTHREAD_SIGMASK
- if test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1; then
- AC_LIBOBJ([pthread_sigmask])
+ gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_SIGMASK],
+ [test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1])
+ AM_COND_IF([GL_COND_OBJ_PTHREAD_SIGMASK], [
gl_PREREQ_PTHREAD_SIGMASK
- fi
+ ])
gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask])
gl_FUNC_READLINK
- if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
- AC_LIBOBJ([readlink])
+ gl_CONDITIONAL([GL_COND_OBJ_READLINK],
+ [test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1])
+ AM_COND_IF([GL_COND_OBJ_READLINK], [
gl_PREREQ_READLINK
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([readlink])
gl_FUNC_READLINKAT
- if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then
- AC_LIBOBJ([readlinkat])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_READLINKAT],
+ [test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1])
gl_UNISTD_MODULE_INDICATOR([readlinkat])
gl_REGEX
- if test $ac_use_included_regex = yes; then
- AC_LIBOBJ([regex])
+ gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes])
+ AM_COND_IF([GL_COND_OBJ_REGEX], [
gl_PREREQ_REGEX
- fi
+ ])
gl_FUNC_SIG2STR
- if test $ac_cv_func_sig2str = no; then
- AC_LIBOBJ([sig2str])
+ gl_CONDITIONAL([GL_COND_OBJ_SIG2STR], [test $ac_cv_func_sig2str = no])
+ AM_COND_IF([GL_COND_OBJ_SIG2STR], [
gl_PREREQ_SIG2STR
- fi
+ ])
gl_FUNC_SIGDESCR_NP
- if test $HAVE_SIGDESCR_NP = 0; then
- AC_LIBOBJ([sigdescr_np])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_SIGDESCR_NP], [test $HAVE_SIGDESCR_NP = 0])
gl_STRING_MODULE_INDICATOR([sigdescr_np])
gl_SIGNAL_H
gl_SIGNAL_H_REQUIRE_DEFAULTS
@@ -504,6 +492,8 @@ AC_DEFUN
gl_STDIO_H
gl_STDIO_H_REQUIRE_DEFAULTS
AC_PROG_MKDIR_P
+ gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1])
+ gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1])
dnl No need to create extra modules for these functions. Everyone who uses
dnl <stdio.h> likely needs them.
gl_STDIO_MODULE_INDICATOR([fscanf])
@@ -531,30 +521,31 @@ AC_DEFUN
gl_STDLIB_H_REQUIRE_DEFAULTS
AC_PROG_MKDIR_P
gl_FUNC_STPCPY
- if test $HAVE_STPCPY = 0; then
- AC_LIBOBJ([stpcpy])
+ gl_CONDITIONAL([GL_COND_OBJ_STPCPY], [test $HAVE_STPCPY = 0])
+ AM_COND_IF([GL_COND_OBJ_STPCPY], [
gl_PREREQ_STPCPY
- fi
+ ])
gl_STRING_MODULE_INDICATOR([stpcpy])
gl_STRING_H
gl_STRING_H_REQUIRE_DEFAULTS
AC_PROG_MKDIR_P
gl_FUNC_STRNLEN
- if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
- AC_LIBOBJ([strnlen])
+ gl_CONDITIONAL([GL_COND_OBJ_STRNLEN],
+ [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1])
+ AM_COND_IF([GL_COND_OBJ_STRNLEN], [
gl_PREREQ_STRNLEN
- fi
+ ])
gl_STRING_MODULE_INDICATOR([strnlen])
gl_FUNC_STRTOIMAX
- if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
- AC_LIBOBJ([strtoimax])
+ gl_CONDITIONAL([GL_COND_OBJ_STRTOIMAX],
+ [test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1])
+ AM_COND_IF([GL_COND_OBJ_STRTOIMAX], [
gl_PREREQ_STRTOIMAX
- fi
+ ])
gl_INTTYPES_MODULE_INDICATOR([strtoimax])
gl_FUNC_SYMLINK
- if test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1; then
- AC_LIBOBJ([symlink])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_SYMLINK],
+ [test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1])
gl_UNISTD_MODULE_INDICATOR([symlink])
gl_SYS_RANDOM_H
gl_SYS_RANDOM_H_REQUIRE_DEFAULTS
@@ -577,21 +568,21 @@ AC_DEFUN
gl_TIME_H_REQUIRE_DEFAULTS
AC_PROG_MKDIR_P
gl_TIME_R
- if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
- AC_LIBOBJ([time_r])
+ gl_CONDITIONAL([GL_COND_OBJ_TIME_R],
+ [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1])
+ AM_COND_IF([GL_COND_OBJ_TIME_R], [
gl_PREREQ_TIME_R
- fi
+ ])
gl_TIME_MODULE_INDICATOR([time_r])
gl_TIME_RZ
- if test $HAVE_TIMEZONE_T = 0; then
- AC_LIBOBJ([time_rz])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_TIME_RZ], [test $HAVE_TIMEZONE_T = 0])
gl_TIME_MODULE_INDICATOR([time_rz])
gl_FUNC_TIMEGM
- if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
- AC_LIBOBJ([timegm])
+ gl_CONDITIONAL([GL_COND_OBJ_TIMEGM],
+ [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1])
+ AM_COND_IF([GL_COND_OBJ_TIMEGM], [
gl_PREREQ_TIMEGM
- fi
+ ])
gl_TIME_MODULE_INDICATOR([timegm])
gl_TIMER_TIME
gl_TIMESPEC
@@ -610,9 +601,8 @@ AC_DEFUN
[An alias of GNULIB_STDIO_SINGLE_THREAD.])
gl_FUNC_GLIBC_UNLOCKED_IO
gl_FUNC_UTIMENSAT
- if test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1; then
- AC_LIBOBJ([utimensat])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_UTIMENSAT],
+ [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1])
gl_SYS_STAT_MODULE_INDICATOR([utimensat])
AC_C_VARARRAYS
gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
@@ -660,11 +650,11 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_dirfd; then
gl_FUNC_DIRFD
- if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no \
- || test $REPLACE_DIRFD = 1; then
- AC_LIBOBJ([dirfd])
+ gl_CONDITIONAL([GL_COND_OBJ_DIRFD],
+ [test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no || test $REPLACE_DIRFD = 1])
+ AM_COND_IF([GL_COND_OBJ_DIRFD], [
gl_PREREQ_DIRFD
- fi
+ ])
gl_DIRENT_MODULE_INDICATOR([dirfd])
gl_gnulib_enabled_dirfd=true
fi
@@ -686,10 +676,10 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_euidaccess; then
gl_FUNC_EUIDACCESS
- if test $HAVE_EUIDACCESS = 0; then
- AC_LIBOBJ([euidaccess])
+ gl_CONDITIONAL([GL_COND_OBJ_EUIDACCESS], [test $HAVE_EUIDACCESS = 0])
+ AM_COND_IF([GL_COND_OBJ_EUIDACCESS], [
gl_PREREQ_EUIDACCESS
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([euidaccess])
gl_gnulib_enabled_euidaccess=true
if test $HAVE_EUIDACCESS = 0; then
@@ -702,10 +692,11 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_getdtablesize; then
gl_FUNC_GETDTABLESIZE
- if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then
- AC_LIBOBJ([getdtablesize])
+ gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE],
+ [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1])
+ AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [
gl_PREREQ_GETDTABLESIZE
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([getdtablesize])
gl_gnulib_enabled_getdtablesize=true
fi
@@ -714,9 +705,8 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_getgroups; then
gl_FUNC_GETGROUPS
- if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then
- AC_LIBOBJ([getgroups])
- fi
+ gl_CONDITIONAL([GL_COND_OBJ_GETGROUPS],
+ [test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1])
gl_UNISTD_MODULE_INDICATOR([getgroups])
gl_gnulib_enabled_getgroups=true
if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then
@@ -736,10 +726,10 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1; then
gl_FUNC_GROUP_MEMBER
- if test $HAVE_GROUP_MEMBER = 0; then
- AC_LIBOBJ([group-member])
+ gl_CONDITIONAL([GL_COND_OBJ_GROUP_MEMBER], [test $HAVE_GROUP_MEMBER = 0])
+ AM_COND_IF([GL_COND_OBJ_GROUP_MEMBER], [
gl_PREREQ_GROUP_MEMBER
- fi
+ ])
gl_UNISTD_MODULE_INDICATOR([group-member])
gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=true
if test $HAVE_GROUP_MEMBER = 0; then
@@ -754,10 +744,10 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_lchmod; then
gl_FUNC_LCHMOD
- if test $HAVE_LCHMOD = 0; then
- AC_LIBOBJ([lchmod])
+ gl_CONDITIONAL([GL_COND_OBJ_LCHMOD], [test $HAVE_LCHMOD = 0])
+ AM_COND_IF([GL_COND_OBJ_LCHMOD], [
gl_PREREQ_LCHMOD
- fi
+ ])
gl_SYS_STAT_MODULE_INDICATOR([lchmod])
gl_gnulib_enabled_lchmod=true
fi
@@ -806,10 +796,10 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_open; then
gl_FUNC_OPEN
- if test $REPLACE_OPEN = 1; then
- AC_LIBOBJ([open])
+ gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
+ AM_COND_IF([GL_COND_OBJ_OPEN], [
gl_PREREQ_OPEN
- fi
+ ])
gl_FCNTL_MODULE_INDICATOR([open])
gl_gnulib_enabled_open=true
if test $REPLACE_OPEN = 1; then
@@ -827,10 +817,10 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_rawmemchr; then
gl_FUNC_RAWMEMCHR
- if test $HAVE_RAWMEMCHR = 0; then
- AC_LIBOBJ([rawmemchr])
+ gl_CONDITIONAL([GL_COND_OBJ_RAWMEMCHR], [test $HAVE_RAWMEMCHR = 0])
+ AM_COND_IF([GL_COND_OBJ_RAWMEMCHR], [
gl_PREREQ_RAWMEMCHR
- fi
+ ])
gl_STRING_MODULE_INDICATOR([rawmemchr])
gl_gnulib_enabled_rawmemchr=true
fi
@@ -889,10 +879,11 @@ AC_DEFUN
{
if ! $gl_gnulib_enabled_strtoll; then
gl_FUNC_STRTOLL
- if test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1; then
- AC_LIBOBJ([strtoll])
+ gl_CONDITIONAL([GL_COND_OBJ_STRTOLL],
+ [test $HAVE_STRTOLL = 0 || test $REPLACE_STRTOLL = 1])
+ AM_COND_IF([GL_COND_OBJ_STRTOLL], [
gl_PREREQ_STRTOLL
- fi
+ ])
gl_STDLIB_MODULE_INDICATOR([strtoll])
gl_gnulib_enabled_strtoll=true
fi
@@ -1035,16 +1026,28 @@ AC_DEFUN
AC_CONFIG_COMMANDS_PRE([
gl_libobjs=
gl_ltlibobjs=
+ gl_libobjdeps=
if test -n "$gl_LIBOBJS"; then
# Remove the extension.
+changequote(,)dnl
sed_drop_objext='s/\.o$//;s/\.obj$//'
+ sed_dirname1='s,//*,/,g'
+ sed_dirname2='s,\(.\)/$,\1,'
+ sed_dirname3='s,^[^/]*$,.,'
+ sed_dirname4='s,\(.\)/[^/]*$,\1,'
+ sed_basename1='s,.*/,,'
+changequote([, ])dnl
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
gl_libobjs="$gl_libobjs $i.$ac_objext"
gl_ltlibobjs="$gl_ltlibobjs $i.lo"
+ i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
+ i_base=`echo "$i" | sed -e "$sed_basename1"`
+ gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
done
fi
AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
+ AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps])
])
gltests_libdeps=
gltests_ltlibdeps=
@@ -1087,17 +1090,30 @@ AC_DEFUN
AC_CONFIG_COMMANDS_PRE([
gltests_libobjs=
gltests_ltlibobjs=
+ gltests_libobjdeps=
if test -n "$gltests_LIBOBJS"; then
# Remove the extension.
+changequote(,)dnl
sed_drop_objext='s/\.o$//;s/\.obj$//'
+ sed_dirname1='s,//*,/,g'
+ sed_dirname2='s,\(.\)/$,\1,'
+ sed_dirname3='s,^[^/]*$,.,'
+ sed_dirname4='s,\(.\)/[^/]*$,\1,'
+ sed_basename1='s,.*/,,'
+changequote([, ])dnl
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
gltests_libobjs="$gltests_libobjs $i.$ac_objext"
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
+ i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
+ i_base=`echo "$i" | sed -e "$sed_basename1"`
+ gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
done
fi
AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
+ AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps])
])
+ AC_REQUIRE([gl_CC_GNULIB_WARNINGS])
LIBGNU_LIBDEPS="$gl_libdeps"
AC_SUBST([LIBGNU_LIBDEPS])
LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
@@ -1330,6 +1346,8 @@ AC_DEFUN
lib/stddef.in.h
lib/stdint.in.h
lib/stdio-impl.h
+ lib/stdio-read.c
+ lib/stdio-write.c
lib/stdio.in.h
lib/stdlib.in.h
lib/stpcpy.c
diff --git a/m4/libgmp.m4 b/m4/libgmp.m4
index a2dee93382..d69dcc7237 100644
--- a/m4/libgmp.m4
+++ b/m4/libgmp.m4
@@ -1,4 +1,4 @@
-# libgmp.m4 serial 6
+# libgmp.m4 serial 7
# Configure the GMP library or a replacement.
dnl Copyright 2020-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -63,8 +63,8 @@ AC_DEFUN
else
GL_GENERATE_GMP_H=true
fi
- AM_CONDITIONAL([GL_GENERATE_MINI_GMP_H],
+ gl_CONDITIONAL([GL_GENERATE_MINI_GMP_H],
[test $HAVE_LIBGMP != yes])
- AM_CONDITIONAL([GL_GENERATE_GMP_GMP_H],
+ gl_CONDITIONAL([GL_GENERATE_GMP_GMP_H],
[test $HAVE_LIBGMP = yes && test "$ac_cv_header_gmp_h" != yes])
])
diff --git a/m4/mktime.m4 b/m4/mktime.m4
index d48f40d187..431b17dcb0 100644
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,4 +1,4 @@
-# serial 36
+# serial 37
dnl Copyright (C) 2002-2003, 2005-2007, 2009-2022 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
@@ -82,7 +82,8 @@ AC_DEFUN
instead of "TZ=America/Vancouver" in order to detect the bug even
on systems that don't support the Olson extension, or don't have the
full zoneinfo tables installed. */
- putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+ if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
+ return -1;
tm.tm_year = 98;
tm.tm_mon = 3;
@@ -170,7 +171,8 @@ AC_DEFUN
instead of "TZ=America/Vancouver" in order to detect the bug even
on systems that don't support the Olson extension, or don't have the
full zoneinfo tables installed. */
- putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
+ if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
+ return -1;
t = mktime (&tm);
@@ -181,6 +183,25 @@ AC_DEFUN
|| (0 < t && answer - 120 <= t && t <= answer + 120));
}
+static int
+indiana_test ()
+{
+ if (putenv ("TZ=America/Indiana/Indianapolis") != 0)
+ return -1;
+ struct tm tm;
+ tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28;
+ tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0;
+ time_t std = mktime (&tm);
+ if (! (std == 515107490 || std == 515107503))
+ return 1;
+
+ /* This platform supports TZDB, either without or with leap seconds.
+ Return true if GNU Bug#48085 is absent. */
+ tm.tm_isdst = 1;
+ time_t dst = mktime (&tm);
+ return std - dst == 60 * 60;
+}
+
int
main ()
{
@@ -236,7 +257,7 @@ AC_DEFUN
result |= 16;
if (! spring_forward_gap ())
result |= 32;
- if (! year_2050_test ())
+ if (! year_2050_test () || ! indiana_test ())
result |= 64;
return result;
}]])],
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index cc80e77365..42e96071f8 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 57
+# stdio_h.m4 serial 59
dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -40,41 +40,32 @@ AC_DEFUN_ONCE
attribute "__gnu_printf__" instead of "__printf__"])
fi
- dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
- dnl "expected source file, required through AC_LIBSOURCES, not found". It is
- dnl also an optimization, to avoid performing a configure check whose result
- dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
- dnl or GNULIB_NONBLOCKING redundant.
+ dnl This ifdef is an optimization, to avoid performing a configure check whose
+ dnl result is not used. But it does not make the test of
+ dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
m4_ifdef([gl_NONBLOCKING_IO], [
gl_NONBLOCKING_IO
if test $gl_cv_have_nonblocking != yes; then
REPLACE_STDIO_READ_FUNCS=1
- AC_LIBOBJ([stdio-read])
fi
])
- dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
- dnl "expected source file, required through AC_LIBSOURCES, not found". It is
- dnl also an optimization, to avoid performing a configure check whose result
- dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
- dnl GNULIB_SIGPIPE redundant.
+ dnl This ifdef is an optimization, to avoid performing a configure check whose
+ dnl result is not used. But it does not make the test of
+ dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
m4_ifdef([gl_SIGNAL_SIGPIPE], [
gl_SIGNAL_SIGPIPE
if test $gl_cv_header_signal_h_SIGPIPE != yes; then
REPLACE_STDIO_WRITE_FUNCS=1
- AC_LIBOBJ([stdio-write])
fi
])
- dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
- dnl "expected source file, required through AC_LIBSOURCES, not found". It is
- dnl also an optimization, to avoid performing a configure check whose result
- dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
- dnl or GNULIB_NONBLOCKING redundant.
+ dnl This ifdef is an optimization, to avoid performing a configure check whose
+ dnl result is not used. But it does not make the test of
+ dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
m4_ifdef([gl_NONBLOCKING_IO], [
gl_NONBLOCKING_IO
if test $gl_cv_have_nonblocking != yes; then
REPLACE_STDIO_WRITE_FUNCS=1
- AC_LIBOBJ([stdio-write])
fi
])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index f93f97a1bd..4c66ccc0a4 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -222,6 +222,7 @@ AC_DEFUN
REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
+ REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
--
2.32.0
[-- Attachment #4: 0003-Port-to-current-Gnulib-some-more.patch --]
[-- Type: text/x-patch, Size: 1077 bytes --]
From a773a7831226c146edd40dbaf97f3cfad995f8ee Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 23 Feb 2022 11:23:05 -0800
Subject: [PATCH 3/4] Port to current Gnulib some more
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* admin/merge-gnulib: Remove lib/stdio-read.c and lib/stdio-write.c,
as Emacs doesn’t need these new Gnulib files.
---
admin/merge-gnulib | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 73b3d39049..4045eabf4e 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -109,7 +109,9 @@ avoided_flags=
"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
$avoided_flags $GNULIB_MODULES &&
-rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 \
+rm -- "$src"lib/gl_openssl.h \
+ "$src"lib/stdio-read.c "$src"lib/stdio-write.c \
+ "$src"m4/fcntl-o.m4 \
"$src"m4/gl-openssl.m4 \
"$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
"$src"m4/manywarnings-c++.m4 \
--
2.32.0
[-- Attachment #5: 0004-Port-pre-commit-hook-to-Git-2.35.0.patch --]
[-- Type: text/x-patch, Size: 1050 bytes --]
From b8a96f055624f86fe965a0d1b7b2495b2db80e63 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 23 Feb 2022 11:29:56 -0800
Subject: [PATCH 4/4] Port pre-commit hook to Git 2.35.0
* build-aux/git-hooks/pre-commit: Use LC_ALL=C grep -E instead of
sane_egrep (removed in Git 2.35.0).
---
build-aux/git-hooks/pre-commit | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit
index a55004680f..49bf05f2d9 100755
--- a/build-aux/git-hooks/pre-commit
+++ b/build-aux/git-hooks/pre-commit
@@ -45,7 +45,9 @@ git_diff=
# 'git diff' will backslash escape tabs and newlines, so we don't have
# to worry about word splitting here.
-$git_diff $head | sane_egrep 'ChangeLog|^-|/-|[^-+./_0-9A-Z_a-z]' | while IFS= read -r new_name; do
+$git_diff $head |
+LC_ALL=C grep -E 'ChangeLog|^-|/-|[^-+./_0-9A-Z_a-z]' |
+while IFS= read -r new_name; do
case $new_name in
-* | */-*)
echo "$new_name: File name component begins with '-'."
--
2.32.0
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-23 19:45 ` Paul Eggert
@ 2022-02-23 19:48 ` Lars Ingebrigtsen
2022-02-23 22:29 ` Paul Eggert
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-23 19:48 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Noam Postavsky
Paul Eggert <eggert@cs.ucla.edu> writes:
> I think the problem was mostly due to Gnulib's recent changing of how
> it handles conditionally-generated directories like lib/alloca.h. I
> installed the first attached patch to try to fix this. The second
> patch is the result of running admin/merge-gnulib, and the third does
> a minor cleanup of two new Gnulib files that Emacs doesn't need.
Thanks; it seems to get a bit further now, but fails here:
Checking for autoconf (need at least version 2.65) ... ok
Your system has the required tools.
Building aclocal.m4 ...
Running 'autoreconf -fi -I m4' ...
configure.ac:6060: warning: gl_FUNC_CLOSE is m4_require'd but not m4_defun'd
m4/fclose.m4:7: gl_FUNC_FCLOSE is expanded from...
m4/gnulib-comp.m4:225: gl_INIT is expanded from...
configure.ac:6060: the top level
configure:27383: error: possibly undefined macro: gl_FUNC_CLOSE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: error: /usr/bin/autoconf failed with exit status: 1
> Also, I installed the fourth attached patch to port Emacs's Git hooks
> to Git 2.35.1, the current Git version, as Emacs was relying on an
> undocumented Git feature that Git removed. (Am I the only Emacs
> developer using up-to-date Git?)
I just use whatever is in Debian/testing, which is:
$ git --version
git version 2.34.1
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-23 19:48 ` Lars Ingebrigtsen
@ 2022-02-23 22:29 ` Paul Eggert
2022-02-23 22:40 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Paul Eggert @ 2022-02-23 22:29 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, Noam Postavsky
On 2/23/22 11:48, Lars Ingebrigtsen wrote:
> it seems to get a bit further now, but fails here:
Looks like you need to fetch the latest Gnulib and/or build from
scratch, as I think I fixed those symptoms in Gnulib here:
https://lists.gnu.org/r/bug-gnulib/2022-02/index.html
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-23 22:29 ` Paul Eggert
@ 2022-02-23 22:40 ` Lars Ingebrigtsen
2022-02-24 3:09 ` Paul Eggert
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-23 22:40 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Noam Postavsky
Paul Eggert <eggert@cs.ucla.edu> writes:
> Looks like you need to fetch the latest Gnulib and/or build from
> scratch, as I think I fixed those symptoms in Gnulib here:
Yup, after fetching the latest Gnulib, admin/merge-gnulib seems to work
fine (i.e., changes almost nothing since you've just merged).
But it does alter this file:
* edited lib/gnulib.mk.in
Is that normal? The diff on that file starts with the following, and
there's only line deletions in the diff -- almost 1K lines deleted:
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 6b90a80f64..25c991b961 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -170,31 +170,14 @@
MOSTLYCLEANFILES += core *.stackdump
# Start of GNU Make output.
-ALLOCA = @ALLOCA@
-ALLOCA_H = @ALLOCA_H@
-ALSA_CFLAGS = @ALSA_CFLAGS@
-ALSA_LIBS = @ALSA_LIBS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
AR = @AR@
-ARFLAGS = @ARFLAGS@
AUTO_DEPEND = @AUTO_DEPEND@
-AWK = @AWK@
-BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@
-BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@
-BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@
-BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@
-BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@
BLESSMAIL_TARGET = @BLESSMAIL_TARGET@
BREW = @BREW@
BUILD_DETAILS = @BUILD_DETAILS@
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-23 22:40 ` Lars Ingebrigtsen
@ 2022-02-24 3:09 ` Paul Eggert
2022-02-24 8:57 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Paul Eggert @ 2022-02-24 3:09 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, Noam Postavsky
On 2/23/22 14:40, Lars Ingebrigtsen wrote:
>
> MOSTLYCLEANFILES += core *.stackdump
> # Start of GNU Make output.
> -ALLOCA = @ALLOCA@
> -ALLOCA_H = @ALLOCA_H@
That means something went wrong. It looks like you're using a mixture of
the old and new somehow. You might try removing autom4te.cache and
re-running admin/merge-gnulib.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-24 3:09 ` Paul Eggert
@ 2022-02-24 8:57 ` Lars Ingebrigtsen
2022-02-24 18:20 ` Paul Eggert
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-24 8:57 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Noam Postavsky
Paul Eggert <eggert@cs.ucla.edu> writes:
> On 2/23/22 14:40, Lars Ingebrigtsen wrote:
>> MOSTLYCLEANFILES += core *.stackdump
>> # Start of GNU Make output.
>> -ALLOCA = @ALLOCA@
>> -ALLOCA_H = @ALLOCA_H@
>
> That means something went wrong. It looks like you're using a mixture
> of the old and new somehow. You might try removing autom4te.cache and
> re-running admin/merge-gnulib.
The problem was that I was running admin/merge-gnulib from a fresh
checkout -- you have to run (at least) autogen.sh first. Perhaps that
should be noted in admin/notes/repo, or possibly fixed in the
merge-gnulib script?
In any case, if I do that now, I get a diff that's just a single line:
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 6b90a80f64..3a9f5b9818 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -207,7 +207,6 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CRYPTOLIB = @CRYPTOLIB@
CXX = @CXX@
-CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGWIN_OBJ = @CYGWIN_OBJ@
C_SWITCH_MACHINE = @C_SWITCH_MACHINE@
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-24 8:57 ` Lars Ingebrigtsen
@ 2022-02-24 18:20 ` Paul Eggert
2022-02-25 2:19 ` Lars Ingebrigtsen
2022-02-25 2:27 ` Lars Ingebrigtsen
0 siblings, 2 replies; 53+ messages in thread
From: Paul Eggert @ 2022-02-24 18:20 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, Noam Postavsky
[-- Attachment #1: Type: text/plain, Size: 772 bytes --]
On 2/24/22 00:57, Lars Ingebrigtsen wrote:
> The problem was that I was running admin/merge-gnulib from a fresh
> checkout -- you have to run (at least) autogen.sh first. Perhaps that
> should be noted in admin/notes/repo, or possibly fixed in the
> merge-gnulib script?
Thanks for reporting that; I installed the attached.
> In any case, if I do that now, I get a diff that's just a single line:
>
> -CXXCPP = @CXXCPP@
That's probably due to differing versions of Autoconf. It shouldn't
matter for Emacs since Emacs doesn't use CXXCPP.
It is annoying that this difference would occur on different platforms;
for now, I wouldn't worry about it (or install the change, as it'll just
be overwritten the next time I do a Gnulib update).
I use Fedora autoconf FWIW.
[-- Attachment #2: 0001-admin-merge-gnulib-fix-bare-checkout-Bug-32452-65.patch --]
[-- Type: text/x-patch, Size: 692 bytes --]
From bd17fa2c7565f180cedbfa396c0b159e144178cb Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 24 Feb 2022 10:12:50 -0800
Subject: [PATCH] * admin/merge-gnulib: fix bare checkout (Bug#32452#65)
---
admin/merge-gnulib | 3 +++
1 file changed, 3 insertions(+)
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 4045eabf4e..4aabffa0dc 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -102,6 +102,9 @@ gnulib_srcdir=
exit 1
}
+# gnulib-tool has problems with a bare checkout (Bug#32452#65).
+test -f configure || ./autogen.sh
+
avoided_flags=
for module in $AVOIDED_MODULES; do
avoided_flags="$avoided_flags --avoid=$module"
--
2.32.0
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-24 18:20 ` Paul Eggert
@ 2022-02-25 2:19 ` Lars Ingebrigtsen
2022-02-25 2:27 ` Lars Ingebrigtsen
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-25 2:19 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Noam Postavsky
Paul Eggert <eggert@cs.ucla.edu> writes:
> Thanks for reporting that; I installed the attached.
Thanks.
>> In any case, if I do that now, I get a diff that's just a single line:
>> -CXXCPP = @CXXCPP@
>
> That's probably due to differing versions of Autoconf. It shouldn't
> matter for Emacs since Emacs doesn't use CXXCPP.
>
> It is annoying that this difference would occur on different
> platforms; for now, I wouldn't worry about it (or install the change,
> as it'll just be overwritten the next time I do a Gnulib update).
Right; will do.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-24 18:20 ` Paul Eggert
2022-02-25 2:19 ` Lars Ingebrigtsen
@ 2022-02-25 2:27 ` Lars Ingebrigtsen
2022-02-25 20:41 ` Paul Eggert
[not found] ` <6f364184-7fa8-04f3-44a9-22ce40b872e8@cs.ucla.edu>
1 sibling, 2 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-25 2:27 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Noam Postavsky
I tried to include the nanosleep module by adding to GNULIB_MODULES and
then doing the merge, and the set of new files looks reasonable:
./
admin/
edited admin/merge-gnulib
lib/
edited lib/gnulib.mk.in
unregistered lib/nanosleep.c
unregistered lib/sig-handler.c
unregistered lib/sig-handler.h
unregistered lib/sigaction.c
m4/
edited m4/gnulib-comp.m4
unregistered m4/nanosleep.m4
unregistered m4/sigaction.m4
But autogen.sh fails:
Running 'autoreconf -fi -I m4' ...
configure.ac:6060: warning: gl_FUNC_SELECT is m4_require'd but not m4_defun'd
m4/nanosleep.m4:14: gl_FUNC_NANOSLEEP is expanded from...
m4/gnulib-comp.m4:215: gl_INIT is expanded from...
configure.ac:6060: the top level
configure:29948: error: possibly undefined macro: gl_FUNC_SELECT
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: error: /usr/bin/autoconf failed with exit status: 1
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-25 2:27 ` Lars Ingebrigtsen
@ 2022-02-25 20:41 ` Paul Eggert
[not found] ` <6f364184-7fa8-04f3-44a9-22ce40b872e8@cs.ucla.edu>
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-02-25 20:41 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, Gnulib bugs, Noam Postavsky
[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]
On 2/24/22 18:27, Lars Ingebrigtsen wrote:
> But autogen.sh fails:
>
> Running 'autoreconf -fi -I m4' ...
> configure.ac:6060: warning: gl_FUNC_SELECT is m4_require'd but not m4_defun'd
This is because Gnulib's 'nanosleep' module depended on the 'select'
module, but Emacs's admin/merge-gnulib avoids the 'select' module
(because Emacs relies on pselect instead and has its own MS-DOS pselect
substitute).
Gnulib's nanosleep appears to use select only for old Unixish platforms
that were relevant in 2000 but aren't practical porting targets any
more. So I installed into Gnulib the attached patch to simplify Gnulib
nanosleep by having it fall back on pselect rather than select, and to
not bother with signal handling. This should cause your addition of
nanosleep to admin/merge-gnulib to add only the files lib/nanosleep.c
and m4/nanosleep.m4 (not the other, signal-related files you mentioned;
they shouldn't be needed with Emacs).
You might also want to adopt my recent little merge-gnulib changes.
I notice that Emacs's GNUstep code calls 'select'. For completeness this
should be 'pselect' instead, so that Emacs never calls 'select'.
[-- Attachment #2: 0001-nanosleep-simplify-by-using-pselect.patch --]
[-- Type: text/x-patch, Size: 8620 bytes --]
From 2510ffcdcdad4e5cd20455b4891de4f5e128072a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 25 Feb 2022 11:54:49 -0800
Subject: [PATCH] nanosleep: simplify by using pselect
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GNU Emacs avoids Gnulib’s ‘select’ module and uses only pselect,
which it implements in a special way on MS-DOS.
Unfortunately, though, nanosleep uses ‘select’;
problem reported by Lars Ingebrigtsen (Bug#32452#74).
As far as I can tell, Gnulib nanosleep's use of
‘select’ with signals is only for ancient platforms
that Gnulib no longer cares about, so remove that use of ‘select’.
I don’t know of any platforms that still need this fallback code,
but just in case, fall back to pselect instead, while removing
signal handling that it shouldn’t be needed nowadays.
* lib/nanosleep.c: Do not include sig-handler.h, sys/time.h.
(SIGCONT, suspended, sighandler, my_usleep): Remove.
(nanosleep) [!HAVE_BUG_BIG_NANOSLEEP && !(_WIN32 && !__CYGWIN__)]:
Just call pselect.
* m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Do not check for sys/time.h
or call gl_FUNC_SELECT. Do not include sys/time.h or worry
about LIBSOCKET.
(gl_PREREQ_NANOSLEEP): Remove as it’s no longer needed.
All uses removed.
* modules/nanosleep (Depends-on): Add pselect.
Remove select, sigaction, sys_time.
---
ChangeLog | 25 +++++++++++++
lib/nanosleep.c | 89 +++--------------------------------------------
m4/nanosleep.m4 | 24 +------------
modules/nanosleep | 7 +---
4 files changed, 31 insertions(+), 114 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3499d066e4..49a1e6a168 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2022-02-25 Paul Eggert <eggert@cs.ucla.edu>
+
+ nanosleep: simplify by using pselect
+ GNU Emacs avoids Gnulib’s ‘select’ module and uses only pselect,
+ which it implements in a special way on MS-DOS.
+ Unfortunately, though, nanosleep uses ‘select’;
+ problem reported by Lars Ingebrigtsen (Bug#32452#74).
+ As far as I can tell, Gnulib nanosleep's use of
+ ‘select’ with signals is only for ancient platforms
+ that Gnulib no longer cares about, so remove that use of ‘select’.
+ I don’t know of any platforms that still need this fallback code,
+ but just in case, fall back to pselect instead, while removing
+ signal handling that it shouldn’t be needed nowadays.
+ * lib/nanosleep.c: Do not include sig-handler.h, sys/time.h.
+ (SIGCONT, suspended, sighandler, my_usleep): Remove.
+ (nanosleep) [!HAVE_BUG_BIG_NANOSLEEP && !(_WIN32 && !__CYGWIN__)]:
+ Just call pselect.
+ * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Do not check for sys/time.h
+ or call gl_FUNC_SELECT. Do not include sys/time.h or worry
+ about LIBSOCKET.
+ (gl_PREREQ_NANOSLEEP): Remove as it’s no longer needed.
+ All uses removed.
+ * modules/nanosleep (Depends-on): Add pselect.
+ Remove select, sigaction, sys_time.
+
2022-02-24 Paul Eggert <eggert@cs.ucla.edu>
userspec: warn about '.' separator
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
index 5294c646ae..446794edc0 100644
--- a/lib/nanosleep.c
+++ b/lib/nanosleep.c
@@ -23,7 +23,6 @@
#include <time.h>
#include "intprops.h"
-#include "sig-handler.h"
#include "verify.h"
#include <stdbool.h>
@@ -32,7 +31,6 @@
#include <sys/select.h>
#include <signal.h>
-#include <sys/time.h>
#include <errno.h>
#include <unistd.h>
@@ -181,45 +179,9 @@ nanosleep (const struct timespec *requested_delay,
}
#else
-/* Unix platforms lacking nanosleep. */
-
-/* Some systems (MSDOS) don't have SIGCONT.
- Using SIGTERM here turns the signal-handling code below
- into a no-op on such systems. */
-# ifndef SIGCONT
-# define SIGCONT SIGTERM
-# endif
-
-static sig_atomic_t volatile suspended;
-
-/* Handle SIGCONT. */
-
-static _GL_ASYNC_SAFE void
-sighandler (int sig)
-{
- suspended = 1;
-}
-
-/* Suspend execution for at least *TS_DELAY seconds. */
-
-static int
-my_usleep (const struct timespec *ts_delay)
-{
- struct timeval tv_delay;
- tv_delay.tv_sec = ts_delay->tv_sec;
- tv_delay.tv_usec = (ts_delay->tv_nsec + 999) / 1000;
- if (tv_delay.tv_usec == 1000000)
- {
- if (tv_delay.tv_sec == TYPE_MAXIMUM (time_t))
- tv_delay.tv_usec = 1000000 - 1; /* close enough */
- else
- {
- tv_delay.tv_sec++;
- tv_delay.tv_usec = 0;
- }
- }
- return select (0, NULL, NULL, NULL, &tv_delay);
-}
+/* Other platforms lacking nanosleep.
+ It's not clear whether these are still practical porting targets.
+ For now, just fall back on pselect. */
/* Suspend execution for at least *REQUESTED_DELAY seconds. The
*REMAINING_DELAY part isn't implemented yet. */
@@ -228,49 +190,6 @@ int
nanosleep (const struct timespec *requested_delay,
struct timespec *remaining_delay)
{
- static bool initialized;
-
- if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
- {
- errno = EINVAL;
- return -1;
- }
-
- /* set up sig handler */
- if (! initialized)
- {
- struct sigaction oldact;
-
- sigaction (SIGCONT, NULL, &oldact);
- if (get_handler (&oldact) != SIG_IGN)
- {
- struct sigaction newact;
-
- newact.sa_handler = sighandler;
- sigemptyset (&newact.sa_mask);
- newact.sa_flags = 0;
- sigaction (SIGCONT, &newact, NULL);
- }
- initialized = true;
- }
-
- suspended = 0;
-
- if (my_usleep (requested_delay) == -1)
- {
- if (suspended)
- {
- /* Calculate time remaining. */
- /* FIXME: the code in sleep doesn't use this, so there's no
- rush to implement it. */
-
- errno = EINTR;
- }
- return -1;
- }
-
- /* FIXME: Restore sig handler? */
-
- return 0;
+ return pselect (0, NULL, NULL, NULL, requested_delay, NULL);
}
#endif
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
index 6a51f28e30..1964b1ea47 100644
--- a/m4/nanosleep.m4
+++ b/m4/nanosleep.m4
@@ -1,4 +1,4 @@
-# serial 40
+# serial 41
dnl From Jim Meyering.
dnl Check for the nanosleep function.
@@ -19,9 +19,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
- AC_CHECK_HEADERS_ONCE([sys/time.h])
- AC_REQUIRE([gl_FUNC_SELECT])
-
AC_CHECK_DECLS_ONCE([alarm])
nanosleep_save_libs=$LIBS
@@ -53,9 +50,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
#include <errno.h>
#include <limits.h>
#include <signal.h>
- #if HAVE_SYS_TIME_H
- #include <sys/time.h>
- #endif
#include <time.h>
#include <unistd.h>
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
@@ -135,15 +129,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
[Define to 1 if nanosleep mishandles large arguments.])
;;
- *)
- # The replacement uses select(). Add $LIBSOCKET to $LIB_NANOSLEEP.
- for ac_lib in $LIBSOCKET; do
- case " $LIB_NANOSLEEP " in
- *" $ac_lib "*) ;;
- *) LIB_NANOSLEEP="$LIB_NANOSLEEP $ac_lib";;
- esac
- done
- ;;
esac
;;
esac
@@ -152,10 +137,3 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
fi
LIBS=$nanosleep_save_libs
])
-
-# Prerequisites of lib/nanosleep.c.
-AC_DEFUN([gl_PREREQ_NANOSLEEP],
-[
- AC_CHECK_HEADERS_ONCE([sys/select.h])
- gl_PREREQ_SIG_HANDLER_H
-])
diff --git a/modules/nanosleep b/modules/nanosleep
index 53c5dc5f7c..a8d0c76744 100644
--- a/modules/nanosleep
+++ b/modules/nanosleep
@@ -10,20 +10,15 @@ time
extensions
multiarch
intprops [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
-select [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
-sigaction [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
+pselect [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
stdbool [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
sys_select [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
-sys_time [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
verify [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1]
configure.ac:
gl_FUNC_NANOSLEEP
gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP],
[test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1])
-AM_COND_IF([GL_COND_OBJ_NANOSLEEP], [
- gl_PREREQ_NANOSLEEP
-])
gl_TIME_MODULE_INDICATOR([nanosleep])
Makefile.am:
--
2.32.0
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <6f364184-7fa8-04f3-44a9-22ce40b872e8@cs.ucla.edu>
@ 2022-02-26 15:12 ` Lars Ingebrigtsen
2022-02-26 15:37 ` Eli Zaretskii
[not found] ` <83ee3pprkr.fsf@gnu.org>
0 siblings, 2 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-26 15:12 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, Gnulib bugs, Noam Postavsky
Paul Eggert <eggert@cs.ucla.edu> writes:
> Gnulib's nanosleep appears to use select only for old Unixish
> platforms that were relevant in 2000 but aren't practical porting
> targets any more. So I installed into Gnulib the attached patch to
> simplify Gnulib nanosleep by having it fall back on pselect rather
> than select, and to not bother with signal handling. This should cause
> your addition of nanosleep to admin/merge-gnulib to add only the files
> lib/nanosleep.c and m4/nanosleep.m4 (not the other, signal-related
> files you mentioned; they shouldn't be needed with Emacs).
Thanks; that does indeed fix the issues, and ./admin/merge-gnulib now
works fine for me when I add nanosleep to the list of modules.
> I notice that Emacs's GNUstep code calls 'select'. For completeness
> this should be 'pselect' instead, so that Emacs never calls 'select'.
OK; I'll have a look at that...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-26 15:12 ` Lars Ingebrigtsen
@ 2022-02-26 15:37 ` Eli Zaretskii
[not found] ` <83ee3pprkr.fsf@gnu.org>
1 sibling, 0 replies; 53+ messages in thread
From: Eli Zaretskii @ 2022-02-26 15:37 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, bug-gnulib, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Noam Postavsky <npostavs@gmail.com>, 32452@debbugs.gnu.org, Eli
> Zaretskii <eliz@gnu.org>, Gnulib bugs <bug-gnulib@gnu.org>
> Date: Sat, 26 Feb 2022 16:12:23 +0100
>
> Paul Eggert <eggert@cs.ucla.edu> writes:
>
> > Gnulib's nanosleep appears to use select only for old Unixish
> > platforms that were relevant in 2000 but aren't practical porting
> > targets any more. So I installed into Gnulib the attached patch to
> > simplify Gnulib nanosleep by having it fall back on pselect rather
> > than select, and to not bother with signal handling. This should cause
> > your addition of nanosleep to admin/merge-gnulib to add only the files
> > lib/nanosleep.c and m4/nanosleep.m4 (not the other, signal-related
> > files you mentioned; they shouldn't be needed with Emacs).
>
> Thanks; that does indeed fix the issues, and ./admin/merge-gnulib now
> works fine for me when I add nanosleep to the list of modules.
>
> > I notice that Emacs's GNUstep code calls 'select'. For completeness
> > this should be 'pselect' instead, so that Emacs never calls 'select'.
>
> OK; I'll have a look at that...
Please post the patch before landing it. Gnulib's nanosleep is
problematic on MS-Windows (and shouldn't be used there anyway), so I'd
like to eyeball the changes before they are installed.
Thanks.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <83ee3pprkr.fsf@gnu.org>
@ 2022-02-26 16:04 ` Lars Ingebrigtsen
[not found] ` <87pmn9txzo.fsf@gnus.org>
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-26 16:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, bug-gnulib, npostavs, 32452
Eli Zaretskii <eliz@gnu.org> writes:
> Please post the patch before landing it. Gnulib's nanosleep is
> problematic on MS-Windows (and shouldn't be used there anyway), so I'd
> like to eyeball the changes before they are installed.
Will do.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87pmn9txzo.fsf@gnus.org>
@ 2022-02-28 8:59 ` Lars Ingebrigtsen
[not found] ` <87ee3ns6x0.fsf@gnus.org>
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-28 8:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, bug-gnulib, npostavs, 32452
I tried adding nanosleep to the modules, and updated, and then tried to
use nanosleep from gnutls.c. But it doesn't build (on Debian/bookworm):
/usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
/home/larsi/src/emacs/trunk/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
collect2: error: ld returned 1 exit status
I tried poking at lib/time.h, but I just don't understand how this all
hooks up:
# if 1
# if 1
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define nanosleep rpl_nanosleep
with nanosleep.c...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87ee3ns6x0.fsf@gnus.org>
@ 2022-02-28 12:28 ` Eli Zaretskii
[not found] ` <83y21vmaye.fsf@gnu.org>
` (2 subsequent siblings)
3 siblings, 0 replies; 53+ messages in thread
From: Eli Zaretskii @ 2022-02-28 12:28 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, bug-gnulib, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: eggert@cs.ucla.edu, bug-gnulib@gnu.org, npostavs@gmail.com,
> 32452@debbugs.gnu.org
> Date: Mon, 28 Feb 2022 09:59:39 +0100
>
> /usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
> /home/larsi/src/emacs/trunk/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
> collect2: error: ld returned 1 exit status
>
> I tried poking at lib/time.h, but I just don't understand how this all
> hooks up:
>
> # if 1
> # if 1
> # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
> # define nanosleep rpl_nanosleep
>
> with nanosleep.c...
And there's no rpl_nanosleep anywhere in sight?
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <83y21vmaye.fsf@gnu.org>
@ 2022-02-28 12:31 ` Lars Ingebrigtsen
2022-02-28 12:35 ` Lars Ingebrigtsen
[not found] ` <877d9fnp7g.fsf@gnus.org>
0 siblings, 2 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-28 12:31 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, bug-gnulib, npostavs, 32452
Eli Zaretskii <eliz@gnu.org> writes:
> And there's no rpl_nanosleep anywhere in sight?
Nope:
grep --color=auto -nH --null -e rpl_nanosleep `find . -type f`
./lib/time.h647:# define nanosleep rpl_nanosleep
./lib/time.in.h140:# define nanosleep rpl_nanosleep
And that's it.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-02-28 12:31 ` Lars Ingebrigtsen
@ 2022-02-28 12:35 ` Lars Ingebrigtsen
[not found] ` <877d9fnp7g.fsf@gnus.org>
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-28 12:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, bug-gnulib, npostavs, 32452
Lars Ingebrigtsen <larsi@gnus.org> writes:
> grep --color=auto -nH --null -e rpl_nanosleep `find . -type f`
> ./lib/time.h647:# define nanosleep rpl_nanosleep
> ./lib/time.in.h140:# define nanosleep rpl_nanosleep
>
> And that's it.
The header file continues:
# if 0
# if GNULIB_PORTCHECK
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define nanosleep rpl_nanosleep
# endif
_GL_FUNCDECL_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# else
# if ! 1
_GL_FUNCDECL_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
_GL_CXXALIASWARN (nanosleep);
# endif
So perhaps it's taking the wrong route here somewhere in the
preprocessor, but I don't know how this is supposed to work.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <877d9fnp7g.fsf@gnus.org>
@ 2022-02-28 12:46 ` Eli Zaretskii
0 siblings, 0 replies; 53+ messages in thread
From: Eli Zaretskii @ 2022-02-28 12:46 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, bug-gnulib, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: eggert@cs.ucla.edu, bug-gnulib@gnu.org, npostavs@gmail.com,
> 32452@debbugs.gnu.org
> Date: Mon, 28 Feb 2022 13:35:47 +0100
>
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > grep --color=auto -nH --null -e rpl_nanosleep `find . -type f`
> > ./lib/time.h647:# define nanosleep rpl_nanosleep
> > ./lib/time.in.h140:# define nanosleep rpl_nanosleep
> >
> > And that's it.
>
> The header file continues:
>
> # if 0
> # if GNULIB_PORTCHECK
> # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
> # define nanosleep rpl_nanosleep
> # endif
> _GL_FUNCDECL_RPL (nanosleep, int,
> (struct timespec const *__rqtp, struct timespec *__rmtp)
> _GL_ARG_NONNULL ((1)));
> _GL_CXXALIAS_RPL (nanosleep, int,
> (struct timespec const *__rqtp, struct timespec *__rmtp));
My guess is that _GL_FUNCDECL_RPL should produce a rpl_nanosleep.
But I'm sure Gnulib folks will see the reason much faster than my
guesses.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87ee3ns6x0.fsf@gnus.org>
2022-02-28 12:28 ` Eli Zaretskii
[not found] ` <83y21vmaye.fsf@gnu.org>
@ 2022-02-28 21:47 ` Paul Eggert
[not found] ` <78c5037a-ac96-e7be-532f-b1776ed25b2b@cs.ucla.edu>
3 siblings, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-02-28 21:47 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, bug-gnulib, npostavs
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]
On 2/28/22 00:59, Lars Ingebrigtsen wrote:
> /usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
> /home/larsi/src/emacs/trunk/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
Evidently my recent workarounds in Emacs to handle running gnulib-tool
from a bare checkout were not sufficient. I installed the attached patch
to up the ante; please give it a try.
It is unfortunate that emacs/admin/merge-gnulib now runs gnulib-tool
twice from a bare checkout, as gnulib-tool is quite slow.
I think gnulib-tool needs to run twice because it builds
emacs/lib/gnulib.mk.in before it builds emacs/m4/gnulib-comp.m4, and so
doesn't use the newly-added emacs/m4/nanosleep.m4 to figure out the new
X=@X@ lines that needed to be added to emacs/lib/gnulib.mk.in. I suspect
that this is related to Emacs's using Gnu Make rather than Automake.
However, I haven't debugged this out.
[-- Attachment #2: 0001-Work-around-merge-gnulib-glitch-from-fresh-checkout.patch --]
[-- Type: text/x-patch, Size: 2854 bytes --]
From d150eb438baa62ef3965ef4dc1f9f342ed839a18 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 28 Feb 2022 13:16:44 -0800
Subject: [PATCH] Work around merge-gnulib glitch from fresh checkout
* admin/merge-gnulib: In a fresh checkout, run gnulib-tool
twice, instead of merely running autogen.sh twice.
---
admin/merge-gnulib | 54 +++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..7219fadd47 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -102,34 +102,44 @@ gnulib_srcdir=
exit 1
}
-# gnulib-tool has problems with a bare checkout (Bug#32452#65).
-test -f configure || ./autogen.sh || exit
-
# Old caches can confuse autoconf when some Gnulib-related changes take effect.
rm -fr autom4te.cache || exit
+# gnulib-tool has problems with a bare checkout (Bug#32452#91).
+if test -f configure; then
+ passes='1'
+else
+ passes='1 2'
+fi
+
avoided_flags=
for module in $AVOIDED_MODULES; do
avoided_flags="$avoided_flags --avoid=$module"
done
-"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
+for pass in $passes; do
+ case $pass in
+ 2) echo 'Running gnulib-tool again to work around Bug#32452#91.' >&2
+ esac
+
+ "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
$avoided_flags $GNULIB_MODULES &&
-rm -- "$src"lib/gl_openssl.h \
- "$src"lib/stdio-read.c "$src"lib/stdio-write.c \
- "$src"m4/fcntl-o.m4 \
- "$src"m4/gl-openssl.m4 \
- "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
- "$src"m4/manywarnings-c++.m4 \
- "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
-cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
-cp -- "$gnulib_srcdir"/build-aux/config.guess \
- "$gnulib_srcdir"/build-aux/config.sub \
- "$gnulib_srcdir"/build-aux/install-sh \
- "$gnulib_srcdir"/build-aux/move-if-change \
- "$src"build-aux &&
-cp -- "$gnulib_srcdir"/lib/af_alg.h \
- "$gnulib_srcdir"/lib/save-cwd.h \
- "$src"lib &&
-{ test -z "$src" || cd "$src"; } &&
-./autogen.sh
+ rm -- "$src"lib/gl_openssl.h \
+ "$src"lib/stdio-read.c "$src"lib/stdio-write.c \
+ "$src"m4/fcntl-o.m4 \
+ "$src"m4/gl-openssl.m4 \
+ "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
+ "$src"m4/manywarnings-c++.m4 \
+ "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
+ cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
+ cp -- "$gnulib_srcdir"/build-aux/config.guess \
+ "$gnulib_srcdir"/build-aux/config.sub \
+ "$gnulib_srcdir"/build-aux/install-sh \
+ "$gnulib_srcdir"/build-aux/move-if-change \
+ "$src"build-aux &&
+ cp -- "$gnulib_srcdir"/lib/af_alg.h \
+ "$gnulib_srcdir"/lib/save-cwd.h \
+ "$src"lib &&
+ { test -z "$src" || cd "$src"; } &&
+ ./autogen.sh || exit
+done
--
2.32.0
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <78c5037a-ac96-e7be-532f-b1776ed25b2b@cs.ucla.edu>
@ 2022-03-01 15:36 ` Lars Ingebrigtsen
[not found] ` <87a6e9n0rg.fsf@gnus.org>
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-01 15:36 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Paul Eggert <eggert@cs.ucla.edu> writes:
> Evidently my recent workarounds in Emacs to handle running gnulib-tool
> from a bare checkout were not sufficient. I installed the attached
> patch to up the ante; please give it a try.
>
> It is unfortunate that emacs/admin/merge-gnulib now runs gnulib-tool
> twice from a bare checkout, as gnulib-tool is quite slow.
My latest attempt wasn't from a bare checkout -- it was from my normal
development tree, though.
In any case, doing this:
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 7219fadd47..074101f095 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -40,7 +40,7 @@ GNULIB_MODULES=
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile libgmp lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
- nproc nstrftime
+ nanosleep nproc nstrftime
pathmax pipe2 pselect pthread_sigmask
qcopy-acl readlink readlinkat regex
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
Then running admin/merge-gnulib, and then adding this:
diff --git a/src/gnutls.c b/src/gnutls.c
index 3ec3837067..5389b15b1e 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -616,6 +616,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
gnutls_session_t state = proc->gnutls_state;
int ret;
bool non_blocking = proc->is_non_blocking_client;
+ struct timespec delay = { 0, 1000 * 1000 * 10 };
if (proc->gnutls_complete_negotiation_p)
non_blocking = false;
@@ -630,6 +631,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
maybe_quit ();
if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
break;
+ nanosleep (&delay, NULL);
}
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
Still leads to:
/usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
/home/larsi/src/emacs/gtest/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
collect2: error: ld returned 1 exit status
Are there any further incantations needed to use stuff from gnulib? I
tried to compare with other usages of gnulib stuff, and nothing really
stood out immediately.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87a6e9n0rg.fsf@gnus.org>
@ 2022-03-01 18:27 ` Paul Eggert
[not found] ` <d0cfd485-2be6-5873-64dc-2926c2f2bae0@cs.ucla.edu>
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-03-01 18:27 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, bug-gnulib, npostavs
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
On 3/1/22 07:36, Lars Ingebrigtsen wrote:
> My latest attempt wasn't from a bare checkout -- it was from my normal
> development tree, though.
Well, that's annoying. :-)
I looked into the problem some more and found what I think is the
underlying problem: gnulib-tool generated lib/gnulib.mk.in before it
generates m4/gnulib-comp.m4, which Makefile-generation relies upon. I
reverted my recent hack to emacs/admin/merge-gnulib and installed the
attached Gnulib patch. Please update to the latest Emacs and Gnulib and
try again.
[-- Attachment #2: 0001-Create-lib-Makefile.am-after-gnulib-comp.m4.patch --]
[-- Type: text/x-patch, Size: 4345 bytes --]
From 8c4f4d7a3c28f88b64fce2fb1d0dc0e570d1a482 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 1 Mar 2022 10:01:22 -0800
Subject: [PATCH] Create lib/Makefile.am after gnulib-comp.m4
* gnulib-tool (func_import): Create library makefile after
creating gnulib-comp.m4. With --gnu-make, the latter depends on
the former. See <https://bugs.gnu.org/32452#109>.
---
ChangeLog | 7 ++++++
gnulib-tool | 68 +++++++++++++++++++++++++++--------------------------
2 files changed, 42 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 629ec803fd..c5a80fd3f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-03-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ Create lib/Makefile.am after gnulib-comp.m4
+ * gnulib-tool (func_import): Create library makefile after
+ creating gnulib-comp.m4. With --gnu-make, the latter depends on
+ the former. See <https://bugs.gnu.org/32452#109>.
+
2022-02-26 Paul Eggert <eggert@cs.ucla.edu>
gettime-res: fix unlikely overflow bug
diff --git a/gnulib-tool b/gnulib-tool
index 9ee7560209..e420b321d2 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -5692,39 +5692,6 @@ s,//*$,/,'
func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
}
- # Create library makefile.
- func_dest_tmpfilename $sourcebase/$source_makefile_am
- destfile="$sourcebase/$source_makefile_am"
- modules="$main_modules"
- if $automake_subdir; then
- func_emit_lib_Makefile_am | "$gnulib_dir"/build-aux/prefix-gnulib-mk --from-gnulib-tool --lib-name="$libname" --prefix="$sourcebase/" > "$tmpfile"
- else
- func_emit_lib_Makefile_am > "$tmpfile"
- fi
- if test -f "$destdir"/$sourcebase/$source_makefile_am; then
- if cmp -s "$destdir"/$sourcebase/$source_makefile_am "$tmpfile"; then
- rm -f "$tmpfile"
- else
- if $doit; then
- echo "Updating $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
- mv -f "$destdir"/$sourcebase/$source_makefile_am "$destdir"/$sourcebase/$source_makefile_am~
- mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
- else
- echo "Update $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
- rm -f "$tmpfile"
- fi
- fi
- else
- if $doit; then
- echo "Creating $sourcebase/$source_makefile_am"
- mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
- else
- echo "Create $sourcebase/$source_makefile_am"
- rm -f "$tmpfile"
- fi
- func_append added_files "$sourcebase/$source_makefile_am$nl"
- fi
-
# Create po/ directory.
if test -n "$pobase"; then
# Create po makefile and auxiliary files.
@@ -6131,6 +6098,41 @@ s,//*$,/,'
fi
fi
+ # Create library makefile.
+ # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am
+ # can run 'autoconf -t', which reads gnulib-comp.m4.
+ func_dest_tmpfilename $sourcebase/$source_makefile_am
+ destfile="$sourcebase/$source_makefile_am"
+ modules="$main_modules"
+ if $automake_subdir; then
+ func_emit_lib_Makefile_am | "$gnulib_dir"/build-aux/prefix-gnulib-mk --from-gnulib-tool --lib-name="$libname" --prefix="$sourcebase/" > "$tmpfile"
+ else
+ func_emit_lib_Makefile_am > "$tmpfile"
+ fi
+ if test -f "$destdir"/$sourcebase/$source_makefile_am; then
+ if cmp -s "$destdir"/$sourcebase/$source_makefile_am "$tmpfile"; then
+ rm -f "$tmpfile"
+ else
+ if $doit; then
+ echo "Updating $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
+ mv -f "$destdir"/$sourcebase/$source_makefile_am "$destdir"/$sourcebase/$source_makefile_am~
+ mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
+ else
+ echo "Update $sourcebase/$source_makefile_am (backup in $sourcebase/$source_makefile_am~)"
+ rm -f "$tmpfile"
+ fi
+ fi
+ else
+ if $doit; then
+ echo "Creating $sourcebase/$source_makefile_am"
+ mv -f "$tmpfile" "$destdir"/$sourcebase/$source_makefile_am
+ else
+ echo "Create $sourcebase/$source_makefile_am"
+ rm -f "$tmpfile"
+ fi
+ func_append added_files "$sourcebase/$source_makefile_am$nl"
+ fi
+
if $gentests; then
# Create tests makefile.
func_dest_tmpfilename $testsbase/$tests_makefile_am
--
2.32.0
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <d0cfd485-2be6-5873-64dc-2926c2f2bae0@cs.ucla.edu>
@ 2022-03-01 18:52 ` Lars Ingebrigtsen
[not found] ` <87czj5ld38.fsf@gnus.org>
1 sibling, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-01 18:52 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Paul Eggert <eggert@cs.ucla.edu> writes:
> I looked into the problem some more and found what I think is the
> underlying problem: gnulib-tool generated lib/gnulib.mk.in before it
> generates m4/gnulib-comp.m4, which Makefile-generation relies upon. I
> reverted my recent hack to emacs/admin/merge-gnulib and installed the
> attached Gnulib patch. Please update to the latest Emacs and Gnulib
> and try again.
I tried this now, but the symptoms seem to be the same -- after trying
to use nanosleep, as described before, I still get:
/usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
/home/larsi/src/emacs/gtest/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
collect2: error: ld returned 1 exit status
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87czj5ld38.fsf@gnus.org>
@ 2022-03-02 1:00 ` Paul Eggert
[not found] ` <d24b1278-1aeb-e17d-ed06-7d36c5e3b68b@cs.ucla.edu>
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-03-02 1:00 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, bug-gnulib, npostavs
On 3/1/22 10:52, Lars Ingebrigtsen wrote:
> Paul Eggert<eggert@cs.ucla.edu> writes:
>
>> I looked into the problem some more and found what I think is the
>> underlying problem: gnulib-tool generated lib/gnulib.mk.in before it
>> generates m4/gnulib-comp.m4, which Makefile-generation relies upon. I
>> reverted my recent hack to emacs/admin/merge-gnulib and installed the
>> attached Gnulib patch. Please update to the latest Emacs and Gnulib
>> and try again.
> I tried this now, but the symptoms seem to be the same -- after trying
> to use nanosleep, as described before, I still get:
>
> /usr/bin/ld: gnutls.o: in function `gnutls_try_handshake':
> /home/larsi/src/emacs/gtest/src/gnutls.c:634: undefined reference to `rpl_nanosleep'
> collect2: error: ld returned 1 exit status
Do you see this problem with a fresh checkout from the latest master
branch, combined with the latest Gnulib? If not, problem solved. If so,
what's the output of 'git status' and of 'git diff' when things fail?
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <d24b1278-1aeb-e17d-ed06-7d36c5e3b68b@cs.ucla.edu>
@ 2022-03-02 1:22 ` Lars Ingebrigtsen
2022-03-02 1:43 ` Lars Ingebrigtsen
[not found] ` <87y21tjggy.fsf@gnus.org>
1 sibling, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-02 1:22 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Paul Eggert <eggert@cs.ucla.edu> writes:
> Do you see this problem with a fresh checkout from the latest master
> branch, combined with the latest Gnulib?
Yes, when I add the nanosleep module as previously described.
> If not, problem solved. If so, what's the output of 'git status' and
> of 'git diff' when things fail?
larsi@giant:~/src/emacs/gtest$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: lib/nanosleep.c
new file: m4/nanosleep.m4
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: admin/merge-gnulib
modified: lib/gnulib.mk.in
modified: m4/gnulib-comp.m4
modified: src/gnutls.c
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..ea3d23686f 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -40,7 +40,7 @@ GNULIB_MODULES=
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile libgmp lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
- nproc nstrftime
+ nanosleep nproc nstrftime
pathmax pipe2 pselect pthread_sigmask
qcopy-acl readlink readlinkat regex
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 3a9f5b9818..b79eebc804 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -129,6 +129,7 @@
# minmax \
# mkostemp \
# mktime \
+# nanosleep \
# nproc \
# nstrftime \
# pathmax \
@@ -2497,6 +2498,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
endif
## end gnulib module mktime-internal
+## begin gnulib module nanosleep
+ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
+
+ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
+libgnu_a_SOURCES += nanosleep.c
+endif
+
+endif
+## end gnulib module nanosleep
+
## begin gnulib module nproc
ifeq (,$(OMIT_GNULIB_MODULE_nproc))
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 1d31239d2d..fb5f1b52a4 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -140,6 +140,7 @@ AC_DEFUN
# Code from module mktime:
# Code from module mktime-internal:
# Code from module multiarch:
+ # Code from module nanosleep:
# Code from module nocrash:
# Code from module nproc:
# Code from module nstrftime:
@@ -430,6 +431,10 @@ AC_DEFUN
fi
gl_TIME_MODULE_INDICATOR([mktime])
gl_MULTIARCH
+ gl_FUNC_NANOSLEEP
+ gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP],
+ [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1])
+ gl_TIME_MODULE_INDICATOR([nanosleep])
gl_NPROC
gl_FUNC_GNU_STRFTIME
gl_PATHMAX
@@ -1304,6 +1309,7 @@ AC_DEFUN
lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
+ lib/nanosleep.c
lib/nproc.c
lib/nproc.h
lib/nstrftime.c
@@ -1456,6 +1462,7 @@ AC_DEFUN
m4/mktime.m4
m4/mode_t.m4
m4/multiarch.m4
+ m4/nanosleep.m4
m4/nocrash.m4
m4/nproc.m4
m4/nstrftime.m4
diff --git a/src/gnutls.c b/src/gnutls.c
index 3ec3837067..5389b15b1e 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -616,6 +616,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
gnutls_session_t state = proc->gnutls_state;
int ret;
bool non_blocking = proc->is_non_blocking_client;
+ struct timespec delay = { 0, 1000 * 1000 * 10 };
if (proc->gnutls_complete_negotiation_p)
non_blocking = false;
@@ -630,6 +631,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
maybe_quit ();
if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
break;
+ nanosleep (&delay, NULL);
}
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-02 1:22 ` Lars Ingebrigtsen
@ 2022-03-02 1:43 ` Lars Ingebrigtsen
0 siblings, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-02 1:43 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Lars Ingebrigtsen <larsi@gnus.org> writes:
> diff --git a/admin/merge-gnulib b/admin/merge-gnulib
> index fec469c017..ea3d23686f 100755
That wasn't the complete diff. Here it is:
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..ea3d23686f 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -40,7 +40,7 @@ GNULIB_MODULES=
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile libgmp lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
- nproc nstrftime
+ nanosleep nproc nstrftime
pathmax pipe2 pselect pthread_sigmask
qcopy-acl readlink readlinkat regex
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 3a9f5b9818..b79eebc804 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -129,6 +129,7 @@
# minmax \
# mkostemp \
# mktime \
+# nanosleep \
# nproc \
# nstrftime \
# pathmax \
@@ -2497,6 +2498,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
endif
## end gnulib module mktime-internal
+## begin gnulib module nanosleep
+ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
+
+ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
+libgnu_a_SOURCES += nanosleep.c
+endif
+
+endif
+## end gnulib module nanosleep
+
## begin gnulib module nproc
ifeq (,$(OMIT_GNULIB_MODULE_nproc))
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
new file mode 100644
index 0000000000..446794edc0
--- /dev/null
+++ b/lib/nanosleep.c
@@ -0,0 +1,195 @@
+/* Provide a replacement for the POSIX nanosleep function.
+
+ Copyright (C) 1999-2000, 2002, 2004-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering
+ and Bruno Haible for the native Windows part */
+
+#include <config.h>
+
+#include <time.h>
+
+#include "intprops.h"
+#include "verify.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <signal.h>
+
+#include <errno.h>
+
+#include <unistd.h>
+
+
+enum { BILLION = 1000 * 1000 * 1000 };
+
+#if HAVE_BUG_BIG_NANOSLEEP
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+# undef nanosleep
+{
+ /* nanosleep mishandles large sleeps due to internal overflow problems.
+ The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
+ can't sleep more than 24.85 days (2^31 milliseconds). Similarly,
+ cygwin 1.5.x, which can't sleep more than 49.7 days (2^32 milliseconds).
+ Solve this by breaking the sleep up into smaller chunks. */
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ {
+ /* Verify that time_t is large enough. */
+ verify (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
+ const time_t limit = 24 * 24 * 60 * 60;
+ time_t seconds = requested_delay->tv_sec;
+ struct timespec intermediate;
+ intermediate.tv_nsec = requested_delay->tv_nsec;
+
+ while (limit < seconds)
+ {
+ int result;
+ intermediate.tv_sec = limit;
+ result = nanosleep (&intermediate, remaining_delay);
+ seconds -= limit;
+ if (result)
+ {
+ if (remaining_delay)
+ remaining_delay->tv_sec += seconds;
+ return result;
+ }
+ intermediate.tv_nsec = 0;
+ }
+ intermediate.tv_sec = seconds;
+ return nanosleep (&intermediate, remaining_delay);
+ }
+}
+
+#elif defined _WIN32 && ! defined __CYGWIN__
+/* Native Windows platforms. */
+
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* The Windows API function Sleep() has a resolution of about 15 ms and takes
+ at least 5 ms to execute. We use this function for longer time periods.
+ Additionally, we use busy-looping over short time periods, to get a
+ resolution of about 0.01 ms. In order to measure such short timespans,
+ we use the QueryPerformanceCounter() function. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ static bool initialized;
+ /* Number of performance counter increments per nanosecond,
+ or zero if it could not be determined. */
+ static double ticks_per_nanosecond;
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* For requested delays of one second or more, 15ms resolution is
+ sufficient. */
+ if (requested_delay->tv_sec == 0)
+ {
+ if (!initialized)
+ {
+ /* Initialize ticks_per_nanosecond. */
+ LARGE_INTEGER ticks_per_second;
+
+ if (QueryPerformanceFrequency (&ticks_per_second))
+ ticks_per_nanosecond =
+ (double) ticks_per_second.QuadPart / 1000000000.0;
+
+ initialized = true;
+ }
+ if (ticks_per_nanosecond)
+ {
+ /* QueryPerformanceFrequency worked. We can use
+ QueryPerformanceCounter. Use a combination of Sleep and
+ busy-looping. */
+ /* Number of milliseconds to pass to the Sleep function.
+ Since Sleep can take up to 8 ms less or 8 ms more than requested
+ (or maybe more if the system is loaded), we subtract 10 ms. */
+ int sleep_millis = (int) requested_delay->tv_nsec / 1000000 - 10;
+ /* Determine how many ticks to delay. */
+ LONGLONG wait_ticks = requested_delay->tv_nsec * ticks_per_nanosecond;
+ /* Start. */
+ LARGE_INTEGER counter_before;
+ if (QueryPerformanceCounter (&counter_before))
+ {
+ /* Wait until the performance counter has reached this value.
+ We don't need to worry about overflow, because the performance
+ counter is reset at reboot, and with a frequency of 3.6E6
+ ticks per second 63 bits suffice for over 80000 years. */
+ LONGLONG wait_until = counter_before.QuadPart + wait_ticks;
+ /* Use Sleep for the longest part. */
+ if (sleep_millis > 0)
+ Sleep (sleep_millis);
+ /* Busy-loop for the rest. */
+ for (;;)
+ {
+ LARGE_INTEGER counter_after;
+ if (!QueryPerformanceCounter (&counter_after))
+ /* QueryPerformanceCounter failed, but succeeded earlier.
+ Should not happen. */
+ break;
+ if (counter_after.QuadPart >= wait_until)
+ /* The requested time has elapsed. */
+ break;
+ }
+ goto done;
+ }
+ }
+ }
+ /* Implementation for long delays and as fallback. */
+ Sleep (requested_delay->tv_sec * 1000 + requested_delay->tv_nsec / 1000000);
+
+ done:
+ /* Sleep is not interruptible. So there is no remaining delay. */
+ if (remaining_delay != NULL)
+ {
+ remaining_delay->tv_sec = 0;
+ remaining_delay->tv_nsec = 0;
+ }
+ return 0;
+}
+
+#else
+/* Other platforms lacking nanosleep.
+ It's not clear whether these are still practical porting targets.
+ For now, just fall back on pselect. */
+
+/* Suspend execution for at least *REQUESTED_DELAY seconds. The
+ *REMAINING_DELAY part isn't implemented yet. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ return pselect (0, NULL, NULL, NULL, requested_delay, NULL);
+}
+#endif
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 1d31239d2d..fb5f1b52a4 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -140,6 +140,7 @@ AC_DEFUN
# Code from module mktime:
# Code from module mktime-internal:
# Code from module multiarch:
+ # Code from module nanosleep:
# Code from module nocrash:
# Code from module nproc:
# Code from module nstrftime:
@@ -430,6 +431,10 @@ AC_DEFUN
fi
gl_TIME_MODULE_INDICATOR([mktime])
gl_MULTIARCH
+ gl_FUNC_NANOSLEEP
+ gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP],
+ [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1])
+ gl_TIME_MODULE_INDICATOR([nanosleep])
gl_NPROC
gl_FUNC_GNU_STRFTIME
gl_PATHMAX
@@ -1304,6 +1309,7 @@ AC_DEFUN
lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
+ lib/nanosleep.c
lib/nproc.c
lib/nproc.h
lib/nstrftime.c
@@ -1456,6 +1462,7 @@ AC_DEFUN
m4/mktime.m4
m4/mode_t.m4
m4/multiarch.m4
+ m4/nanosleep.m4
m4/nocrash.m4
m4/nproc.m4
m4/nstrftime.m4
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
new file mode 100644
index 0000000000..1964b1ea47
--- /dev/null
+++ b/m4/nanosleep.m4
@@ -0,0 +1,139 @@
+# serial 41
+
+dnl From Jim Meyering.
+dnl Check for the nanosleep function.
+dnl If not found, use the supplied replacement.
+dnl
+
+# Copyright (C) 1999-2001, 2003-2022 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NANOSLEEP],
+[
+ AC_REQUIRE([gl_TIME_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([alarm])
+
+ nanosleep_save_libs=$LIBS
+
+ # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
+ # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+ LIB_NANOSLEEP=
+ AC_SUBST([LIB_NANOSLEEP])
+ AC_SEARCH_LIBS([nanosleep], [rt posix4],
+ [test "$ac_cv_search_nanosleep" = "none required" ||
+ LIB_NANOSLEEP=$ac_cv_search_nanosleep])
+ if test "x$ac_cv_search_nanosleep" != xno; then
+ dnl The system has a nanosleep function.
+
+ AC_REQUIRE([gl_MULTIARCH])
+ if test $APPLE_UNIVERSAL_BUILD = 1; then
+ # A universal build on Apple Mac OS X platforms.
+ # The test result would be 'no (mishandles large arguments)' in 64-bit
+ # mode but 'yes' in 32-bit mode. But we need a configuration result that
+ # is valid in both modes.
+ gl_cv_func_nanosleep='no (mishandles large arguments)'
+ fi
+
+ AC_CACHE_CHECK([for working nanosleep],
+ [gl_cv_func_nanosleep],
+ [
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <errno.h>
+ #include <limits.h>
+ #include <signal.h>
+ #include <time.h>
+ #include <unistd.h>
+ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+ #define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+
+ #if HAVE_DECL_ALARM
+ static void
+ check_for_SIGALRM (int sig)
+ {
+ if (sig != SIGALRM)
+ _exit (1);
+ }
+ #endif
+
+ int
+ main ()
+ {
+ static struct timespec ts_sleep;
+ static struct timespec ts_remaining;
+ /* Test for major problems first. */
+ if (! nanosleep)
+ return 2;
+ ts_sleep.tv_sec = 0;
+ ts_sleep.tv_nsec = 1;
+ #if HAVE_DECL_ALARM
+ {
+ static struct sigaction act;
+ act.sa_handler = check_for_SIGALRM;
+ sigemptyset (&act.sa_mask);
+ sigaction (SIGALRM, &act, NULL);
+ alarm (1);
+ if (nanosleep (&ts_sleep, NULL) != 0)
+ return 3;
+ /* Test for a minor problem: the handling of large arguments. */
+ ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
+ ts_sleep.tv_nsec = 999999999;
+ alarm (1);
+ if (nanosleep (&ts_sleep, &ts_remaining) != -1)
+ return 4;
+ if (errno != EINTR)
+ return 5;
+ if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10)
+ return 6;
+ }
+ #else /* A simpler test for native Windows. */
+ if (nanosleep (&ts_sleep, &ts_remaining) < 0)
+ return 3;
+ #endif
+ return 0;
+ }]])],
+ [gl_cv_func_nanosleep=yes],
+ [case $? in dnl (
+ 4|5|6) gl_cv_func_nanosleep='no (mishandles large arguments)';; dnl (
+ *) gl_cv_func_nanosleep=no;;
+ esac],
+ [case "$host_os" in dnl ((
+ linux*) # Guess it halfway works when the kernel is Linux.
+ gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;;
+ mingw*) # Guess no on native Windows.
+ gl_cv_func_nanosleep='guessing no' ;;
+ *) # If we don't know, obey --enable-cross-guesses.
+ gl_cv_func_nanosleep="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_nanosleep" in
+ *yes)
+ REPLACE_NANOSLEEP=0
+ ;;
+ *)
+ REPLACE_NANOSLEEP=1
+ case "$gl_cv_func_nanosleep" in
+ *"mishandles large arguments"*)
+ AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
+ [Define to 1 if nanosleep mishandles large arguments.])
+ ;;
+ esac
+ ;;
+ esac
+ else
+ HAVE_NANOSLEEP=0
+ fi
+ LIBS=$nanosleep_save_libs
+])
diff --git a/src/gnutls.c b/src/gnutls.c
index 3ec3837067..5389b15b1e 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -616,6 +616,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
gnutls_session_t state = proc->gnutls_state;
int ret;
bool non_blocking = proc->is_non_blocking_client;
+ struct timespec delay = { 0, 1000 * 1000 * 10 };
if (proc->gnutls_complete_negotiation_p)
non_blocking = false;
@@ -630,6 +631,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
maybe_quit ();
if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
break;
+ nanosleep (&delay, NULL);
}
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87y21tjggy.fsf@gnus.org>
@ 2022-03-02 2:12 ` Paul Eggert
[not found] ` <ab47871e-ad1e-e06d-c226-ab7b7c9bb857@cs.ucla.edu>
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-03-02 2:12 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, bug-gnulib, npostavs
[-- Attachment #1: Type: text/plain, Size: 18371 bytes --]
On 3/1/22 17:22, Lars Ingebrigtsen wrote:
> --- a/lib/gnulib.mk.in
> +++ b/lib/gnulib.mk.in
> @@ -129,6 +129,7 @@
> # minmax \
> # mkostemp \
> # mktime \
> +# nanosleep \
> # nproc \
> # nstrftime \
> # pathmax \
> @@ -2497,6 +2498,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
> endif
> ## end gnulib module mktime-internal
>
> +## begin gnulib module nanosleep
> +ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
> +
> +ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
> +libgnu_a_SOURCES += nanosleep.c
> +endif
> +
> +endif
> +## end gnulib module nanosleep
> +
> ## begin gnulib module nproc
> ifeq (,$(OMIT_GNULIB_MODULE_nproc))
>
This diff is wrong, as it omits a line "GL_COND_OBJ_NANOSLEEP_CONDITION
= @GL_COND_OBJ_NANOSLEEP_CONDITION@".
I ran what should have been something like your commands and got the
attached patch. One way forward is for you to simply install the
attached patch and move on from there. Or we can continue to look into
why things work for me and not for you. I suppose it could be an
Autoconf bug on your platform, but it'd be an odd one.
Here's a shell transcript of what I did to get the attached patch, on
Fedora 35 x86-64:
$ git clone master master-tmp
Cloning into 'master-tmp'...
done.
Updating files: 100% (4608/4608), done.
$ cd master-tmp
$ git log HEAD^!
commit 689a34e2153ec558dbf406809a5e58489250fe1a (HEAD -> master,
origin/master, origin/HEAD)
Author: Po Lu <luangruo@yahoo.com>
Date: Wed Mar 2 09:46:44 2022 +0800
Dismiss help text when item becomes unactivated on oldXMenu
* oldXMenu/Activate.c (XMenuActivate): Dismiss help text when
leaving an item.
$ (cd ../gnulib && git log HEAD^! )
commit 8c4f4d7a3c28f88b64fce2fb1d0dc0e570d1a482 (HEAD -> master,
origin/master, origin/HEAD)
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue Mar 1 10:01:22 2022 -0800
Create lib/Makefile.am after gnulib-comp.m4
* gnulib-tool (func_import): Create library makefile after
creating gnulib-comp.m4. With --gnu-make, the latter depends on
the former. See <https://bugs.gnu.org/32452#109>.
$ sed -i 's/nproc nstrftime/nanosleep &/' admin/merge-gnulib
$ admin/merge-gnulib
Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)
Checking for autoconf (need at least version 2.65) ... ok
Your system has the required tools.
Building aclocal.m4 ...
Running 'autoreconf -fi -I m4' ...
Configuring local git repository...
'.git/config' -> '.git/config.~1~'
git config transfer.fsckObjects 'true'
git config diff.cpp.xfuncname '!^[
\t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])
^((::[[:space:]]*)?[A-Za-z_][A-Za-z_0-9]*[[:space:]]*\(.*)$
^((#define[[:space:]]|DEFUN).*)$'
git config diff.elisp.xfuncname
'^\([^[:space:]]*def[^[:space:]]+[[:space:]]+([^()[:space:]]+)'
git config diff.m4.xfuncname '^((m4_)?define|A._DEFUN(_ONCE)?)\([^),]*'
git config diff.make.xfuncname
'^([$.[:alnum:]_].*:|[[:alnum:]_]+[[:space:]]*([*:+]?[:?]?|!?)=|define .*)'
git config diff.shell.xfuncname
'^([[:space:]]*[[:alpha:]_][[:alnum:]_]*[[:space:]]*\(\)|[[:alpha:]_][[:alnum:]_]*=)'
git config diff.texinfo.xfuncname
'^@node[[:space:]]+([^,[:space:]][^,]+)'
Installing git hooks...
'build-aux/git-hooks/commit-msg' -> '.git/hooks/commit-msg'
'build-aux/git-hooks/pre-commit' -> '.git/hooks/pre-commit'
'build-aux/git-hooks/prepare-commit-msg' ->
'.git/hooks/prepare-commit-msg'
'.git/hooks/applypatch-msg.sample' -> '.git/hooks/applypatch-msg'
'.git/hooks/pre-applypatch.sample' -> '.git/hooks/pre-applypatch'
You can now run './configure'.
Module list with included dependencies (indented):
absolute-header
acl-permissions
alloca-opt
allocator
at-internal
attribute
binary-io
builtin-expect
byteswap
c-ctype
c-strcase
c99
canonicalize-lgpl
careadlinkat
clock-time
cloexec
close-stream
copy-file-range
count-leading-zeros
count-one-bits
count-trailing-zeros
crypto/md5
crypto/md5-buffer
crypto/sha1-buffer
crypto/sha256-buffer
crypto/sha512-buffer
d-type
diffseq
dirent
dirfd
double-slash-root
dtoastr
dtotimespec
dup2
dynarray
eloop-threshold
environ
errno
euidaccess
execinfo
explicit_bzero
extensions
extern-inline
faccessat
fchmodat
fcntl
fcntl-h
fdopendir
file-has-acl
filemode
filename
filevercmp
flexmember
fpending
fpieee
free-posix
fstatat
fsusage
fsync
futimens
gen-header
getdtablesize
getgroups
getloadavg
getopt-gnu
getopt-posix
getrandom
gettext-h
gettime
gettimeofday
gitlog-to-changelog
group-member
idx
ieee754-h
ignore-value
include_next
intprops
inttypes-incomplete
largefile
lchmod
libc-config
libgmp
limits-h
lstat
malloc-gnu
malloc-posix
manywarnings
memmem-simple
mempcpy
memrchr
minmax
mkostemp
mktime
mktime-internal
multiarch
nanosleep
nocrash
nproc
nstrftime
open
openat-h
pathmax
pipe2
pselect
pthread_sigmask
qcopy-acl
rawmemchr
readlink
readlinkat
realloc-gnu
realloc-posix
regex
root-uid
scratch_buffer
sig2str
sigdescr_np
signal-h
snippet/_Noreturn
snippet/arg-nonnull
snippet/c++defs
snippet/warn-on-use
socklen
ssize_t
stat-time
std-gnu11
stdalign
stddef
stdint
stdio
stdlib
stpcpy
string
strnlen
strtoimax
strtoll
symlink
sys_random
sys_select
sys_stat
sys_time
sys_types
tempname
time
time_r
time_rz
timegm
timer-time
timespec
timespec-add
timespec-sub
u64
unistd
unlocked-io
unlocked-io-internal
update-copyright
utimens
utimensat
vararrays
verify
vla
warnings
xalloc-oversized
File list:
build-aux/gitlog-to-changelog
build-aux/update-copyright
lib/_Noreturn.h
lib/acl-errno-valid.c
lib/acl-internal.c
lib/acl-internal.h
lib/acl.h
lib/acl_entries.c
lib/alloca.in.h
lib/allocator.c
lib/allocator.h
lib/arg-nonnull.h
lib/at-func.c
lib/attribute.h
lib/binary-io.c
lib/binary-io.h
lib/byteswap.in.h
lib/c++defs.h
lib/c-ctype.c
lib/c-ctype.h
lib/c-strcase.h
lib/c-strcasecmp.c
lib/c-strncasecmp.c
lib/canonicalize-lgpl.c
lib/careadlinkat.c
lib/careadlinkat.h
lib/cdefs.h
lib/cloexec.c
lib/cloexec.h
lib/close-stream.c
lib/close-stream.h
lib/copy-file-range.c
lib/count-leading-zeros.c
lib/count-leading-zeros.h
lib/count-one-bits.c
lib/count-one-bits.h
lib/count-trailing-zeros.c
lib/count-trailing-zeros.h
lib/diffseq.h
lib/dirent.in.h
lib/dirfd.c
lib/dtoastr.c
lib/dtotimespec.c
lib/dup2.c
lib/dynarray.h
lib/eloop-threshold.h
lib/errno.in.h
lib/euidaccess.c
lib/execinfo.c
lib/execinfo.in.h
lib/explicit_bzero.c
lib/faccessat.c
lib/fchmodat.c
lib/fcntl.c
lib/fcntl.in.h
lib/fdopendir.c
lib/file-has-acl.c
lib/filemode.c
lib/filemode.h
lib/filename.h
lib/filevercmp.c
lib/filevercmp.h
lib/flexmember.h
lib/fpending.c
lib/fpending.h
lib/free.c
lib/fstatat.c
lib/fsusage.c
lib/fsusage.h
lib/fsync.c
lib/ftoastr.c
lib/ftoastr.h
lib/futimens.c
lib/get-permissions.c
lib/getdtablesize.c
lib/getgroups.c
lib/getloadavg.c
lib/getopt-cdefs.in.h
lib/getopt-core.h
lib/getopt-ext.h
lib/getopt-pfx-core.h
lib/getopt-pfx-ext.h
lib/getopt.c
lib/getopt.in.h
lib/getopt1.c
lib/getopt_int.h
lib/getrandom.c
lib/gettext.h
lib/gettime.c
lib/gettimeofday.c
lib/gl_openssl.h
lib/group-member.c
lib/idx.h
lib/ieee754.in.h
lib/ignore-value.h
lib/intprops.h
lib/inttypes.in.h
lib/lchmod.c
lib/libc-config.h
lib/limits.in.h
lib/lstat.c
lib/malloc.c
lib/malloc/dynarray-skeleton.c
lib/malloc/dynarray.h
lib/malloc/dynarray_at_failure.c
lib/malloc/dynarray_emplace_enlarge.c
lib/malloc/dynarray_finalize.c
lib/malloc/dynarray_resize.c
lib/malloc/dynarray_resize_clear.c
lib/malloc/scratch_buffer.h
lib/malloc/scratch_buffer_dupfree.c
lib/malloc/scratch_buffer_grow.c
lib/malloc/scratch_buffer_grow_preserve.c
lib/malloc/scratch_buffer_set_array_size.c
lib/md5-stream.c
lib/md5.c
lib/md5.h
lib/memmem.c
lib/mempcpy.c
lib/memrchr.c
lib/mini-gmp-gnulib.c
lib/mini-gmp.c
lib/mini-gmp.h
lib/minmax.h
lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
lib/nanosleep.c
lib/nproc.c
lib/nproc.h
lib/nstrftime.c
lib/open.c
lib/openat-priv.h
lib/openat-proc.c
lib/openat.h
lib/pathmax.h
lib/pipe2.c
lib/pselect.c
lib/pthread_sigmask.c
lib/qcopy-acl.c
lib/rawmemchr.c
lib/rawmemchr.valgrind
lib/readlink.c
lib/readlinkat.c
lib/realloc.c
lib/regcomp.c
lib/regex.c
lib/regex.h
lib/regex_internal.c
lib/regex_internal.h
lib/regexec.c
lib/root-uid.h
lib/scratch_buffer.h
lib/set-permissions.c
lib/sha1.c
lib/sha1.h
lib/sha256.c
lib/sha256.h
lib/sha512.c
lib/sha512.h
lib/sig2str.c
lib/sig2str.h
lib/sigdescr_np.c
lib/signal.in.h
lib/stat-time.c
lib/stat-time.h
lib/stdalign.in.h
lib/stddef.in.h
lib/stdint.in.h
lib/stdio-impl.h
lib/stdio-read.c
lib/stdio-write.c
lib/stdio.in.h
lib/stdlib.in.h
lib/stpcpy.c
lib/str-two-way.h
lib/strftime.h
lib/string.in.h
lib/strnlen.c
lib/strtoimax.c
lib/strtol.c
lib/strtoll.c
lib/symlink.c
lib/sys_random.in.h
lib/sys_select.in.h
lib/sys_stat.in.h
lib/sys_time.in.h
lib/sys_types.in.h
lib/tempname.c
lib/tempname.h
lib/time-internal.h
lib/time.in.h
lib/time_r.c
lib/time_rz.c
lib/timegm.c
lib/timespec-add.c
lib/timespec-sub.c
lib/timespec.c
lib/timespec.h
lib/u64.c
lib/u64.h
lib/unistd.c
lib/unistd.in.h
lib/unlocked-io.h
lib/utimens.c
lib/utimens.h
lib/utimensat.c
lib/verify.h
lib/vla.h
lib/warn-on-use.h
lib/xalloc-oversized.h
m4/00gnulib.m4
m4/__inline.m4
m4/absolute-header.m4
m4/acl.m4
m4/alloca.m4
m4/builtin-expect.m4
m4/byteswap.m4
m4/canonicalize.m4
m4/clock_time.m4
m4/copy-file-range.m4
m4/d-type.m4
m4/dirent_h.m4
m4/dirfd.m4
m4/double-slash-root.m4
m4/dup2.m4
m4/eealloc.m4
m4/environ.m4
m4/errno_h.m4
m4/euidaccess.m4
m4/execinfo.m4
m4/explicit_bzero.m4
m4/extensions.m4
m4/extern-inline.m4
m4/faccessat.m4
m4/fchmodat.m4
m4/fcntl-o.m4
m4/fcntl.m4
m4/fcntl_h.m4
m4/fdopendir.m4
m4/filemode.m4
m4/flexmember.m4
m4/fpending.m4
m4/fpieee.m4
m4/free.m4
m4/fstatat.m4
m4/fsusage.m4
m4/fsync.m4
m4/futimens.m4
m4/getdtablesize.m4
m4/getgroups.m4
m4/getloadavg.m4
m4/getopt.m4
m4/getrandom.m4
m4/gettime.m4
m4/gettimeofday.m4
m4/gl-openssl.m4
m4/gnulib-common.m4
m4/group-member.m4
m4/ieee754-h.m4
m4/include_next.m4
m4/inttypes.m4
m4/largefile.m4
m4/lchmod.m4
m4/libgmp.m4
m4/limits-h.m4
m4/lstat.m4
m4/malloc.m4
m4/manywarnings-c++.m4
m4/manywarnings.m4
m4/mbstate_t.m4
m4/md5.m4
m4/memmem.m4
m4/mempcpy.m4
m4/memrchr.m4
m4/minmax.m4
m4/mkostemp.m4
m4/mktime.m4
m4/mode_t.m4
m4/multiarch.m4
m4/nanosleep.m4
m4/nocrash.m4
m4/nproc.m4
m4/nstrftime.m4
m4/off_t.m4
m4/open-cloexec.m4
m4/open-slash.m4
m4/open.m4
m4/pathmax.m4
m4/pid_t.m4
m4/pipe2.m4
m4/pselect.m4
m4/pthread_sigmask.m4
m4/rawmemchr.m4
m4/readlink.m4
m4/readlinkat.m4
m4/realloc.m4
m4/regex.m4
m4/sha1.m4
m4/sha256.m4
m4/sha512.m4
m4/sig2str.m4
m4/sigdescr_np.m4
m4/signal_h.m4
m4/socklen.m4
m4/ssize_t.m4
m4/stat-time.m4
m4/std-gnu11.m4
m4/stdalign.m4
m4/stddef_h.m4
m4/stdint.m4
m4/stdio_h.m4
m4/stdlib_h.m4
m4/stpcpy.m4
m4/string_h.m4
m4/strnlen.m4
m4/strtoimax.m4
m4/strtoll.m4
m4/symlink.m4
m4/sys_random_h.m4
m4/sys_select_h.m4
m4/sys_socket_h.m4
m4/sys_stat_h.m4
m4/sys_time_h.m4
m4/sys_types_h.m4
m4/tempname.m4
m4/time_h.m4
m4/time_r.m4
m4/time_rz.m4
m4/timegm.m4
m4/timer_time.m4
m4/timespec.m4
m4/tm_gmtoff.m4
m4/unistd_h.m4
m4/unlocked-io.m4
m4/utimens.m4
m4/utimensat.m4
m4/utimes.m4
m4/vararrays.m4
m4/warn-on-use.m4
m4/warnings.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/year2038.m4
m4/zzgnulib.m4
Copying file lib/gl_openssl.h
Copying file lib/nanosleep.c
Copying file lib/stdio-read.c
Copying file lib/stdio-write.c
Copying file m4/fcntl-o.m4
Copying file m4/gl-openssl.m4
Copying file m4/gnulib-tool.m4
Copying file m4/manywarnings-c++.m4
Copying file m4/nanosleep.m4
Copying file m4/warn-on-use.m4
Copying file m4/wint_t.m4
Creating m4/gnulib-cache.m4
Updating m4/gnulib-comp.m4 (backup in m4/gnulib-comp.m4~)
Updating lib/gnulib.mk.in (backup in lib/gnulib.mk.in~)
Finished.
You may need to add #include directives for the following .h files.
#include <alloca.h>
#include <byteswap.h>
#include <dirent.h>
#include <execinfo.h>
#include <fcntl.h>
#include <getopt.h>
#include <gmp.h>
#include <ieee754.h>
#include <inttypes.h>
#include <regex.h>
#include <signal.h>
#include <stdalign.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/random.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include "acl.h"
#include "binary-io.h"
#include "c-ctype.h"
#include "c-strcase.h"
#include "careadlinkat.h"
#include "close-stream.h"
#include "count-leading-zeros.h"
#include "count-one-bits.h"
#include "count-trailing-zeros.h"
#include "diffseq.h"
#include "filemode.h"
#include "filename.h"
#include "filevercmp.h"
#include "fsusage.h"
#include "ftoastr.h"
#include "ignore-value.h"
#include "intprops.h"
#include "md5.h"
#include "minmax.h"
#include "nproc.h"
#include "pathmax.h"
#include "sha1.h"
#include "sha256.h"
#include "sha512.h"
#include "sig2str.h"
#include "stat-time.h"
#include "strftime.h"
#include "tempname.h"
#include "timespec.h"
#include "unlocked-io.h"
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#elif HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#endif
You may need to use the following Makefile variables when linking.
Use them in <program>_LDADD when linking a program, or
in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
$(GETLOADAVG_LIBS)
$(LIBTHREAD)
$(LIB_ACL)
$(LIB_CLOCK_GETTIME)
$(LIB_CRYPTO)
$(LIB_EACCESS)
$(LIB_EXECINFO)
$(LIB_GETRANDOM)
$(LIB_HAS_ACL)
$(LIB_MBRTOWC)
$(LIB_NANOSLEEP)
$(LIB_PTHREAD_SIGMASK)
$(LIB_SELECT)
$(LIB_TIMER_TIME)
$(LTLIBGMP) when linking with libtool, $(LIBGMP) otherwise
$(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise
Don't forget to
- "include gnulib.mk.in" from within "lib/Makefile.am",
- mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am
or add an AC_CONFIG_MACRO_DIRS([m4]) invocation in ./configure.ac,
- mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am,
- invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC,
- invoke gl_INIT in ./configure.ac.
Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)
Checking for autoconf (need at least version 2.65) ... ok
Your system has the required tools.
Building aclocal.m4 ...
Running 'autoreconf -fi -I m4' ...
You can now run './configure'.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: admin/merge-gnulib
modified: lib/gnulib.mk.in
modified: m4/gnulib-comp.m4
Untracked files:
(use "git add <file>..." to include in what will be committed)
lib/nanosleep.c
m4/nanosleep.m4
merge-gnulib.diff
no changes added to commit (use "git add" and/or "git commit -a")
$ git checkout -b for-larsi
Switched to a new branch 'for-larsi'
$ git add lib/nanosleep.c m4/nanosleep.m4 admin/merge-gnulib
lib/gnulib.mk.in m4/gnulib-comp.m4
$ git commit -m'Add Gnulib nanosleep module'
[for-larsi 2020d4fc91] Add Gnulib nanosleep module
5 files changed, 355 insertions(+), 1 deletion(-)
create mode 100644 lib/nanosleep.c
create mode 100644 m4/nanosleep.m4
$ git format-patch -1
0001-Add-Gnulib-nanosleep-module.patch
$
[-- Attachment #2: 0001-Add-Gnulib-nanosleep-module.patch --]
[-- Type: text/x-patch, Size: 15273 bytes --]
From 2020d4fc91bf704a2572e7b68baca615f88a9144 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 1 Mar 2022 18:04:38 -0800
Subject: [PATCH] Add Gnulib nanosleep module
---
admin/merge-gnulib | 2 +-
lib/gnulib.mk.in | 13 +++
lib/nanosleep.c | 195 +++++++++++++++++++++++++++++++++++++++++++++
m4/gnulib-comp.m4 | 7 ++
m4/nanosleep.m4 | 139 ++++++++++++++++++++++++++++++++
5 files changed, 355 insertions(+), 1 deletion(-)
create mode 100644 lib/nanosleep.c
create mode 100644 m4/nanosleep.m4
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..ea3d23686f 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -40,7 +40,7 @@ GNULIB_MODULES=
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile libgmp lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
- nproc nstrftime
+ nanosleep nproc nstrftime
pathmax pipe2 pselect pthread_sigmask
qcopy-acl readlink readlinkat regex
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 3a9f5b9818..3deeca98be 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -129,6 +129,7 @@
# minmax \
# mkostemp \
# mktime \
+# nanosleep \
# nproc \
# nstrftime \
# pathmax \
@@ -207,6 +208,7 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CRYPTOLIB = @CRYPTOLIB@
CXX = @CXX@
+CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGWIN_OBJ = @CYGWIN_OBJ@
C_SWITCH_MACHINE = @C_SWITCH_MACHINE@
@@ -283,6 +285,7 @@ GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@
GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@
GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION = @GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION@
GL_COND_OBJ_MKOSTEMP_CONDITION = @GL_COND_OBJ_MKOSTEMP_CONDITION@
+GL_COND_OBJ_NANOSLEEP_CONDITION = @GL_COND_OBJ_NANOSLEEP_CONDITION@
GL_COND_OBJ_OPEN_CONDITION = @GL_COND_OBJ_OPEN_CONDITION@
GL_COND_OBJ_PSELECT_CONDITION = @GL_COND_OBJ_PSELECT_CONDITION@
GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@
@@ -2497,6 +2500,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
endif
## end gnulib module mktime-internal
+## begin gnulib module nanosleep
+ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
+
+ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
+libgnu_a_SOURCES += nanosleep.c
+endif
+
+endif
+## end gnulib module nanosleep
+
## begin gnulib module nproc
ifeq (,$(OMIT_GNULIB_MODULE_nproc))
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
new file mode 100644
index 0000000000..446794edc0
--- /dev/null
+++ b/lib/nanosleep.c
@@ -0,0 +1,195 @@
+/* Provide a replacement for the POSIX nanosleep function.
+
+ Copyright (C) 1999-2000, 2002, 2004-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering
+ and Bruno Haible for the native Windows part */
+
+#include <config.h>
+
+#include <time.h>
+
+#include "intprops.h"
+#include "verify.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <signal.h>
+
+#include <errno.h>
+
+#include <unistd.h>
+
+
+enum { BILLION = 1000 * 1000 * 1000 };
+
+#if HAVE_BUG_BIG_NANOSLEEP
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+# undef nanosleep
+{
+ /* nanosleep mishandles large sleeps due to internal overflow problems.
+ The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
+ can't sleep more than 24.85 days (2^31 milliseconds). Similarly,
+ cygwin 1.5.x, which can't sleep more than 49.7 days (2^32 milliseconds).
+ Solve this by breaking the sleep up into smaller chunks. */
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ {
+ /* Verify that time_t is large enough. */
+ verify (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
+ const time_t limit = 24 * 24 * 60 * 60;
+ time_t seconds = requested_delay->tv_sec;
+ struct timespec intermediate;
+ intermediate.tv_nsec = requested_delay->tv_nsec;
+
+ while (limit < seconds)
+ {
+ int result;
+ intermediate.tv_sec = limit;
+ result = nanosleep (&intermediate, remaining_delay);
+ seconds -= limit;
+ if (result)
+ {
+ if (remaining_delay)
+ remaining_delay->tv_sec += seconds;
+ return result;
+ }
+ intermediate.tv_nsec = 0;
+ }
+ intermediate.tv_sec = seconds;
+ return nanosleep (&intermediate, remaining_delay);
+ }
+}
+
+#elif defined _WIN32 && ! defined __CYGWIN__
+/* Native Windows platforms. */
+
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* The Windows API function Sleep() has a resolution of about 15 ms and takes
+ at least 5 ms to execute. We use this function for longer time periods.
+ Additionally, we use busy-looping over short time periods, to get a
+ resolution of about 0.01 ms. In order to measure such short timespans,
+ we use the QueryPerformanceCounter() function. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ static bool initialized;
+ /* Number of performance counter increments per nanosecond,
+ or zero if it could not be determined. */
+ static double ticks_per_nanosecond;
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* For requested delays of one second or more, 15ms resolution is
+ sufficient. */
+ if (requested_delay->tv_sec == 0)
+ {
+ if (!initialized)
+ {
+ /* Initialize ticks_per_nanosecond. */
+ LARGE_INTEGER ticks_per_second;
+
+ if (QueryPerformanceFrequency (&ticks_per_second))
+ ticks_per_nanosecond =
+ (double) ticks_per_second.QuadPart / 1000000000.0;
+
+ initialized = true;
+ }
+ if (ticks_per_nanosecond)
+ {
+ /* QueryPerformanceFrequency worked. We can use
+ QueryPerformanceCounter. Use a combination of Sleep and
+ busy-looping. */
+ /* Number of milliseconds to pass to the Sleep function.
+ Since Sleep can take up to 8 ms less or 8 ms more than requested
+ (or maybe more if the system is loaded), we subtract 10 ms. */
+ int sleep_millis = (int) requested_delay->tv_nsec / 1000000 - 10;
+ /* Determine how many ticks to delay. */
+ LONGLONG wait_ticks = requested_delay->tv_nsec * ticks_per_nanosecond;
+ /* Start. */
+ LARGE_INTEGER counter_before;
+ if (QueryPerformanceCounter (&counter_before))
+ {
+ /* Wait until the performance counter has reached this value.
+ We don't need to worry about overflow, because the performance
+ counter is reset at reboot, and with a frequency of 3.6E6
+ ticks per second 63 bits suffice for over 80000 years. */
+ LONGLONG wait_until = counter_before.QuadPart + wait_ticks;
+ /* Use Sleep for the longest part. */
+ if (sleep_millis > 0)
+ Sleep (sleep_millis);
+ /* Busy-loop for the rest. */
+ for (;;)
+ {
+ LARGE_INTEGER counter_after;
+ if (!QueryPerformanceCounter (&counter_after))
+ /* QueryPerformanceCounter failed, but succeeded earlier.
+ Should not happen. */
+ break;
+ if (counter_after.QuadPart >= wait_until)
+ /* The requested time has elapsed. */
+ break;
+ }
+ goto done;
+ }
+ }
+ }
+ /* Implementation for long delays and as fallback. */
+ Sleep (requested_delay->tv_sec * 1000 + requested_delay->tv_nsec / 1000000);
+
+ done:
+ /* Sleep is not interruptible. So there is no remaining delay. */
+ if (remaining_delay != NULL)
+ {
+ remaining_delay->tv_sec = 0;
+ remaining_delay->tv_nsec = 0;
+ }
+ return 0;
+}
+
+#else
+/* Other platforms lacking nanosleep.
+ It's not clear whether these are still practical porting targets.
+ For now, just fall back on pselect. */
+
+/* Suspend execution for at least *REQUESTED_DELAY seconds. The
+ *REMAINING_DELAY part isn't implemented yet. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ return pselect (0, NULL, NULL, NULL, requested_delay, NULL);
+}
+#endif
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 1d31239d2d..fb5f1b52a4 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -140,6 +140,7 @@ AC_DEFUN
# Code from module mktime:
# Code from module mktime-internal:
# Code from module multiarch:
+ # Code from module nanosleep:
# Code from module nocrash:
# Code from module nproc:
# Code from module nstrftime:
@@ -430,6 +431,10 @@ AC_DEFUN
fi
gl_TIME_MODULE_INDICATOR([mktime])
gl_MULTIARCH
+ gl_FUNC_NANOSLEEP
+ gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP],
+ [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1])
+ gl_TIME_MODULE_INDICATOR([nanosleep])
gl_NPROC
gl_FUNC_GNU_STRFTIME
gl_PATHMAX
@@ -1304,6 +1309,7 @@ AC_DEFUN
lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
+ lib/nanosleep.c
lib/nproc.c
lib/nproc.h
lib/nstrftime.c
@@ -1456,6 +1462,7 @@ AC_DEFUN
m4/mktime.m4
m4/mode_t.m4
m4/multiarch.m4
+ m4/nanosleep.m4
m4/nocrash.m4
m4/nproc.m4
m4/nstrftime.m4
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
new file mode 100644
index 0000000000..1964b1ea47
--- /dev/null
+++ b/m4/nanosleep.m4
@@ -0,0 +1,139 @@
+# serial 41
+
+dnl From Jim Meyering.
+dnl Check for the nanosleep function.
+dnl If not found, use the supplied replacement.
+dnl
+
+# Copyright (C) 1999-2001, 2003-2022 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NANOSLEEP],
+[
+ AC_REQUIRE([gl_TIME_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([alarm])
+
+ nanosleep_save_libs=$LIBS
+
+ # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
+ # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+ LIB_NANOSLEEP=
+ AC_SUBST([LIB_NANOSLEEP])
+ AC_SEARCH_LIBS([nanosleep], [rt posix4],
+ [test "$ac_cv_search_nanosleep" = "none required" ||
+ LIB_NANOSLEEP=$ac_cv_search_nanosleep])
+ if test "x$ac_cv_search_nanosleep" != xno; then
+ dnl The system has a nanosleep function.
+
+ AC_REQUIRE([gl_MULTIARCH])
+ if test $APPLE_UNIVERSAL_BUILD = 1; then
+ # A universal build on Apple Mac OS X platforms.
+ # The test result would be 'no (mishandles large arguments)' in 64-bit
+ # mode but 'yes' in 32-bit mode. But we need a configuration result that
+ # is valid in both modes.
+ gl_cv_func_nanosleep='no (mishandles large arguments)'
+ fi
+
+ AC_CACHE_CHECK([for working nanosleep],
+ [gl_cv_func_nanosleep],
+ [
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <errno.h>
+ #include <limits.h>
+ #include <signal.h>
+ #include <time.h>
+ #include <unistd.h>
+ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+ #define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+
+ #if HAVE_DECL_ALARM
+ static void
+ check_for_SIGALRM (int sig)
+ {
+ if (sig != SIGALRM)
+ _exit (1);
+ }
+ #endif
+
+ int
+ main ()
+ {
+ static struct timespec ts_sleep;
+ static struct timespec ts_remaining;
+ /* Test for major problems first. */
+ if (! nanosleep)
+ return 2;
+ ts_sleep.tv_sec = 0;
+ ts_sleep.tv_nsec = 1;
+ #if HAVE_DECL_ALARM
+ {
+ static struct sigaction act;
+ act.sa_handler = check_for_SIGALRM;
+ sigemptyset (&act.sa_mask);
+ sigaction (SIGALRM, &act, NULL);
+ alarm (1);
+ if (nanosleep (&ts_sleep, NULL) != 0)
+ return 3;
+ /* Test for a minor problem: the handling of large arguments. */
+ ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
+ ts_sleep.tv_nsec = 999999999;
+ alarm (1);
+ if (nanosleep (&ts_sleep, &ts_remaining) != -1)
+ return 4;
+ if (errno != EINTR)
+ return 5;
+ if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10)
+ return 6;
+ }
+ #else /* A simpler test for native Windows. */
+ if (nanosleep (&ts_sleep, &ts_remaining) < 0)
+ return 3;
+ #endif
+ return 0;
+ }]])],
+ [gl_cv_func_nanosleep=yes],
+ [case $? in dnl (
+ 4|5|6) gl_cv_func_nanosleep='no (mishandles large arguments)';; dnl (
+ *) gl_cv_func_nanosleep=no;;
+ esac],
+ [case "$host_os" in dnl ((
+ linux*) # Guess it halfway works when the kernel is Linux.
+ gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;;
+ mingw*) # Guess no on native Windows.
+ gl_cv_func_nanosleep='guessing no' ;;
+ *) # If we don't know, obey --enable-cross-guesses.
+ gl_cv_func_nanosleep="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_nanosleep" in
+ *yes)
+ REPLACE_NANOSLEEP=0
+ ;;
+ *)
+ REPLACE_NANOSLEEP=1
+ case "$gl_cv_func_nanosleep" in
+ *"mishandles large arguments"*)
+ AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
+ [Define to 1 if nanosleep mishandles large arguments.])
+ ;;
+ esac
+ ;;
+ esac
+ else
+ HAVE_NANOSLEEP=0
+ fi
+ LIBS=$nanosleep_save_libs
+])
--
2.35.1
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <ab47871e-ad1e-e06d-c226-ab7b7c9bb857@cs.ucla.edu>
@ 2022-03-03 13:46 ` Lars Ingebrigtsen
2022-03-03 13:49 ` Lars Ingebrigtsen
` (2 subsequent siblings)
3 siblings, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-03 13:46 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Paul Eggert <eggert@cs.ucla.edu> writes:
> This diff is wrong, as it omits a line
> "GL_COND_OBJ_NANOSLEEP_CONDITION = @GL_COND_OBJ_NANOSLEEP_CONDITION@".
Yup, looks like it.
> I ran what should have been something like your commands and got the
> attached patch. One way forward is for you to simply install the
> attached patch and move on from there. Or we can continue to look into
> why things work for me and not for you. I suppose it could be an
> Autoconf bug on your platform, but it'd be an odd one.
As far as I can tell, I'm running exactly the same commands you are, but
I end up with a result that misses the line up there.
Let's see... I've been doing this on my development laptop (which uses
debian/bookworm (i.e., "testing"). I now re-ran the merge-gnulib on a
debian/bullseye (i.e., "stable"), and I get the same results as you now
(i.e., things work).
So either there's something weird on my laptop, or it sounds like
there's an Autoconf bug in debian/bookworm?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <ab47871e-ad1e-e06d-c226-ab7b7c9bb857@cs.ucla.edu>
2022-03-03 13:46 ` Lars Ingebrigtsen
@ 2022-03-03 13:49 ` Lars Ingebrigtsen
[not found] ` <87czj3jgdd.fsf@gnus.org>
[not found] ` <87h78fjgi7.fsf@gnus.org>
3 siblings, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-03 13:49 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Eli, here's the proposed complete patch to do some sleeping in
gnutls_try_handshake. Does it work on Windows for you?
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index fec469c017..ea3d23686f 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -40,7 +40,7 @@ GNULIB_MODULES=
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile libgmp lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime
- nproc nstrftime
+ nanosleep nproc nstrftime
pathmax pipe2 pselect pthread_sigmask
qcopy-acl readlink readlinkat regex
sig2str sigdescr_np socklen stat-time std-gnu11 stdalign stddef stdio
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 3a9f5b9818..3deeca98be 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -129,6 +129,7 @@
# minmax \
# mkostemp \
# mktime \
+# nanosleep \
# nproc \
# nstrftime \
# pathmax \
@@ -207,6 +208,7 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CRYPTOLIB = @CRYPTOLIB@
CXX = @CXX@
+CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGWIN_OBJ = @CYGWIN_OBJ@
C_SWITCH_MACHINE = @C_SWITCH_MACHINE@
@@ -283,6 +285,7 @@ GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@
GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@
GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION = @GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION@
GL_COND_OBJ_MKOSTEMP_CONDITION = @GL_COND_OBJ_MKOSTEMP_CONDITION@
+GL_COND_OBJ_NANOSLEEP_CONDITION = @GL_COND_OBJ_NANOSLEEP_CONDITION@
GL_COND_OBJ_OPEN_CONDITION = @GL_COND_OBJ_OPEN_CONDITION@
GL_COND_OBJ_PSELECT_CONDITION = @GL_COND_OBJ_PSELECT_CONDITION@
GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@
@@ -2497,6 +2500,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
endif
## end gnulib module mktime-internal
+## begin gnulib module nanosleep
+ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
+
+ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
+libgnu_a_SOURCES += nanosleep.c
+endif
+
+endif
+## end gnulib module nanosleep
+
## begin gnulib module nproc
ifeq (,$(OMIT_GNULIB_MODULE_nproc))
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
new file mode 100644
index 0000000000..446794edc0
--- /dev/null
+++ b/lib/nanosleep.c
@@ -0,0 +1,195 @@
+/* Provide a replacement for the POSIX nanosleep function.
+
+ Copyright (C) 1999-2000, 2002, 2004-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering
+ and Bruno Haible for the native Windows part */
+
+#include <config.h>
+
+#include <time.h>
+
+#include "intprops.h"
+#include "verify.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <signal.h>
+
+#include <errno.h>
+
+#include <unistd.h>
+
+
+enum { BILLION = 1000 * 1000 * 1000 };
+
+#if HAVE_BUG_BIG_NANOSLEEP
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+# undef nanosleep
+{
+ /* nanosleep mishandles large sleeps due to internal overflow problems.
+ The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
+ can't sleep more than 24.85 days (2^31 milliseconds). Similarly,
+ cygwin 1.5.x, which can't sleep more than 49.7 days (2^32 milliseconds).
+ Solve this by breaking the sleep up into smaller chunks. */
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ {
+ /* Verify that time_t is large enough. */
+ verify (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
+ const time_t limit = 24 * 24 * 60 * 60;
+ time_t seconds = requested_delay->tv_sec;
+ struct timespec intermediate;
+ intermediate.tv_nsec = requested_delay->tv_nsec;
+
+ while (limit < seconds)
+ {
+ int result;
+ intermediate.tv_sec = limit;
+ result = nanosleep (&intermediate, remaining_delay);
+ seconds -= limit;
+ if (result)
+ {
+ if (remaining_delay)
+ remaining_delay->tv_sec += seconds;
+ return result;
+ }
+ intermediate.tv_nsec = 0;
+ }
+ intermediate.tv_sec = seconds;
+ return nanosleep (&intermediate, remaining_delay);
+ }
+}
+
+#elif defined _WIN32 && ! defined __CYGWIN__
+/* Native Windows platforms. */
+
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* The Windows API function Sleep() has a resolution of about 15 ms and takes
+ at least 5 ms to execute. We use this function for longer time periods.
+ Additionally, we use busy-looping over short time periods, to get a
+ resolution of about 0.01 ms. In order to measure such short timespans,
+ we use the QueryPerformanceCounter() function. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ static bool initialized;
+ /* Number of performance counter increments per nanosecond,
+ or zero if it could not be determined. */
+ static double ticks_per_nanosecond;
+
+ if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* For requested delays of one second or more, 15ms resolution is
+ sufficient. */
+ if (requested_delay->tv_sec == 0)
+ {
+ if (!initialized)
+ {
+ /* Initialize ticks_per_nanosecond. */
+ LARGE_INTEGER ticks_per_second;
+
+ if (QueryPerformanceFrequency (&ticks_per_second))
+ ticks_per_nanosecond =
+ (double) ticks_per_second.QuadPart / 1000000000.0;
+
+ initialized = true;
+ }
+ if (ticks_per_nanosecond)
+ {
+ /* QueryPerformanceFrequency worked. We can use
+ QueryPerformanceCounter. Use a combination of Sleep and
+ busy-looping. */
+ /* Number of milliseconds to pass to the Sleep function.
+ Since Sleep can take up to 8 ms less or 8 ms more than requested
+ (or maybe more if the system is loaded), we subtract 10 ms. */
+ int sleep_millis = (int) requested_delay->tv_nsec / 1000000 - 10;
+ /* Determine how many ticks to delay. */
+ LONGLONG wait_ticks = requested_delay->tv_nsec * ticks_per_nanosecond;
+ /* Start. */
+ LARGE_INTEGER counter_before;
+ if (QueryPerformanceCounter (&counter_before))
+ {
+ /* Wait until the performance counter has reached this value.
+ We don't need to worry about overflow, because the performance
+ counter is reset at reboot, and with a frequency of 3.6E6
+ ticks per second 63 bits suffice for over 80000 years. */
+ LONGLONG wait_until = counter_before.QuadPart + wait_ticks;
+ /* Use Sleep for the longest part. */
+ if (sleep_millis > 0)
+ Sleep (sleep_millis);
+ /* Busy-loop for the rest. */
+ for (;;)
+ {
+ LARGE_INTEGER counter_after;
+ if (!QueryPerformanceCounter (&counter_after))
+ /* QueryPerformanceCounter failed, but succeeded earlier.
+ Should not happen. */
+ break;
+ if (counter_after.QuadPart >= wait_until)
+ /* The requested time has elapsed. */
+ break;
+ }
+ goto done;
+ }
+ }
+ }
+ /* Implementation for long delays and as fallback. */
+ Sleep (requested_delay->tv_sec * 1000 + requested_delay->tv_nsec / 1000000);
+
+ done:
+ /* Sleep is not interruptible. So there is no remaining delay. */
+ if (remaining_delay != NULL)
+ {
+ remaining_delay->tv_sec = 0;
+ remaining_delay->tv_nsec = 0;
+ }
+ return 0;
+}
+
+#else
+/* Other platforms lacking nanosleep.
+ It's not clear whether these are still practical porting targets.
+ For now, just fall back on pselect. */
+
+/* Suspend execution for at least *REQUESTED_DELAY seconds. The
+ *REMAINING_DELAY part isn't implemented yet. */
+
+int
+nanosleep (const struct timespec *requested_delay,
+ struct timespec *remaining_delay)
+{
+ return pselect (0, NULL, NULL, NULL, requested_delay, NULL);
+}
+#endif
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 1d31239d2d..fb5f1b52a4 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -140,6 +140,7 @@ AC_DEFUN
# Code from module mktime:
# Code from module mktime-internal:
# Code from module multiarch:
+ # Code from module nanosleep:
# Code from module nocrash:
# Code from module nproc:
# Code from module nstrftime:
@@ -430,6 +431,10 @@ AC_DEFUN
fi
gl_TIME_MODULE_INDICATOR([mktime])
gl_MULTIARCH
+ gl_FUNC_NANOSLEEP
+ gl_CONDITIONAL([GL_COND_OBJ_NANOSLEEP],
+ [test $HAVE_NANOSLEEP = 0 || test $REPLACE_NANOSLEEP = 1])
+ gl_TIME_MODULE_INDICATOR([nanosleep])
gl_NPROC
gl_FUNC_GNU_STRFTIME
gl_PATHMAX
@@ -1304,6 +1309,7 @@ AC_DEFUN
lib/mkostemp.c
lib/mktime-internal.h
lib/mktime.c
+ lib/nanosleep.c
lib/nproc.c
lib/nproc.h
lib/nstrftime.c
@@ -1456,6 +1462,7 @@ AC_DEFUN
m4/mktime.m4
m4/mode_t.m4
m4/multiarch.m4
+ m4/nanosleep.m4
m4/nocrash.m4
m4/nproc.m4
m4/nstrftime.m4
diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4
new file mode 100644
index 0000000000..1964b1ea47
--- /dev/null
+++ b/m4/nanosleep.m4
@@ -0,0 +1,139 @@
+# serial 41
+
+dnl From Jim Meyering.
+dnl Check for the nanosleep function.
+dnl If not found, use the supplied replacement.
+dnl
+
+# Copyright (C) 1999-2001, 2003-2022 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NANOSLEEP],
+[
+ AC_REQUIRE([gl_TIME_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([alarm])
+
+ nanosleep_save_libs=$LIBS
+
+ # Solaris 2.5.1 needs -lposix4 to get the nanosleep function.
+ # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+ LIB_NANOSLEEP=
+ AC_SUBST([LIB_NANOSLEEP])
+ AC_SEARCH_LIBS([nanosleep], [rt posix4],
+ [test "$ac_cv_search_nanosleep" = "none required" ||
+ LIB_NANOSLEEP=$ac_cv_search_nanosleep])
+ if test "x$ac_cv_search_nanosleep" != xno; then
+ dnl The system has a nanosleep function.
+
+ AC_REQUIRE([gl_MULTIARCH])
+ if test $APPLE_UNIVERSAL_BUILD = 1; then
+ # A universal build on Apple Mac OS X platforms.
+ # The test result would be 'no (mishandles large arguments)' in 64-bit
+ # mode but 'yes' in 32-bit mode. But we need a configuration result that
+ # is valid in both modes.
+ gl_cv_func_nanosleep='no (mishandles large arguments)'
+ fi
+
+ AC_CACHE_CHECK([for working nanosleep],
+ [gl_cv_func_nanosleep],
+ [
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <errno.h>
+ #include <limits.h>
+ #include <signal.h>
+ #include <time.h>
+ #include <unistd.h>
+ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+ #define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+
+ #if HAVE_DECL_ALARM
+ static void
+ check_for_SIGALRM (int sig)
+ {
+ if (sig != SIGALRM)
+ _exit (1);
+ }
+ #endif
+
+ int
+ main ()
+ {
+ static struct timespec ts_sleep;
+ static struct timespec ts_remaining;
+ /* Test for major problems first. */
+ if (! nanosleep)
+ return 2;
+ ts_sleep.tv_sec = 0;
+ ts_sleep.tv_nsec = 1;
+ #if HAVE_DECL_ALARM
+ {
+ static struct sigaction act;
+ act.sa_handler = check_for_SIGALRM;
+ sigemptyset (&act.sa_mask);
+ sigaction (SIGALRM, &act, NULL);
+ alarm (1);
+ if (nanosleep (&ts_sleep, NULL) != 0)
+ return 3;
+ /* Test for a minor problem: the handling of large arguments. */
+ ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
+ ts_sleep.tv_nsec = 999999999;
+ alarm (1);
+ if (nanosleep (&ts_sleep, &ts_remaining) != -1)
+ return 4;
+ if (errno != EINTR)
+ return 5;
+ if (ts_remaining.tv_sec <= TYPE_MAXIMUM (time_t) - 10)
+ return 6;
+ }
+ #else /* A simpler test for native Windows. */
+ if (nanosleep (&ts_sleep, &ts_remaining) < 0)
+ return 3;
+ #endif
+ return 0;
+ }]])],
+ [gl_cv_func_nanosleep=yes],
+ [case $? in dnl (
+ 4|5|6) gl_cv_func_nanosleep='no (mishandles large arguments)';; dnl (
+ *) gl_cv_func_nanosleep=no;;
+ esac],
+ [case "$host_os" in dnl ((
+ linux*) # Guess it halfway works when the kernel is Linux.
+ gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;;
+ mingw*) # Guess no on native Windows.
+ gl_cv_func_nanosleep='guessing no' ;;
+ *) # If we don't know, obey --enable-cross-guesses.
+ gl_cv_func_nanosleep="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ ])
+ case "$gl_cv_func_nanosleep" in
+ *yes)
+ REPLACE_NANOSLEEP=0
+ ;;
+ *)
+ REPLACE_NANOSLEEP=1
+ case "$gl_cv_func_nanosleep" in
+ *"mishandles large arguments"*)
+ AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], [1],
+ [Define to 1 if nanosleep mishandles large arguments.])
+ ;;
+ esac
+ ;;
+ esac
+ else
+ HAVE_NANOSLEEP=0
+ fi
+ LIBS=$nanosleep_save_libs
+])
diff --git a/src/gnutls.c b/src/gnutls.c
index 3ec3837067..09590ca005 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -616,6 +616,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
gnutls_session_t state = proc->gnutls_state;
int ret;
bool non_blocking = proc->is_non_blocking_client;
+ /* Sleep for ten milliseconds when busy-looping in
+ gnutls_handshake. */
+ struct timespec delay = { 0, 1000 * 1000 * 10 };
if (proc->gnutls_complete_negotiation_p)
non_blocking = false;
@@ -630,6 +633,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
maybe_quit ();
if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
break;
+ nanosleep (&delay, NULL);
}
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87czj3jgdd.fsf@gnus.org>
@ 2022-03-03 15:11 ` Eli Zaretskii
2022-03-04 15:28 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2022-03-03 15:11 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: bug-gnulib@gnu.org, npostavs@gmail.com, 32452@debbugs.gnu.org, Eli
> Zaretskii <eliz@gnu.org>
> Date: Thu, 03 Mar 2022 14:49:18 +0100
>
> Eli, here's the proposed complete patch to do some sleeping in
> gnutls_try_handshake. Does it work on Windows for you?
It does, after I make these 2 additional changes:
diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk
index 4748474..69119b1 100644
--- a/nt/gnulib-cfg.mk
+++ b/nt/gnulib-cfg.mk
@@ -74,3 +74,4 @@ OMIT_GNULIB_MODULE_futimens =
OMIT_GNULIB_MODULE_utimensat = true
OMIT_GNULIB_MODULE_file-has-acl = true
OMIT_GNULIB_MODULE_nproc = true
+OMIT_GNULIB_MODULE_nanosleep = true
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index 6ab81e9..7ca19cb 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -167,3 +167,6 @@ ac_cv_func_strsignal=no
# implementation of 'free' doesn't touch errno, and it emits a
# compilation warning.
gl_cv_func_free_preserves_errno=yes
+# Don't build the Gnulib nanosleep module: it requires W2K or later,
+# and MinGW does have nanosleep.
+gl_cv_func_nanosleep=yes
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <87h78fjgi7.fsf@gnus.org>
@ 2022-03-03 21:40 ` Paul Eggert
[not found] ` <0756f1bd-1348-84ef-4eb8-4cc25eacf1dd@cs.ucla.edu>
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-03-03 21:40 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 32452, bug-gnulib, npostavs
On 3/3/22 05:46, Lars Ingebrigtsen wrote:
> So either there's something weird on my laptop, or it sounds like
> there's an Autoconf bug in debian/bookworm?
Could be either.
Debian Bookworm uses Autoconf 2.71+patches, as opposed to the Autoconf
2.69+patches that Fedora 35 uses. For what it's worth I just now tried
to reproduce the problem on Fedora 35 but with an Autoconf 2.71 that I
installed by hand, and could not reproduce the problem. However, I
looked at the patches in autoconf_2.71-2.debian.tar.xz and none of them
seemed to be relevant (some don't even apply, which is curious....).
If you have an easily-reproducible script (runs in the C locale, etc.)
it might be worth a bug report to the Debian developers. To be honest
though it sounds like it might be something odd on your laptop.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-03 15:11 ` Eli Zaretskii
@ 2022-03-04 15:28 ` Lars Ingebrigtsen
2022-03-04 16:47 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-04 15:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, npostavs, 32452
Eli Zaretskii <eliz@gnu.org> writes:
> It does, after I make these 2 additional changes:
Thanks; I've now pushed this complete change set to Emacs 29. I'll open
a new bug report for the p/select issue Paul noted on gnustep, and I'm
closing this one.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
[not found] ` <0756f1bd-1348-84ef-4eb8-4cc25eacf1dd@cs.ucla.edu>
@ 2022-03-04 15:31 ` Lars Ingebrigtsen
0 siblings, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-04 15:31 UTC (permalink / raw)
To: Paul Eggert; +Cc: 32452, bug-gnulib, npostavs
Paul Eggert <eggert@cs.ucla.edu> writes:
> If you have an easily-reproducible script (runs in the C locale, etc.)
> it might be worth a bug report to the Debian developers. To be honest
> though it sounds like it might be something odd on your laptop.
Might well be -- perhaps something's gotten slightly borked while doing
updates. So I think I'll just leave this be for now...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-04 15:28 ` Lars Ingebrigtsen
@ 2022-03-04 16:47 ` Lars Ingebrigtsen
2022-03-04 19:46 ` Eli Zaretskii
0 siblings, 1 reply; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-04 16:47 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, npostavs, 32452
Hm, this led to the emacs-module tests to fail:
passed 16/38 mod-test-non-local-exit-throw-test (0.000024 sec)
../src/emacs: symbol lookup error: /home/larsi/src/emacs/trunk/test/src/emacs-module-resources/mod-test.so: undefined symbol: rpl_nanosleep
make[1]: *** [Makefile:176: src/emacs-module-tests.log] Error 127
Does gnulib changes require updates to the module stuff?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-04 16:47 ` Lars Ingebrigtsen
@ 2022-03-04 19:46 ` Eli Zaretskii
2022-03-05 17:11 ` Lars Ingebrigtsen
0 siblings, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2022-03-04 19:46 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: eggert@cs.ucla.edu, npostavs@gmail.com, 32452@debbugs.gnu.org
> Date: Fri, 04 Mar 2022 17:47:48 +0100
>
> Hm, this led to the emacs-module tests to fail:
>
> passed 16/38 mod-test-non-local-exit-throw-test (0.000024 sec)
> ../src/emacs: symbol lookup error: /home/larsi/src/emacs/trunk/test/src/emacs-module-resources/mod-test.so: undefined symbol: rpl_nanosleep
> make[1]: *** [Makefile:176: src/emacs-module-tests.log] Error 127
>
> Does gnulib changes require updates to the module stuff?
mod-test.c calls nanosleep, so it needs to be linked against libgnu.a,
I think. (We should have done that to begin with, since mod-test.c
includes config.h and headers that have Gnulib replacements.)
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-04 19:46 ` Eli Zaretskii
@ 2022-03-05 17:11 ` Lars Ingebrigtsen
2022-03-05 17:47 ` Eli Zaretskii
2022-03-09 3:01 ` Paul Eggert
0 siblings, 2 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-05 17:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, npostavs, 32452
Eli Zaretskii <eliz@gnu.org> writes:
> mod-test.c calls nanosleep, so it needs to be linked against libgnu.a,
> I think. (We should have done that to begin with, since mod-test.c
> includes config.h and headers that have Gnulib replacements.)
The following seems to do the trick (and simplifies the rule slightly).
Does this look correct to you?
diff --git a/test/Makefile.in b/test/Makefile.in
index 708c4b2fb0..09f1e0f005 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -283,9 +283,9 @@ $(test_module): $(test_module:
$(AM_V_CCLD)${MKDIR_P} $(dir $@)
$(AM_V_at)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
-o $@ $< $(LIBGMP) \
+ ../lib/libgnu.a \
$(and $(GMP_H),$(srcdir)/../lib/mini-gmp-gnulib.c) \
- $(FREE_SOURCE_$(REPLACE_FREE)) \
- $(srcdir)/../lib/timespec.c $(srcdir)/../lib/gettime.c
+ $(FREE_SOURCE_$(REPLACE_FREE))
endif
src/emacs-tests.log: ../lib-src/seccomp-filter.c
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-05 17:11 ` Lars Ingebrigtsen
@ 2022-03-05 17:47 ` Eli Zaretskii
2022-03-05 18:06 ` Lars Ingebrigtsen
2022-03-09 3:01 ` Paul Eggert
1 sibling, 1 reply; 53+ messages in thread
From: Eli Zaretskii @ 2022-03-05 17:47 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: eggert, npostavs, 32452
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: eggert@cs.ucla.edu, npostavs@gmail.com, 32452@debbugs.gnu.org
> Date: Sat, 05 Mar 2022 18:11:33 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > mod-test.c calls nanosleep, so it needs to be linked against libgnu.a,
> > I think. (We should have done that to begin with, since mod-test.c
> > includes config.h and headers that have Gnulib replacements.)
>
> The following seems to do the trick (and simplifies the rule slightly).
> Does this look correct to you?
>
> diff --git a/test/Makefile.in b/test/Makefile.in
> index 708c4b2fb0..09f1e0f005 100644
> --- a/test/Makefile.in
> +++ b/test/Makefile.in
> @@ -283,9 +283,9 @@ $(test_module): $(test_module:
> $(AM_V_CCLD)${MKDIR_P} $(dir $@)
> $(AM_V_at)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
> -o $@ $< $(LIBGMP) \
> + ../lib/libgnu.a \
> $(and $(GMP_H),$(srcdir)/../lib/mini-gmp-gnulib.c) \
> - $(FREE_SOURCE_$(REPLACE_FREE)) \
> - $(srcdir)/../lib/timespec.c $(srcdir)/../lib/gettime.c
> + $(FREE_SOURCE_$(REPLACE_FREE))
> endif
I'd put libgnu.a last, after all the sources. It's safer, since ld is
a one-pass linker, so it needs to see the libraries after it saw all
the sources.
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-05 17:47 ` Eli Zaretskii
@ 2022-03-05 18:06 ` Lars Ingebrigtsen
0 siblings, 0 replies; 53+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-05 18:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, npostavs, 32452
Eli Zaretskii <eliz@gnu.org> writes:
> I'd put libgnu.a last, after all the sources. It's safer, since ld is
> a one-pass linker, so it needs to see the libraries after it saw all
> the sources.
Makes sense; now pushed to the trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 53+ messages in thread
* bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
2022-03-05 17:11 ` Lars Ingebrigtsen
2022-03-05 17:47 ` Eli Zaretskii
@ 2022-03-09 3:01 ` Paul Eggert
1 sibling, 0 replies; 53+ messages in thread
From: Paul Eggert @ 2022-03-09 3:01 UTC (permalink / raw)
To: Lars Ingebrigtsen, Eli Zaretskii; +Cc: 32452, npostavs
[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]
On 3/5/22 09:11, Lars Ingebrigtsen wrote:
> $(AM_V_at)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
> -o $@ $< $(LIBGMP) \
> + ../lib/libgnu.a \
Unfortunately that won't work in general; the comment for mod-test.so
says "In the compilation command, we can't use any object or archive
file as source because those are not compiled with -fPIC" but as things
stood mod-test.so was being linked with libgnu.a.
Anyway, mod-test.so should be decoupled from Emacs as much as possible -
that's the whole point of modules after all - so the mod-test.so rule
shouldn't make assumptions about how Emacs internals use Gnulib. I
installed the attached patches to lessen the coupling between
mod-test.so and Emacs internals and I hope this fixes the problem. It
may need to be adjusted a tad for platforms that lack
nanosleep/clock_gettime/libgmp whatever, but the basic idea should work
on these platforms with only minor twiddling.
Even with these patches, mod-test.so uses "config.h"; but at least it
doesn't use Gnulib code.
[-- Attachment #2: 0001-Do-not-include-attribute.h-from-config.h.patch --]
[-- Type: text/x-patch, Size: 8060 bytes --]
From 5b96a5136aacc82a634d41407d4473494596f196 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 8 Mar 2022 18:46:47 -0800
Subject: [PATCH 1/2] Do not include <attribute.h> from <config.h>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is because mod-test.c shouldn’t use source code from lib,
but it does need to include <config.h>.
* lib-src/ebrowse.c, lib-src/emacsclient.c, lib-src/etags.c:
* lib-src/make-docfile.c, lib-src/movemail.c:
* lib-src/seccomp-filter.c, src/dynlib.h, src/lisp.h:
* src/syssignal.h, src/sysstdio.h, src/systhread.h, src/tparam.h:
Include <attribute.h>.
* src/conf_post.h: Do not include <attribute.h>.
All uses of attribute.h macros replaced with their _GL_ equivalents.
---
lib-src/ebrowse.c | 1 +
lib-src/emacsclient.c | 1 +
lib-src/etags.c | 1 +
lib-src/make-docfile.c | 1 +
lib-src/movemail.c | 1 +
lib-src/seccomp-filter.c | 3 ++-
src/conf_post.h | 19 +++++++++----------
src/dynlib.h | 1 +
src/lisp.h | 1 +
src/syssignal.h | 2 ++
src/sysstdio.h | 4 +++-
src/systhread.h | 2 ++
src/tparam.h | 2 ++
13 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index ac7e790187..b77572734f 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -26,6 +26,7 @@ Copyright (C) 1992-2022 Free Software Foundation, Inc.
#include <assert.h>
#include <getopt.h>
+#include <attribute.h>
#include <flexmember.h>
#include <min-max.h>
#include <unlocked-io.h>
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 365e803e1c..7406ef3490 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -80,6 +80,7 @@ Copyright (C) 1986-1987, 1994, 1999-2022 Free Software Foundation, Inc.
#include <sys/stat.h>
#include <unistd.h>
+#include <attribute.h>
#include <filename.h>
#include <intprops.h>
#include <min-max.h>
diff --git a/lib-src/etags.c b/lib-src/etags.c
index aa5bc8839d..65b9fae8d5 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -112,6 +112,7 @@ Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2022 Free Software
# define O_CLOEXEC O_NOINHERIT
#endif /* WINDOWSNT */
+#include <attribute.h>
#include <inttypes.h>
#include <limits.h>
#include <unistd.h>
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index f42b1988a2..d2d4b1d277 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -42,6 +42,7 @@ Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2022 Free Software
#include <stdlib.h>
#include <string.h>
+#include <attribute.h>
#include <binary-io.h>
#include <c-ctype.h>
#include <intprops.h>
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 888688f90b..aa3c15e72e 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -69,6 +69,7 @@ Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2022 Free Software
#include <signal.h>
#include <string.h>
+#include <attribute.h>
#include <unlocked-io.h>
#include "syswait.h"
diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c
index b515851010..9f0de7d64f 100644
--- a/lib-src/seccomp-filter.c
+++ b/lib-src/seccomp-filter.c
@@ -59,7 +59,8 @@ Copyright (C) 2020-2022 Free Software Foundation, Inc.
#include <seccomp.h>
#include <unistd.h>
-#include "verify.h"
+#include <attribute.h>
+#include <verify.h>
#ifndef ARCH_CET_STATUS
#define ARCH_CET_STATUS 0x3001
diff --git a/src/conf_post.h b/src/conf_post.h
index dd350b8dc8..5108e44efb 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -32,13 +32,11 @@ Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2022 Free Software
/* To help make dependencies clearer elsewhere, this file typically
does not #include other files. The exceptions are stdbool.h
because it is unlikely to interfere with configuration and bool is
- such a core part of the C language, attribute.h because its
- ATTRIBUTE_* macros are used here, and ms-w32.h (DOS_NT
+ such a core part of the C language, and ms-w32.h (DOS_NT
only) because it historically was included here and changing that
would take some work. */
#include <stdbool.h>
-#include <attribute.h>
#if defined WINDOWSNT && !defined DEFER_MS_W32_H
# include <ms-w32.h>
@@ -279,8 +277,8 @@ #define setenv_TZ emacs_setenv_TZ
extern char *emacs_getenv_TZ (void);
extern int emacs_setenv_TZ (char const *);
-#define NO_INLINE ATTRIBUTE_NOINLINE
-#define EXTERNALLY_VISIBLE ATTRIBUTE_EXTERNALLY_VISIBLE
+#define NO_INLINE _GL_ATTRIBUTE_NOINLINE
+#define EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
#if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
# define PRINTF_ARCHETYPE __gnu_printf__
@@ -310,9 +308,9 @@ #define EXTERNALLY_VISIBLE ATTRIBUTE_EXTERNALLY_VISIBLE
# define PRINTF_ARCHETYPE __printf__
#endif
#define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
- ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
+ _GL_ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
-#define ARG_NONNULL ATTRIBUTE_NONNULL
+#define ARG_NONNULL _GL_ATTRIBUTE_NONNULL
/* Declare NAME to be a pointer to an object of type TYPE, initialized
to the address ADDR, which may be of a different type. Accesses
@@ -320,15 +318,16 @@ #define ARG_NONNULL ATTRIBUTE_NONNULL
behavior, even if options like gcc -fstrict-aliasing are used. */
#define DECLARE_POINTER_ALIAS(name, type, addr) \
- type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
+ type _GL_ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
#if 3 <= __GNUC__
# define ATTRIBUTE_SECTION(name) __attribute__((section (name)))
#else
-#define ATTRIBUTE_SECTION(name)
+# define ATTRIBUTE_SECTION(name)
#endif
-#define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
+#define ATTRIBUTE_MALLOC_SIZE(args) \
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE (args)
/* Work around GCC bug 59600: when a function is inlined, the inlined
code may have its addresses sanitized even if the function has the
diff --git a/src/dynlib.h b/src/dynlib.h
index ac3d8e58ab..03b8f98356 100644
--- a/src/dynlib.h
+++ b/src/dynlib.h
@@ -20,6 +20,7 @@
#ifndef DYNLIB_H
#define DYNLIB_H
+#include <attribute.h>
#include <stdbool.h>
typedef void *dynlib_handle_ptr;
diff --git a/src/lisp.h b/src/lisp.h
index deeca9bc86..778bd1bfa5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -31,6 +31,7 @@ #define EMACS_LISP_H
#include <inttypes.h>
#include <limits.h>
+#include <attribute.h>
#include <intprops.h>
#include <verify.h>
diff --git a/src/syssignal.h b/src/syssignal.h
index 07055c04be..02fe44a382 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -22,6 +22,8 @@ #define EMACS_SYSSIGNAL_H
#include <signal.h>
+#include <attribute.h>
+
extern void init_signals (void);
extern void block_child_signal (sigset_t *);
extern void unblock_child_signal (sigset_t const *);
diff --git a/src/sysstdio.h b/src/sysstdio.h
index 5bcfe7d8a5..727a466be5 100644
--- a/src/sysstdio.h
+++ b/src/sysstdio.h
@@ -24,7 +24,9 @@ #define EMACS_SYSSTDIO_H
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
-#include "unlocked-io.h"
+
+#include <attribute.h>
+#include <unlocked-io.h>
extern FILE *emacs_fopen (char const *, char const *) ATTRIBUTE_MALLOC;
extern void errputc (int);
diff --git a/src/systhread.h b/src/systhread.h
index fb1a0a72d6..bf4e0306cd 100644
--- a/src/systhread.h
+++ b/src/systhread.h
@@ -21,6 +21,8 @@ #define SYSTHREAD_H
#include <stdbool.h>
+#include <attribute.h>
+
#ifdef THREADS_ENABLED
#ifdef HAVE_PTHREAD
diff --git a/src/tparam.h b/src/tparam.h
index 6361f138ea..653f01bdde 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -20,6 +20,8 @@ Copyright (C) 2011-2022 Free Software Foundation, Inc.
#ifndef EMACS_TPARAM_H
#define EMACS_TPARAM_H
+#include <attribute.h>
+
/* Don't try to include termcap.h. On some systems, configure finds a
non-standard termcap.h that the main build won't find. */
--
2.35.1
[-- Attachment #3: 0002-Decouple-mod-test.c-from-Gnulib.patch --]
[-- Type: text/x-patch, Size: 11185 bytes --]
From 3b86bc162cca1991a1ce66445e5d8f0d8f3bc7b2 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 8 Mar 2022 18:46:47 -0800
Subject: [PATCH 2/2] Decouple mod-test.c from Gnulib
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
mod-test.c should not use Gnulib code, as that creates
unnecessary coupling between Emacs internals and this test module.
Also Gnulib code is compiled without -fPIC whereas mod-test.c
needs -fPIC and recompiling Gnulib with -fPIC would be too painful.
* src/Makefile.in (LIB_NANOSLEEP): New macro.
(LIBES): Use it.
* test/Makefile.in (REPLACE_FREE, FREE_SOURCE_0, FREE_SOURCE_0):
Remove. All uses removed.
(LIB_CLOCK_GETTIME, LIB_NANOSLEEP): New macros.
(MODULE_CFLAGS): Do not -I from lib as that would include Gnulib
modifications to standard .h files (e.g., "#define nanosleep
rpl_nanosleep") and we don’t want the Gnulib replacements.
Instead, for gmp.h (on platforms lacking <gmp.h>) simply '-I.'
with a suitable gmp.h.
(gmp.h): New rule to create a suitable gmp.h.
($(test_module)): Depend on config.h since the code uses config.h.
Depend on gmp.h if we need to create a suitable one.
If compiling mini-gmp.h, compile the original one and not
the Emacs-specific one, to lessen coupling with Emacs internals.
Link with LIB_CLOCK_GETTIME and LIB_NANOSLEEP.
(clean): Remove gmp.h.
* test/src/emacs-module-resources/mod-test.c: Don’t include timespec.h.
All uses of timespec.h APIs changed to use system-supplied APIs.
Change _Static_assert to plain assert, so that we needn’t rely
on Gnulib’s _Static_assert.
(timespec_le) [CLOCK_REALTIME]: New function.
Change use of timespec_cmp changed to use this instead.
(Fmod_test_sleep_until, Fmod_test_nanoseconds):
Define these functions and their Lisp names mod-test-sleep-until
and mod-test-nanoseconds only if CLOCK_REALTIME,
since they now won’t work on platforms lacking CLOCK_REALTIME.
(Fmod_test_nanoseconds): Just use _Static_assert since it
should work on all platforms.
* test/src/emacs-module-tests.el (mod-test-sleep-until)
(mod-test-nanoseconds, mod-test-double):
Skip test if the corresponding functione is not defined.
---
src/Makefile.in | 3 +-
test/Makefile.in | 22 ++++++------
test/src/emacs-module-resources/mod-test.c | 42 ++++++++++++++--------
test/src/emacs-module-tests.el | 3 ++
4 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/src/Makefile.in b/src/Makefile.in
index 3353fb16d7..2b7c4bb316 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -146,6 +146,7 @@ M17N_FLT_LIBS =
LIB_ACL=@LIB_ACL@
LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@
LIB_EACCESS=@LIB_EACCESS@
+LIB_NANOSLEEP=@LIB_NANOSLEEP@
LIB_TIMER_TIME=@LIB_TIMER_TIME@
DBUS_CFLAGS = @DBUS_CFLAGS@
@@ -548,7 +549,7 @@ lisp =
LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(PGTK_LIBS) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
- $(WEBKIT_LIBS) \
+ $(LIB_NANOSLEEP) $(WEBKIT_LIBS) \
$(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
$(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
$(XDBE_LIBS) $(XSYNC_LIBS) \
diff --git a/test/Makefile.in b/test/Makefile.in
index 79d3dcf92f..3b6e116e65 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -49,8 +49,6 @@ SEPCHAR =
HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@
-REPLACE_FREE = @REPLACE_FREE@
-
-include ${top_builddir}/src/verbose.mk
# We never change directory before running Emacs, so a relative file
@@ -265,27 +263,29 @@ FPIC_CFLAGS =
GMP_H = @GMP_H@
LIBGMP = @LIBGMP@
+LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
+LIB_NANOSLEEP = @LIB_NANOSLEEP@
-MODULE_CFLAGS = -I../src -I$(srcdir)/../src -I../lib -I$(srcdir)/../lib \
+MODULE_CFLAGS = $(and $(GMP_H),-I.) -I../src -I$(srcdir)/../src \
$(FPIC_CFLAGS) $(PROFILING_CFLAGS) \
$(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
+gmp.h:
+ echo '#include "$(srcdir)/../lib/mini-gmp.h"' >$@
+
test_module = $(test_module_dir)/mod-test${SO}
src/emacs-module-tests.log src/emacs-module-tests.elc: $(test_module)
-FREE_SOURCE_0 =
-FREE_SOURCE_1 = $(srcdir)/../lib/free.c
-
# In the compilation command, we can't use any object or archive file
# as source because those are not compiled with -fPIC. Therefore we
# use only source files.
-$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h
+$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h \
+ ../src/config.h $(and $(GMP_H),gmp.h)
$(AM_V_CCLD)${MKDIR_P} $(dir $@)
$(AM_V_at)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
-o $@ $< $(LIBGMP) \
- $(and $(GMP_H),$(srcdir)/../lib/mini-gmp-gnulib.c) \
- $(FREE_SOURCE_$(REPLACE_FREE)) \
- ../lib/libgnu.a
+ $(and $(GMP_H),$(srcdir)/../lib/mini-gmp.c) \
+ $(LIB_CLOCK_GETTIME) $(LIB_NANOSLEEP)
endif
src/emacs-tests.log: ../lib-src/seccomp-filter.c
@@ -345,7 +345,7 @@ clean:
find . '(' -name '*.xml' -a ! -path '*resources*' ')' $(FIND_DELETE)
rm -f ${srcdir}/lisp/gnus/mml-sec-resources/random_seed
rm -f $(test_module_dir)/*.o $(test_module_dir)/*.so \
- $(test_module_dir)/*.dll
+ $(test_module_dir)/*.dll gmp.h
bootstrap-clean: clean
find $(srcdir) -name '*.elc' $(FIND_DELETE)
diff --git a/test/src/emacs-module-resources/mod-test.c b/test/src/emacs-module-resources/mod-test.c
index 015c1efd97..187af821c2 100644
--- a/test/src/emacs-module-resources/mod-test.c
+++ b/test/src/emacs-module-resources/mod-test.c
@@ -47,8 +47,6 @@
#include <gmp.h>
#include <emacs-module.h>
-#include "timespec.h"
-
int plugin_is_GPL_compatible;
#if INTPTR_MAX <= 0
@@ -74,9 +72,6 @@
# error "INTPTR_MAX too large"
#endif
-/* Smoke test to verify that EMACS_LIMB_MAX is defined. */
-_Static_assert (0 < EMACS_LIMB_MAX, "EMACS_LIMB_MAX missing or incorrect");
-
/* Always return symbol 't'. */
static emacs_value
Fmod_test_return_t (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
@@ -422,6 +417,16 @@ signal_errno (emacs_env *env, const char *function)
signal_system_error (env, errno, function);
}
+#ifdef CLOCK_REALTIME
+
+/* Whether A <= B. */
+static bool
+timespec_le (struct timespec a, struct timespec b)
+{
+ return (a.tv_sec < b.tv_sec
+ || (a.tv_sec == b.tv_sec && a.tv_nsec <= b.tv_nsec));
+}
+
/* A long-running operation that occasionally calls `should_quit' or
`process_input'. */
@@ -434,11 +439,13 @@ Fmod_test_sleep_until (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
if (env->non_local_exit_check (env))
return NULL;
const bool process_input = env->is_not_nil (env, args[1]);
- const struct timespec amount = make_timespec(0, 10000000);
+ const struct timespec amount = { .tv_nsec = 10000000 };
while (true)
{
- const struct timespec now = current_timespec ();
- if (timespec_cmp (now, until) >= 0)
+ struct timespec now;
+ if (clock_gettime (CLOCK_REALTIME, &now) != 0)
+ return NULL;
+ if (timespec_le (until, now))
break;
if (nanosleep (&amount, NULL) && errno != EINTR)
{
@@ -452,6 +459,7 @@ Fmod_test_sleep_until (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
}
return env->intern (env, "finished");
}
+#endif
static emacs_value
Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
@@ -553,6 +561,7 @@ make_big_integer (emacs_env *env, const mpz_t value)
return result;
}
+#ifdef CLOCK_REALTIME
static emacs_value
Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void *data) {
assert (nargs == 1);
@@ -560,11 +569,6 @@ Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void
mpz_t nanoseconds;
assert (LONG_MIN <= time.tv_sec && time.tv_sec <= LONG_MAX);
mpz_init_set_si (nanoseconds, time.tv_sec);
-#ifdef __MINGW32__
- _Static_assert (1000000000 <= ULONG_MAX, "unsupported architecture");
-#else
- static_assert (1000000000 <= ULONG_MAX, "unsupported architecture");
-#endif
mpz_mul_ui (nanoseconds, nanoseconds, 1000000000);
assert (0 <= time.tv_nsec && time.tv_nsec <= ULONG_MAX);
mpz_add_ui (nanoseconds, nanoseconds, time.tv_nsec);
@@ -572,6 +576,7 @@ Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void
mpz_clear (nanoseconds);
return result;
}
+#endif
static emacs_value
Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
@@ -631,7 +636,7 @@ sleep_for_half_second (void)
#ifdef WINDOWSNT
Sleep (500);
#else
- const struct timespec sleep = {0, 500000000};
+ const struct timespec sleep = { .tv_nsec = 500000000 };
if (nanosleep (&sleep, NULL) != 0)
perror ("nanosleep");
#endif
@@ -763,6 +768,11 @@ bind_function (emacs_env *env, const char *name, emacs_value Sfun)
int
emacs_module_init (struct emacs_runtime *ert)
{
+ /* These smoke tests don't use _Static_assert because too many
+ compilers lack support for _Static_assert. */
+ assert (0 < EMACS_LIMB_MAX);
+ assert (1000000000 <= ULONG_MAX);
+
/* Check that EMACS_MAJOR_VERSION is defined and an integral
constant. */
char dummy[EMACS_MAJOR_VERSION];
@@ -815,9 +825,13 @@ #define DEFUN(lsym, csym, amin, amax, doc, data) \
DEFUN ("mod-test-invalid-load", Fmod_test_invalid_load, 0, 0, NULL, NULL);
DEFUN ("mod-test-invalid-finalizer", Fmod_test_invalid_finalizer, 0, 0,
NULL, NULL);
+#ifdef CLOCK_REALTIME
DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL);
+#endif
DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL);
+#ifdef CLOCK_REALTIME
DEFUN ("mod-test-nanoseconds", Fmod_test_nanoseconds, 1, 1, NULL, NULL);
+#endif
DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL);
DEFUN ("mod-test-make-function-with-finalizer",
Fmod_test_make_function_with_finalizer, 0, 0, NULL, NULL);
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index ec83f91f00..1099fd0467 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -336,6 +336,7 @@ module/load-history
(ert-deftest mod-test-sleep-until ()
"Check that `mod-test-sleep-until' either returns normally or quits.
Interactively, you can try hitting \\[keyboard-quit] to quit."
+ (skip-unless (fboundp 'mod-test-sleep-until))
(dolist (arg '(nil t))
;; Guard against some caller setting `inhibit-quit'.
(with-local-quit
@@ -390,6 +391,7 @@ mod-test-add-nanosecond/invalid
(ert-deftest mod-test-nanoseconds ()
"Test truncation when converting to `struct timespec'."
+ (skip-unless (fboundp 'mod-test-nanoseconds))
(dolist (test-case '((0 . 0)
(-1 . -1000000000)
((1 . 1000000000) . 1)
@@ -408,6 +410,7 @@ mod-test-nanoseconds
(should (= (mod-test-nanoseconds input) expected))))))
(ert-deftest mod-test-double ()
+ (skip-unless (fboundp 'mod-test-double))
(dolist (input (list 0 1 2 -1 42 12345678901234567890
most-positive-fixnum (1+ most-positive-fixnum)
most-negative-fixnum (1- most-negative-fixnum)))
--
2.35.1
^ permalink raw reply related [flat|nested] 53+ messages in thread
end of thread, other threads:[~2022-03-09 3:01 UTC | newest]
Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-16 12:13 bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy Noam Postavsky
2018-08-16 12:49 ` Noam Postavsky
2018-08-16 13:41 ` Eli Zaretskii
2018-08-16 14:45 ` Noam Postavsky
2018-08-16 17:33 ` Eli Zaretskii
2018-08-17 1:02 ` Noam Postavsky
2018-08-17 5:59 ` Eli Zaretskii
2018-08-17 11:55 ` Noam Postavsky
2018-08-17 12:25 ` Eli Zaretskii
2018-08-17 22:10 ` Noam Postavsky
2018-08-18 6:34 ` Eli Zaretskii
2018-08-21 0:52 ` Noam Postavsky
2018-08-21 2:42 ` Eli Zaretskii
2022-02-21 15:20 ` Lars Ingebrigtsen
2022-02-23 19:45 ` Paul Eggert
2022-02-23 19:48 ` Lars Ingebrigtsen
2022-02-23 22:29 ` Paul Eggert
2022-02-23 22:40 ` Lars Ingebrigtsen
2022-02-24 3:09 ` Paul Eggert
2022-02-24 8:57 ` Lars Ingebrigtsen
2022-02-24 18:20 ` Paul Eggert
2022-02-25 2:19 ` Lars Ingebrigtsen
2022-02-25 2:27 ` Lars Ingebrigtsen
2022-02-25 20:41 ` Paul Eggert
[not found] ` <6f364184-7fa8-04f3-44a9-22ce40b872e8@cs.ucla.edu>
2022-02-26 15:12 ` Lars Ingebrigtsen
2022-02-26 15:37 ` Eli Zaretskii
[not found] ` <83ee3pprkr.fsf@gnu.org>
2022-02-26 16:04 ` Lars Ingebrigtsen
[not found] ` <87pmn9txzo.fsf@gnus.org>
2022-02-28 8:59 ` Lars Ingebrigtsen
[not found] ` <87ee3ns6x0.fsf@gnus.org>
2022-02-28 12:28 ` Eli Zaretskii
[not found] ` <83y21vmaye.fsf@gnu.org>
2022-02-28 12:31 ` Lars Ingebrigtsen
2022-02-28 12:35 ` Lars Ingebrigtsen
[not found] ` <877d9fnp7g.fsf@gnus.org>
2022-02-28 12:46 ` Eli Zaretskii
2022-02-28 21:47 ` Paul Eggert
[not found] ` <78c5037a-ac96-e7be-532f-b1776ed25b2b@cs.ucla.edu>
2022-03-01 15:36 ` Lars Ingebrigtsen
[not found] ` <87a6e9n0rg.fsf@gnus.org>
2022-03-01 18:27 ` Paul Eggert
[not found] ` <d0cfd485-2be6-5873-64dc-2926c2f2bae0@cs.ucla.edu>
2022-03-01 18:52 ` Lars Ingebrigtsen
[not found] ` <87czj5ld38.fsf@gnus.org>
2022-03-02 1:00 ` Paul Eggert
[not found] ` <d24b1278-1aeb-e17d-ed06-7d36c5e3b68b@cs.ucla.edu>
2022-03-02 1:22 ` Lars Ingebrigtsen
2022-03-02 1:43 ` Lars Ingebrigtsen
[not found] ` <87y21tjggy.fsf@gnus.org>
2022-03-02 2:12 ` Paul Eggert
[not found] ` <ab47871e-ad1e-e06d-c226-ab7b7c9bb857@cs.ucla.edu>
2022-03-03 13:46 ` Lars Ingebrigtsen
2022-03-03 13:49 ` Lars Ingebrigtsen
[not found] ` <87czj3jgdd.fsf@gnus.org>
2022-03-03 15:11 ` Eli Zaretskii
2022-03-04 15:28 ` Lars Ingebrigtsen
2022-03-04 16:47 ` Lars Ingebrigtsen
2022-03-04 19:46 ` Eli Zaretskii
2022-03-05 17:11 ` Lars Ingebrigtsen
2022-03-05 17:47 ` Eli Zaretskii
2022-03-05 18:06 ` Lars Ingebrigtsen
2022-03-09 3:01 ` Paul Eggert
[not found] ` <87h78fjgi7.fsf@gnus.org>
2022-03-03 21:40 ` Paul Eggert
[not found] ` <0756f1bd-1348-84ef-4eb8-4cc25eacf1dd@cs.ucla.edu>
2022-03-04 15:31 ` Lars Ingebrigtsen
2019-09-24 5:39 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).