X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_23,J_CHICKENPOX_43,J_CHICKENPOX_44,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Fri, 16 Jan 2009 15:10:35 +0000 Message-ID: Subject: Re: how to get mmap page size? From: Jay Foad To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Corinna Vinschen wrote: > mmap always allocates in 64K chunks. That doesn't seem to be true in practice. In the test below I mmap a 1080K file (this is a multiple of 4K but not a multiple of 64K). The first byte after the end of the file isn't readable. $ cat mmaptest.c #include #include #include #include int main(int argc, char *argv[]) { int fd; struct stat st; void *p; if (argc != 2) return 1; if ((fd = open(argv[1], O_RDONLY, 0)) < 0) return 1; if (fstat(fd, &st) != 0) return 1; if ((p = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED) return 1; printf("last byte 0x%02X\n", ((unsigned char *)p)[st.st_size - 1]); fflush(stdout); printf("next byte 0x%02X\n", ((unsigned char *)p)[st.st_size]); return 0; } $ gcc -o mmaptest mmaptest.c $ dd bs=1080K count=1 if=/dev/random of=foo 1+0 records in 1+0 records out 1105920 bytes (1.1 MB) copied, 0.077 s, 14.4 MB/s $ ./mmaptest foo last byte 0x5F 9 [main] mmaptest 3040 _cygtls::handle_exceptions: Error while dumping sta te (probably corrupted stack) Segmentation fault (core dumped) This is a recent cygwin installation on XP Pro SP2. Thanks, Jay. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/