From 759ebcb57db73449b5670204f85931d34881b7d2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 16 Sep 2012 22:31:04 +0200 Subject: factor: merge with preexisting factor; integrate tests; avoid warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/factor.c: Renamed from factor-ng.c, with the following changes: Adjust copyright header to be consistent with others. Use xmalloc and xrealloc, to avoid segv upon OOM. Switch back to using readtokens to handle input. Diagnose invalid inputs. s/fprintf+exit/error/ (print_factors): Add comments. (strto2uintmax): Return strtol_error, not int. (read_item): Remove, no longer used. (main): Use atexit(close_stdout) so that we don't ignore failed write. * cfg.mk: Exempt src/longlong.h from several tests. Exempt run.sh from the test-list-consistency test. Exempt make-prime-list.c from numerous tests, since we won't be making it conform: it must not link with libcoreutils.a. Exempt factor-ng.c from the no-upper-case error message test. * AUTHORS (factor): Add Torbjörn and Niels. * tests/local.mk (factor_tests): Encode the 37 tests. ($(factor_tests)): Rule to generate a test script for each test. * tests/factor/run.sh: New script, marked as very expensive. * .gitignore: Ignore new generated files. * src/local.mk (src/primes.h): New rule. (noinst_PROGRAMS): Add make-prime-list. (noinst_HEADERS): Add longlong.h. Remove all wheel-related rules and files. * src/wheel-gen.pl: Remove file. maint: mark set-but-not-used variables with ATTRIBUTE_UNUSED * src/factor-ng.c (redcify, prime_p, isqrt2): Mark them, so we don't have to disable -Wunused-but-set-variable. maint: use __builtin_expect only if __GNUC__ * src/factor-ng.c (LIKELY, UNLIKELY) [__GNUC__]: Add #ifdef guard. build: avoid warning about unused macro * src/factor-ng.c (__GMP_DECLSPEC): Don't define here * src/longlong.h (__GMP_DECLSPEC): Define if not already defined. --- src/local.mk | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/local.mk') diff --git a/src/local.mk b/src/local.mk index 98259fa80..6a01ef1c7 100644 --- a/src/local.mk +++ b/src/local.mk @@ -35,7 +35,10 @@ bin_PROGRAMS = @bin_PROGRAMS@ pkglibexec_PROGRAMS = @pkglibexec_PROGRAMS@ # Needed by the testsuite. -noinst_PROGRAMS = src/setuidgid src/getlimits +noinst_PROGRAMS = \ + src/getlimits \ + src/make-prime-list \ + src/setuidgid noinst_HEADERS = \ src/chown-core.h \ @@ -48,20 +51,18 @@ noinst_HEADERS = \ src/fs-is-local.h \ src/group-list.h \ src/ioblksize.h \ + src/longlong.h \ src/ls.h \ src/operand2sig.h \ src/prog-fprintf.h \ src/remove.h \ src/system.h \ - src/wheel-size.h \ - src/wheel.h \ src/uname.h EXTRA_DIST += \ src/dcgen \ src/dircolors.hin \ src/tac-pipe.c \ - src/wheel-gen.pl \ src/extract-magic \ src/c99-to-c89.diff @@ -134,6 +135,12 @@ src_link_LDADD = $(LDADD) src_ln_LDADD = $(LDADD) src_logname_LDADD = $(LDADD) src_ls_LDADD = $(LDADD) + +# This must *not* depend on anything in lib/, since it is used to generate +# src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c +# into BUILT_SOURCES. +src_make_prime_list_LDADD = + src_md5sum_LDADD = $(LDADD) src_mkdir_LDADD = $(LDADD) src_mkfifo_LDADD = $(LDADD) @@ -371,19 +378,11 @@ src/dircolors.h: src/dcgen src/dircolors.hin $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ -wheel_size = 5 - -BUILT_SOURCES += src/wheel-size.h -src/wheel-size.h: Makefile.am - $(AM_V_GEN)rm -f $@ $@-t - $(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t - $(AM_V_at)chmod a-w $@-t - $(AM_V_at)mv $@-t $@ - -BUILT_SOURCES += src/wheel.h -src/wheel.h: src/wheel-gen.pl Makefile.am +BUILT_SOURCES += src/primes.h +CLEANFILES += src/primes.h +src/primes.h: src/make-prime-list $(AM_V_GEN)rm -f $@ $@-t - $(AM_V_at)$(srcdir)/src/wheel-gen.pl $(wheel_size) > $@-t + $(AM_V_at)src/make-prime-list 5000 > $@-t $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ -- cgit v1.2.3-54-g00ecf