From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12790 invoked by alias); 16 Jan 2009 15:11:13 -0000 Received: (qmail 12781 invoked by uid 22791); 16 Jan 2009 15:11:12 -0000 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 Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.246) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Jan 2009 15:10:37 +0000 Received: by rv-out-0708.google.com with SMTP id b17so1722373rvf.38 for ; Fri, 16 Jan 2009 07:10:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.141.129.14 with SMTP id g14mr1274529rvn.8.1232118635087; Fri, 16 Jan 2009 07:10:35 -0800 (PST) Date: Fri, 16 Jan 2009 16:11:00 -0000 Message-ID: Subject: Re: how to get mmap page size? From: Jay Foad To: cygwin@cygwin.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2009-01/txt/msg00498.txt.bz2 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/