[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9e4e477 5/7: In pdumper, simplify INT_MAX computation
From: |
Paul Eggert |
Subject: |
master 9e4e477 5/7: In pdumper, simplify INT_MAX computation |
Date: |
Tue, 11 Aug 2020 05:27:51 -0400 (EDT) |
branch: master
commit 9e4e4775364490d31406f247237934dd7f203808
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
In pdumper, simplify INT_MAX computation
* src/pdumper.c (dump_read_all): Avoid unnecessary cast.
Also, round down to page size, as sysdep.c does.
Also, don’t assume INT_MAX <= UINT_MAX (!).
---
src/pdumper.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/pdumper.c b/src/pdumper.c
index 6d303af..fcad524 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -5065,14 +5065,13 @@ dump_read_all (int fd, void *buf, size_t bytes_to_read)
{
/* We don't want to use emacs_read, since that relies on the lisp
world, and we're not in the lisp world yet. */
- eassert (bytes_to_read <= SSIZE_MAX);
size_t bytes_read = 0;
while (bytes_read < bytes_to_read)
{
- /* Some platforms accept only int-sized values to read. */
- unsigned chunk_to_read = INT_MAX;
- if (bytes_to_read - bytes_read < chunk_to_read)
- chunk_to_read = (unsigned) (bytes_to_read - bytes_read);
+ /* Some platforms accept only int-sized values to read.
+ Round this down to a page size (see MAX_RW_COUNT in sysdep.c). */
+ int max_rw_count = INT_MAX >> 18 << 18;
+ size_t chunk_to_read = min (bytes_to_read - bytes_read, max_rw_count);
ssize_t chunk = read (fd, (char *) buf + bytes_read, chunk_to_read);
if (chunk < 0)
return chunk;
- master updated (0d0aad2 -> 25b4168), Paul Eggert, 2020/08/11
- master 53132c1 6/7: pdumper speed tweeks for hash tables, Paul Eggert, 2020/08/11
- master 23c1d5d 2/7: * src/fns.c (hash_table_rehash): Help the compiler a bit., Paul Eggert, 2020/08/11
- master 16a1664 1/7: Rehash hash tables eagerly after loading a dump, Paul Eggert, 2020/08/11
- master eeaef1a 4/7: Don’t needlessly convert to ‘unsigned’ in pdumper, Paul Eggert, 2020/08/11
- master 9e4e477 5/7: In pdumper, simplify INT_MAX computation,
Paul Eggert <=
- master 25b4168 7/7: pdumper avoid listing hash table contents, Paul Eggert, 2020/08/11
- master 5bd7b3c 3/7: * src/pdumper.c (pdumper_load): XSETVECTOR -> make_lisp_ptr., Paul Eggert, 2020/08/11