Re: fuword(), suword(), etc.

From: Pawel Jakub Dawidek <nick_at_garage.freebsd.pl>
Date: Thu, 24 Jul 2003 10:28:10 +0200
On Wed, Jul 23, 2003 at 02:48:41PM -0700, Julian Elischer wrote:
+> I'd like to have a "suptr and fuptr" to be able to save and read
+> user pointers in a "machine independent" manner..
+> at the moment ia need to know the size of a pointer and select the
+> appropriate 32 or 64 version.. It would jus tbe another ENTRY files in 
+> support.[sS] alongside teh appropriate sized entry
+> for each architecture so it wouldn't 'cost' anything..
+> 
+> for i386 it would be an alternate name for fuword32() and suword32()
+> I'm not sure what it would be on other architectures....
+> 
+> comments?

Yes, good idea. I'm using for now something like this:

static __inline void *
fuptr(void *uaddr)
{
	void *ptr;

	if (copyin(uaddr, &ptr, sizeof(void *)) != 0)
		return ((void *)-1);

	return (ptr);
}

For numbers is always better to use copyin(9)/copyout(9). Functions
like fubyte(9), etc. make no sens for me. -1 is returned on error or
if there is really -1, so one isn't able to find out if there is an
error or not.

-- 
Pawel Jakub Dawidek                       pawel_at_dawidek.net
UNIX Systems Programmer/Administrator     http://garage.freebsd.pl
Am I Evil? Yes, I Am!                     http://cerber.sourceforge.net

Received on Wed Jul 23 2003 - 23:27:40 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:16 UTC