diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-09-14 23:17:17 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-09-14 23:17:17 +0000 |
| commit | cdc2a0c6d1f03711aeb77fa1cb56ed9da4d85c5d (patch) | |
| tree | 732874411be9ecda4b0636f2d36c5dda3f1576b3 /usr.bin/cmp/regular.c | |
| parent | 91c68d8f0a7b40a948337e670bf1ce277ac0b0f5 (diff) | |
Notes
Diffstat (limited to 'usr.bin/cmp/regular.c')
| -rw-r--r-- | usr.bin/cmp/regular.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c index e791522a99be..f540ab4aebe8 100644 --- a/usr.bin/cmp/regular.c +++ b/usr.bin/cmp/regular.c @@ -71,18 +71,27 @@ c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2) eofmsg(file2); len2 -= skip2; + pagemask = (off_t)getpagesize() - 1; + off1 = ROUNDPAGE(skip1); + off2 = ROUNDPAGE(skip2); + length = MIN(len1, len2); if (length > SIZE_T_MAX) return (c_special(fd1, file1, skip1, fd2, file2, skip2)); if ((p1 = (u_char *)mmap(NULL, - (size_t)length, PROT_READ, 0, fd1, skip1)) == (u_char *)-1) + (size_t)length, PROT_READ, MAP_SHARED, fd1, off1)) == (u_char *)MAP_FAILED) err(ERR_EXIT, "%s", file1); + + madvise(p1, length, MADV_SEQUENTIAL); if ((p2 = (u_char *)mmap(NULL, - (size_t)length, PROT_READ, 0, fd2, skip2)) == (u_char *)-1) + (size_t)length, PROT_READ, MAP_SHARED, fd2, off2)) == (u_char *)MAP_FAILED) err(ERR_EXIT, "%s", file2); + madvise(p2, length, MADV_SEQUENTIAL); dfound = 0; + p1 += skip1 - off1; + p2 += skip2 - off2; for (byte = line = 1; length--; ++p1, ++p2, ++byte) { if ((ch = *p1) != *p2) if (lflag) { |
