From: Paul Eggert <eggert@cs.ucla.edu>
To: Noam Postavsky <npostavs@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Strange code in emacs.c
Date: Wed, 3 Oct 2018 15:59:10 -0700 [thread overview]
Message-ID: <cbbe0122-610d-568d-a380-ac445890ee35@cs.ucla.edu> (raw)
In-Reply-To: <CAM-tV-9oZV8CVo5UatuhVUjGFs4qp+hHnQdR6oNih0Z5VQVrrg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 71 bytes --]
Thanks for checking; I installed the attached into the master branch.
[-- Attachment #2: 0001-Fix-emacs_re_safe_alloca-calculation.patch --]
[-- Type: text/x-patch, Size: 1268 bytes --]
From 8026f11696430bfdf6b38a4eef4cbf9e337cc947 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 3 Oct 2018 15:55:43 -0700
Subject: [PATCH] Fix emacs_re_safe_alloca calculation
Problem and draft fix noted by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-10/msg00022.html
* src/emacs.c (main): Fix arithmetic used in calculation
of emacs_re_safe_alloca.
---
src/emacs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/emacs.c b/src/emacs.c
index b1c96d1828..ddaaf3fed5 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -888,11 +888,11 @@ main (int argc, char **argv)
lim = newlim;
}
}
- /* If the stack is big enough, let regex-emacs.c more of it before
- falling back to heap allocation. */
- emacs_re_safe_alloca = max
- (min (lim - extra, SIZE_MAX) * (min_ratio / ratio),
- MAX_ALLOCA);
+ /* If the stack is big enough, let regex-emacs.c use more of it
+ before falling back to heap allocation. */
+ ptrdiff_t max_failures
+ = min (lim - extra, min (PTRDIFF_MAX, SIZE_MAX)) / ratio;
+ emacs_re_safe_alloca = max (max_failures * min_ratio, MAX_ALLOCA);
}
#endif /* HAVE_SETRLIMIT and RLIMIT_STACK and not CYGWIN */
--
2.17.1
prev parent reply other threads:[~2018-10-03 22:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-03 15:15 Strange code in emacs.c Eli Zaretskii
2018-10-03 17:36 ` Paul Eggert
2018-10-03 17:42 ` Eli Zaretskii
2018-10-03 18:29 ` Paul Eggert
2018-10-03 22:12 ` Noam Postavsky
2018-10-03 22:59 ` Paul Eggert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbbe0122-610d-568d-a380-ac445890ee35@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=npostavs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.