From d2cf8d0afb490fbc109dad882a048102aabfa90c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 25 Sep 2025 11:31:27 +0300 Subject: [PATCH] Fix igc tests on MS-Windows * src/igc.c (Figc_info): Fix "commit-limit" value when there's no limit, and 'size_t' is narrower than 'intmax_t'. Doc fix. * test/src/igc-tests.el (set-commit-limit-test): Fix test for 32-bit builds. --- src/igc.c | 9 +++++++-- test/src/igc-tests.el | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/igc.c b/src/igc.c index fe8faf7b6dc..438aee08520 100644 --- a/src/igc.c +++ b/src/igc.c @@ -4796,7 +4796,8 @@ form (NAME NOBJECTS NBYTES LARGEST), where: In addition, there are several pseudo-objects which provide overall IGC statistics: - committed -- the amount of committed memory in bytes - - commit-limit -- max amount of memory the arena is allowed to commit + - commit-limit -- max amount of memory the arena is allowed to commit; + the value -1 means no limit - spare-committed -- memory which remains committed and which the arena is managing as free memory - reserved -- total address space reserved by the arena @@ -4833,7 +4834,11 @@ IGC statistics: result = Fcons (e, result); e = make_entry ("spare-committed", 1, mps_arena_spare_committed (gc->arena), 0); result = Fcons (e, result); - e = make_entry ("commit-limit", 1, mps_arena_commit_limit (gc->arena), 0); + size_t commit_limit = mps_arena_commit_limit (gc->arena); + /* Don't assume size_t and intmax_t are of the same width. */ + e = make_entry ("commit-limit", 1, + commit_limit == SIZE_MAX ? (intmax_t) -1 : commit_limit, + 0); result = Fcons (e, result); e = make_entry ("committed", 1, mps_arena_committed (gc->arena), 0); result = Fcons (e, result); diff --git a/test/src/igc-tests.el b/test/src/igc-tests.el index c81dde7ecd5..31c87d04397 100644 --- a/test/src/igc-tests.el +++ b/test/src/igc-tests.el @@ -32,8 +32,11 @@ '("commit-limit" 1 1073741824 0))) (should-error (igc--set-commit-limit -1) :type 'args-out-of-range) - (should-error (igc--set-commit-limit (- (ash 1 64) 1)) - :type 'args-out-of-range) + (should-error (igc--set-commit-limit + (if (< #x1fffffff most-positive-fixnum) + (- (ash 1 64) 1) + (- (ash 1 32) 1)) + :type 'args-out-of-range)) (should (equal (igc--set-commit-limit nil) nil)) (should (equal (assoc-string "commit-limit" (igc-info)) '("commit-limit" 1 -1 0))))