[klibc] mmap and getpagesize

Jon Smirl jonsmirl at yahoo.com
Sat Jan 24 20:39:19 PST 2004


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 at yahoo.com

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/



More information about the klibc mailing list