The man page for mmap() says the size needs to be a multiple of getpagesize(). So in my code I call getpagesize() and adjust my lengths accordingly. klibc doesn't have getpagesize() implemented. Is it safe to call mmap() with arbritary lengths and assume the mmap will round up for you? Does this work on glibc too? If so, I can just eliminate my getpagesize() code. It turns out for VM86 support all I needed to do was copy a couple of header files into klibc. The code I am working from calls INT 113 directly. It would probably be cleaner to do this through a library call that automatically called the x86 emulator on other architectures. I'm able to compile with klibc now. Next I need to make sure everything works. static int vm86_rep(struct vm86_struct *ptr) { int __res; __asm__ __volatile__("int $0x80\n":"=a"(__res):"a"((int) 113), "b"((struct vm86_struct *) ptr)); if ((__res) < 0) { errno = -__res; __res = -1; } else errno = 0; return __res; } ====Jon Smirl jonsmirl@yahoo.com __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/
Jon Smirl wrote:> The man page for mmap() says the size needs to be a multiple of getpagesize(). > So in my code I call getpagesize() and adjust my lengths accordingly. klibc > doesn't have getpagesize() implemented. Is it safe to call mmap() with arbritary > lengths and assume the mmap will round up for you? Does this work on glibc too? > If so, I can just eliminate my getpagesize() code. >It's sort-of OK. I think klibc uses PAGE_SIZE as a compile-time constant. I probably should implement getpagesize() as an inline returning PAGE_SIZE. -hpa
On Sat, Jan 24, Jon Smirl wrote:> The man page for mmap() says the size needs to be a multiple of getpagesize(). > So in my code I call getpagesize() and adjust my lengths accordingly. klibc > doesn't have getpagesize() implemented. Is it safe to call mmap() with arbritary > lengths and assume the mmap will round up for you? Does this work on glibc too? > If so, I can just eliminate my getpagesize() code.Why do you depend on PAGE_SIZE as a compiletime option? It does depend on the used kernel .config on some architectures, like ia64. Current klibc fails to compile because of that. -- USB is for mice, FireWire is for men! sUse lINUX ag, n?RNBERG