# include "error.h"
# include "cksum.h"
-# if !USE_PCLMUL_CRC32
-# define cksum_pclmul cksum_slice8
-# endif /* USE_PCLMUL_CRC32 */
/* Number of bytes to read at once. */
# define BUFLEN (1 << 16)
-
-static bool
-cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
-static bool
- (*cksum_fp)(FILE *, uint_fast32_t *, uintmax_t *);
-
+# if USE_PCLMUL_CRC32
static bool
pclmul_supported (void)
{
-# if USE_PCLMUL_CRC32
bool pclmul_enabled = (0 < __builtin_cpu_supports ("pclmul")
&& 0 < __builtin_cpu_supports ("avx"));
: _("pclmul support not detected")));
return pclmul_enabled;
-# else
- if (cksum_debug)
- error (0, 0, "%s", _("using generic hardware support"));
- return false;
-# endif /* USE_PCLMUL_CRC32 */
}
+# endif /* USE_PCLMUL_CRC32 */
static bool
cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
uintmax_t total_bytes = 0;
uint_fast32_t crc = 0;
+# if USE_PCLMUL_CRC32
+ static bool (*cksum_fp) (FILE *, uint_fast32_t *, uintmax_t *);
if (! cksum_fp)
- {
- if (pclmul_supported ())
- cksum_fp = cksum_pclmul;
- else
- cksum_fp = cksum_slice8;
- }
+ cksum_fp = pclmul_supported () ? cksum_pclmul : cksum_slice8;
+#else
+ bool (*cksum_fp) (FILE *, uint_fast32_t *, uintmax_t *) = cksum_slice8;
+#endif
if (! cksum_fp (stream, &crc, &total_bytes))
return -1;
/* Size of atomic reads. */
#define BUFFER_SIZE (16 * 1024)
-static bool
-wc_lines (char const *file, int fd, uintmax_t *lines_out,
- uintmax_t *bytes_out);
#ifdef USE_AVX2_WC_LINECOUNT
/* From wc_avx2.c */
extern bool
wc_lines_avx2 (char const *file, int fd, uintmax_t *lines_out,
uintmax_t *bytes_out);
#endif
-static bool
-(*wc_lines_p) (char const *file, int fd, uintmax_t *lines_out,
- uintmax_t *bytes_out) = wc_lines;
static bool debug;
else if (!count_chars && !count_complicated)
{
#ifdef USE_AVX2_WC_LINECOUNT
- if (avx2_supported ())
- wc_lines_p = wc_lines_avx2;
+ static bool (*wc_lines_p) (char const *, int, uintmax_t *, uintmax_t *);
+ if (!wc_lines_p)
+ wc_lines_p = avx2_supported () ? wc_lines_avx2 : wc_lines;
+#else
+ bool (*wc_lines_p) (char const *, int, uintmax_t *, uintmax_t *)
+ = wc_lines;
#endif
/* Use a separate loop when counting only lines or lines and bytes --