site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: q=dns; a=rsa-sha1; c=nofws; s=test; d=omniti.com; h=Received:In-Reply-To:References:Mime-Version:Content-Type:Message-Id:Cc:Content-Transfer-Encoding:From:Subject:Date:To:X-Mailer; b=QXN9J6kipwGqdzsuSVcDO5WK+SF2ncvhNQjLRd2TUC76jZk4+I6qFwsQMQawG7Or UlG1uE0wWdgDMjQmx1gnGmga/W2VreNwsTU4Ogp2oPahb9WmnKb6uy2UlhbgKsJu Domainkey-status: good On Feb 13, 2006, at 11:31 PM, Mike Smith wrote: On Feb 13, 2006, at 3:04 PM, darwin-dev-request@lists.apple.com wrote: I'm porting an app that uses mmap() and banks on its alignment behaviour on Solaris and Linux. I'd like to mmap a 64k and have the resulting address be aligned on a 64k boundary. I'm trying with: mmap((void *)65536, 65536, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_ALIGN, -1, 0); MAP_ALIGN is not supported on Mac OS X. Thanks everyone for the replies. // Theo Schlossnagle // Principal Engineer -- http://www.omniti.com/~jesus/ // OmniTI Computer Consulting, Inc. -- http://www.omniti.com/ // Ecelerity: Run with it. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This is almost always guaranteed to fail, as you are trying to map *at* 64KB, and normally you will find your program's text mapped around there. However, the return address is not modulo 64k. How do I accomplish what I want? Well now, what is it, specifically, that you think you want? Why is a virtual address modulo 64K important? (Pointer overloading?) One approach would be to use vm_allocate to allocate an N + 64K sized chunk, round the base address up to the next boundary, free the chunk and then mmap with that address as a hint. Unless you have activity elsewhere (on e.g. another thread) in your app, that's pretty safe). What I am attempting to do it port Solaris' super-scalable slab sllocator (libumem) to Darwin. We have a product that runs ons on a variety of architecture that leverages a custom allocator for performance and uniformity. The Solaris would seems a bit better than ours and we wanted to adopt it while still having a consistent allocator across all platforms. Using the vm_map() directly may be one approach. We already use pthread_mach_thread_np in part of the porting effort. As it will be allocating a tremendous amount of memory and efficient use is a goal, over-allocating and doing alignment ourselves isn't the right approach. This email sent to site_archiver@lists.apple.com