Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does madvise(2) work under OS X?



On Wed, 23 Oct 2002, Jim Magee wrote:

> On Wednesday, October 23, 2002, at 01:40  AM, Paul J. Lucas wrote:
> > 	Is madvise(2) broken under OS X ?
> 
> Can you provide a code snippet that causes this error?  It should work.

	It's something like this:

struct stat stat_buf;
int fd_;
void *addr_;

if ( ::stat( "/tmp/foo", &stat_buf ) == -1 ) {
	// ...
}
if ( ( fd_ = ::open( path, O_RDONLY ) ) == -1 ) {
	// ...
}
addr_ = mmap( 0, stat_buf.st_size, PROT_READ, MAP_SHARED, fd_, 0 );
if ( addr_ == MAP_FAILED ) {
	// ...
}
if ( madvise( addr_, size_, MADV_SEQUENTIAL ) == -1 ) {
	// ...
}

	- Paul
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.



References: 
 >Re: Does madvise(2) work under OS X? (From: Jim Magee <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.