1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00
Commit Graph

30737 Commits

Author SHA1 Message Date
Paul Eggert
831623ba66 factor: switch from mp to single when doable
This significantly improves performance when a number exceeds
2**(W_TYPE_SIZE - 1) and is the product of a prime less than
FIRST_OMITTED_PRIME and another prime less than 2**(W_TYPE_SIZE - 1).
On my platform, for example, it doubled the speed of factoring
4999 * (2**128 - 159).
* src/factor.c (mp_size, mp_finish_in_single): New functions.
(mp_factor_using_division, mp_factor_using_pollard_rho):
Finish using single precision when possible.
* tests/factor/factor.pl (lt-5000-times-128-bit): New test.
2025-07-09 17:12:39 -07:00
Paul Eggert
845f3a6158 factor: primes_diff idx type consistency
* src/factor.c (factor_insert_refind):
Use idx_t for indexes into primes_diff,
for consistency with other indexes into primes_diff.
This has no practical effect unless the primes_diff
table becomes unreasonably large.
2025-07-09 17:12:39 -07:00
Paul Eggert
fd458798fe factor: omit q from mp_factor_using_division
* src/factor.c (mp_factor_using_division): Remove unused local.
2025-07-09 17:12:39 -07:00
Paul Eggert
64b860c2f7 factor: mp insert multiplicity too
Support a multiplicity argument in the mp case, too.
This helps keeps the two cases in sync, for maintenance.
* src/factor.c (mp_factor_insert, mp_factor_insert_ui):
New arg M, for multiplicity.  All callers changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
258392808c factor: prefer non-macros
Use something other than a macro when that is easy and won’t hurt
performance.
* src/factor.c (__ll_B, __ll_lowpart, _ll_highpart) [!USE_LONGLONG_H]:
(MAX_NFACTS, highbit_to_mask, factor_insert, PRIMES_PTAB_ENTRIES):
Make these enums, or constants, or static functions instead of macros.
(highbit_to_mask): Rename from HIGHBIT_TO_MASK.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
fe136a9800 factor: let builder specify MR_REPS
* src/factor.c (MR_REPS): Let the builder specify it
with -DMR_REPS=whatever.
2025-07-09 17:12:39 -07:00
Paul Eggert
3e438e369c factor: add comments 2025-07-09 17:12:39 -07:00
Paul Eggert
77717f597e factor: factor insertion simplifications
* src/factor.c (factor_insert_multiplicity):
Adjust to keep in sync with mp_factor_insert changes below,
by adding 1 to the index and using memmove to move.
(mp_factor_insert): Omit redundant call to mpz_cmp.
Prefer idx_t (always nonnegative) to ptrdiff_t,
by adding 1 to the indexes.
Prefer mpz_init_set to mpz_init+mpz_set.
Use memmove to move, rather than doing it by hand.
2025-07-09 17:12:39 -07:00
Paul Eggert
374f5fdcc1 factor: check unsigned char counts
* src/factor.c (MAX_NFACTS): Allow word size of 128 bits,
even if this is only theoretical now.
Check that struct factors’s unsigned char counts won’t overflow.
2025-07-09 17:12:39 -07:00
Paul Eggert
5ae141ae14 factor: fix comment 2025-07-09 17:12:39 -07:00
Paul Eggert
a25d188098 factor: paren cleanup
* src/factor.c (umul_ppmm, udiv_qrnnd, addmod, addmod2, submod2)
(binv, divexact_21, redcify2, div_smallq): Omit unnecessary parens.
2025-07-09 17:12:39 -07:00
Paul Eggert
f14ddcb1ef factor: simplify longlong.h setup
* src/factor.c (USE_LONGLONG_H):
Default to false on unusual (but standard-conforming)
platforms that lack int64_t etc.
(UWtype, UHWtype): Now typedefs, not macros.
(UQItype): Remove.
(SItype, USItype, DItype, UDItype): Use standard C types.
2025-07-09 17:12:39 -07:00
Paul Eggert
0a5d071967 factor: prefer uuint to two words in a couple of places
This simplifies things slightly by using uuint for
some two-word integers.
* src/factor.c (strtouuint): Accept uuint *, not two mp_limb_t *.
All callers changed.
(print_factors_single): Accept uuint, not two limbs.
All callers changed.
(print_factors): Use simpler test for high bit,
one that need not worry about promoting to int.
2025-07-09 17:12:39 -07:00
Paul Eggert
59421d373b factor: FALLTHROUGH instead of break
* src/factor.c (print_factors): Use FALLTHROUGH
to make it clear that the "Use GMP" comment also applies here.
2025-07-09 17:12:39 -07:00
Paul Eggert
e7c1abfe79 factor: remove wide_uuint
Simplify by using GMP’s word type instead of pretending to roll our own.
* src/factor.c (wide_uuint): Remove.  All uses replaced by mp_limb_t.
(umul_ppmm) [!umul_ppmm]: Don’t assume unsigned long is at least half
as wide as mp_limb_t.  This simpler anyway.
(strtouuint): Rename from strto2wide_uint.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
d6ee61e407 factor: use same word size as GMP
Remove experimental code for 128-bit words as it does not work and
we lack time to figure out why.  Instead, ensure that words are
the same size as with GMP.
* src/factor.c (USE_INT128): Remove.  All uses removed.
(wide_uint, W_TYPE_SIZE): Define to be the same as GMP.
(MP_LIMB_MAX): New macro.  Check that it matches W_TYPE_SIZE.
(USE_LONGLONG_H): Default to true.
(UHWtype) [USE_LONGLONG_H]: Define to unsigned int, same as GMP.
(prime_p): Go back to not worrying about 128-bit words,
since GMP doesn’t worry and doesn’t use them.
(lbuf_putbitcnt): New function, since we cannot assume
that bitcnt_t fits into mp_limb_t.
(print_factors): Use it.
* src/make-prime-list.c (output_primes):
Don’t assume that wide_uint’s maximum is UINTMAX_MAX.
2025-07-09 17:12:39 -07:00
Paul Eggert
c8af57b5b8 factor: unsigned long → mp_bitcnt_t
* src/factor.c (struct mp_factors): e (multiplicity) member
is now of type mp_bitcnt_t, not unsigned long int, since
its value is at most a bit count.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
badc24c30c factor: fix test case name
* tests/factor/factor.pl (bug-gmp-plus_2_sup_127_plus_1):
Rename from bug-gmp-plus_2_sup_128_plus_1, so that
it accurately reflects the test case.
2025-07-09 17:12:39 -07:00
Paul Eggert
bdccb27ca6 factor: generalize BIG_POWER_OF_10
* src/factor.c (BIG_POWER_OF_10, LOG_BIG_POWER_OF_10):
Place fewer restrictions on BIG_POWER_OF_10.
This is only for currently-theoretical hosts;
it shouldn’t affect machine code on practical platforms.
2025-07-09 17:12:39 -07:00
Paul Eggert
88cca5d5fc factor: remove wide_int
* src/factor.c (wide_int): Remove, since it gets in the
way of using mp_limb_t for words.  All uses removed.
(submod2, HIGHBIT_TO_MASK, divexact_21):
Rewrite without using wide_int.
This shouldn't change the machine code these days,
as compilers are pretty smart about isolating the
top bit of an unsigned int.
2025-07-09 17:12:39 -07:00
Paul Eggert
397d9b02a3 factor: add platform sanity check
* src/factor.c: Check against theoretical platform.
2025-07-09 17:12:39 -07:00
Paul Eggert
8ff11d626b factor: squfof cleanup
* src/factor.c (USE_SQUFOF, STAT_SQUFOF):
Assume these are always false, and simplify the code accordingly.
We can bring it back later if needed be.
2025-07-09 17:12:39 -07:00
Paul Eggert
d7fd90d22d factor: don’t used uninitialized uu[0]
In practice there’s no bug but we might as well avoid the
undefined behavior.
* src/factor.c (hi_is_set): New static function.
(factor_insert_large, prime2_p, print_factors_single): Use it.
2025-07-09 17:12:39 -07:00
Pádraig Brady
fd59e4a955 build: avoid make distcheck error
* src/local.mk: Similarly to commit v8.22-156-g09937e9d0
track speedlist.h with nodist_src_stty_SOURCES and DISTCLEANFILES
to ensure the make distcheck manifest comparison passes.
Addresses https://bug.gnu.org/78960
2025-07-05 22:14:08 +01:00
Collin Funk
2230933f84 doc: fix a dead link
* doc/coreutils.texi (Block Size): Use an updated link to SI prefixes.
2025-07-05 09:57:29 -07:00
Pádraig Brady
1485eabfdd build: fix non parallel VPATH builds
* src/local.mk: Use the coarser BUILT_SOURCES mechanism
to generate speedlist.h, rather than a specific dependency
(which did seem to work for parallel builds).
Fixes https://bugs.gnu.org/78960
2025-07-05 12:49:02 +01:00
Collin Funk
e34a79a034 maint: prefer endian.h macros to WORDS_BIGENDIAN, part 2
* src/blake2/blake2-impl.h: Include endian.h. Use BYTE_ORDER and
LITTLE_ENDIAN instead of WORDS_BIGENDIAN.
2025-07-04 20:52:37 -07:00
Collin Funk
991934d9c9 maint: prefer endian.h macros to WORDS_BIGENDIAN
* src/od.c: Include endian.h.
(WORDS_BIGENDIAN): Remove definition.
(main): Use BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN instead of
WORDS_BIGENDIAN. Fix formatting.
2025-07-04 10:59:39 -07:00
Collin Funk
4db08f928e maint: add files generated by 'make ps' to .gitignore
* doc/.gitignore (/coreutils.ps, /coreutils.t2d/): Add entries.
2025-07-02 19:01:27 -07:00
Collin Funk
9cb89ff084 doc: remove outdated TODO/FIXME items
* TODO: Remove note about missing documentation for 'pinky' and '['.
* doc/coreutils.texi: Likewise.
2025-07-02 18:51:02 -07:00
Pádraig Brady
8771957703 tests: cat: add test for O_APPEND bug fix
* tests/cat/cat-self.sh: Add a test case
for commit v9.6-19-g7386c291b
2025-07-01 23:32:31 +01:00
Pádraig Brady
ab21f2e95e doc: remove extraneous double quotes within @samp{}
* doc/coreutils.texi (df invocation): @samp{} items
are suitably quoted already.
2025-07-01 12:02:08 +01:00
Collin Funk
1535ac272e doc: use ``...'' instead of "..."
* doc/coreutils.texi (split invocation): Use ``...'' for quoting text.
(cksum common options): Likewise.
(Control): Likewise.
2025-06-30 19:50:58 -07:00
Pádraig Brady
0512608a44 tests: avoid false failure due to varied ERANGE errors
* tests/od/od.pl: Use the system error string for ERANGE,
rather than hardcoding a particular one.
Fixes https://bugs.gnu.org/78934
2025-07-01 00:03:30 +01:00
Paul Eggert
48281e56a3 od: port to Apple clang 14
* src/od.c (print_function_type): New type.  Use it for convenience.
(width_bytes): Omit duplicate entries, such as ‘double’ vs ‘long
double’ on macOS.  Problem reported by Bruno Haible
<https://bugs.gnu.org/78933>.
(decode_one_format): Cast null pointer to print_function_type
to pacify Apple clang-1400.0.29.202.
2025-06-30 15:41:47 -07:00
Pádraig Brady
017fc50bb6 build: fix VPATH builds with --enable-single-binary
* src/local.mk: Adjust the dependency so that speedlist.h
is built irrespective of the object file name.
Note we could use BUILT_SOURCES for this,
but it's better to have this more accurate dependency.
2025-06-30 16:03:44 +01:00
Pádraig Brady
87dcd447b1 od: reinstate half float validation check
Reinstate check removed in commit 56aa549a0 so that we
disallow -f2 when configured with utils_cv_ieee_16_bit_supported=no.
Otherwise the output routines will consume floats,
i.e. 4 bytes at a time.  Without this extra check
the tests/od/od-endian.sh will fail with this configuration.

