aboutsummaryrefslogtreecommitdiff
path: root/bin/dd/dd.h
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2018-11-29 19:28:01 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2018-11-29 19:28:01 +0000
commitdead7b5e47d14f6560c5be40e673664ba20c670f (patch)
treed35261be8adc5986baf73412030722df77b9435a /bin/dd/dd.h
parent7d2b0bd7d78a05f57adb96cc73a605d05938a037 (diff)
downloadsrc-dead7b5e47d14f6560c5be40e673664ba20c670f.tar.gz
src-dead7b5e47d14f6560c5be40e673664ba20c670f.zip
Replace hand-crafted naive byte-by-byte zero block detection routine
with macro based around memcmp(). The latter is expected to be some 8 times faster on a modern 64-bit architectures. In practice, throughput of doing conv=sparse from /dev/zero to /dev/null went up some 5-fold here from 1.9GB/sec to 9.7GB/sec with this change (bs=128k). MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=341257
Diffstat (limited to 'bin/dd/dd.h')
-rw-r--r--bin/dd/dd.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/dd/dd.h b/bin/dd/dd.h
index 0f7c680a6ee0..8090252923fd 100644
--- a/bin/dd/dd.h
+++ b/bin/dd/dd.h
@@ -103,3 +103,7 @@ typedef struct {
#define C_PROGRESS 0x40000000
#define C_PARITY (C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET)
+
+#define BISZERO(p, s) ((s) > 0 && *((const char *)p) == 0 && !memcmp( \
+ (const void *)(p), (const void *) \
+ ((const char *)p + 1), (s) - 1))