Subject: Re: cacheflush() proposal
To: Chris G. Demetriou <>
From: Todd Whitesel <>
List: tech-userlevel
Date: 12/03/1998 01:37:47
> >      cacheflush(addr, nbytes, cache)
> >      char *addr;
> >      int nbytes, cache;
> "how do you flush all of memory?"
> no, addr == 0 and nbytes == INT_MAX won't do it.
> even if nbytes is unsigned and you use UINT_MAX, you lose.  8-)
> maybe 'unsigned long' or 'size_t' nbytes.

For that to work, either sizeof(nbytes) > sizeof(void *), or you disallow a
starting address of NULL.

Two complete solutions:

    1. addr,nbytes where ADDR is a start address pointer and NBYTES is the
	offset from ADDR to the last byte in the desired region (i.e. length-1).
	NBYTES can be any unsigned type whose sizeof == sizeof(void*).

    2. addr,endaddr which are two pointers, first and last address. Of course,
	you'd need a VOIDSTAR_MAX macro or guarantee that ~(void*)NULL worked.

> also, is there reason to use 'char *' rather than 'void *'?  the
> memory's type doesn't really matter...

char* in this context is only useful if people expect to mix this interface
with code that must be compiled using -traditional. Otherwise void* is the
correct choice -- it's practically the only new language feature that ANSI C
did entirely right. (Except that pointer arithmetic on void* wasn't defined
well enough!!)

Todd Whitesel
toddpw @