* src/od.c (decode_one_format): Reinstate the explicit check
for this configuration edge case.
2025-06-30 14:34:55 +01:00
Pádraig Brady
9075b2b8d2 maint: avoid sc_prohibit-quotearg failure
* src/od.c (parse_old_offset): s/quotearg_colon/quotef/.
2025-06-30 13:10:59 +01:00
Paul Eggert
5c5f069a4c od: add test cases for recent fix
* tests/od/od.pl: New tests for the offset issues
2025-06-29 22:32:05 -07:00
Paul Eggert
9002c04ccc od: more minor fixes for offsets
* src/od.c (parse_old_offset): Reject invalid offsets like "++0".
Treat overflowing offsets as errors, not as file names.
2025-06-29 22:26:14 -07:00
Paul Eggert
617220e970 od: refactor parse_old_offset
* src/od.c (parse_old_offset): Refactor for brevity and clarity.
2025-06-29 22:26:14 -07:00
Paul Eggert
3eb731e8ab maint: fix version in NEWS
* NEWS: Update version number as per Jim Meyering
<https://bugs.gnu.org/78880#46>.
2025-06-29 17:14:48 -07:00
Paul Eggert
dcdb2550c4 od: pacify gcc -Wduplicated-cond
Problem reported by Pádraig Brady <https://bugs.gnu.org/78880#43>.
This patch doesn’t fix any bugs; it merely pacifies GCC.
* src/od.c (ispec_to_format): New function, replacing
the old ISPEC_TO_FORMAT macro.  All uses changed.
This part of the change is just refactoring.
(decode_one_format): Pacify à la ispec_to_format.
2025-06-29 17:14:48 -07:00
Paul Eggert
25454fa34d od: be more consistent re sizeof
* src/od.c (width_bytes, decode_one_format): Don’t assume a signed
type has the same size as the corresponding unsigned type.
This has no effect on practical platforms; it’s just for
consistency there.
2025-06-28 21:00:41 -07:00
Paul Eggert
d5ea5e8aed od: fix integer overflow with large pseudos
* src/od.c (format_address_label): Diagnose overflow.
2025-06-28 21:00:41 -07:00
Paul Eggert
667be269ed od: speed up -S
* src/od.c (read_char): Use getc, not fgetc.
2025-06-28 21:00:41 -07:00
Paul Eggert
984dcc37f2 od: check sign bit more often
* src/od.c (read_char, dump_strings, main):
Instead of testing for an exact negative number,
just look at the sign bit.  This is a very minor tweak.
2025-06-28 21:00:41 -07:00
Paul Eggert
9aab4fb287 od: simplify away one loop copy
* src/od.c (dump): Coalesce two loops into one.
2025-06-28 21:00:41 -07:00
Paul Eggert
34b5043c6e od: simpler static initialization
* src/od.c (address_base, address_pad_len, format_address):
Initialize statically rather than dynamically.
(limit_bytes_to_format): Remove.  All uses replaced by
checking sign of end_offset.
(max_bytes_to_format): Remove static var.  Now local to ‘main’.
(end_offset): -1 now means no limit.  All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
0e104647a7 od: minor lcm tuning
* src/od.c (dump, main): Redo lcm calcuations to avoid a multiply.
2025-06-28 21:00:41 -07:00