Skip to content

Fixes for LLP64 systems (i.e. Windows 64bit) - #6538

Open
fingolfin wants to merge 3 commits into
masterfrom
mh/llp64-fixes
Open

Fixes for LLP64 systems (i.e. Windows 64bit)#6538
fingolfin wants to merge 3 commits into
masterfrom
mh/llp64-fixes

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 29, 2026

Copy link
Copy Markdown
Member

This contains three commits which fix various issues on LLP64 systems (where sizeof(long)==4 yet sizeof(void*)==8).

  • blist: COUNT_TRUES_BLOCK used __builtin_popcountl, ignoring bits >= 32 of every block. Every filter with flag number above 32 looked empty, derailing the type system during library bootstrap -- the unexplained breakage in Fix Windows/MinGW compilation issues #6077. Now selects the popcount builtin matching UInt, like CLog2UInt does for clz.
  • integer: GMP's mpz_*_ui take unsigned long. GcdInt(<large>, 2^50) computed Gcd(x, 0) = 0, sending rational arithmetic into an infinite loop (a hang in ctblmoli.tst). GcdInt now uses mpn_gcd_1; FACTORIAL_INT errors and BINOMIAL_INT returns fail above ULONG_MAX.
  • system: 4096L*1024*1024 overflows a 32-bit long; compute the default pool sizes in UInt.

These are part of a port of GAP to MingW Claude Fable 5 wrote for me (see also issue #4157), but they are clearly of independent use, and therefore in a PR of their own.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

fingolfin and others added 2 commits August 29, 2026 01:54
4096L*1024*1024 overflows the 32-bit long of LLP64 systems (native
Windows); compute the default allocation pool sizes in UInt.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
COUNT_TRUES_BLOCK used __builtin_popcountl, whose argument type
'unsigned long' has only 32 bits on LLP64 systems such as native
Windows: bits at positions >= 32 of each block were silently not
counted. In particular, every filter with flag number above 32
appeared to have empty flags, which derailed the type system early
in the library bootstrap -- the mysterious breakage observed in
PR #6077. With this fix, GAP starts up and computes correctly on
native Windows (mingw).

Select the popcount builtin matching the size of UInt, the same way
CLog2UInt in integer.c already selects among the clz builtins.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@fingolfin fingolfin added os: windows Issues and PRs that are (at least partially) specific to Windows topic: kernel labels Aug 29, 2026
GMP's mpz_*_ui functions take 'unsigned long', which has only 32
bits on LLP64 systems (native Windows), so passing a UInt silently
truncates. In particular GcdInt(<large>, 2^50) returned Gcd(x,0)=0,
sending rational arithmetic into an infinite loop (found via a hang
in ctblmoli.tst).

- GcdInt: use mpn_gcd_1, whose small operand is an mp_limb_t
- FACTORIAL_INT: raise an error for n above ULONG_MAX (the result
  would be astronomically large anyway)
- BINOMIAL_INT: return Fail for k above ULONG_MAX, matching the
  existing policy for multi-limb k, and route n above ULONG_MAX
  through the mpz_bin_ui branch

No behavior change on LP64 systems.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.97%. Comparing base (989cc35) to head (31a20d6).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/integer.c 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6538      +/-   ##
==========================================
- Coverage   79.00%   78.97%   -0.03%     
==========================================
  Files         684      684              
  Lines      294205   294207       +2     
  Branches     8647     8673      +26     
==========================================
- Hits       232444   232363      -81     
- Misses      59955    60034      +79     
- Partials     1806     1810       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fingolfin fingolfin added the release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

os: windows Issues and PRs that are (at least partially) specific to Windows release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant