Separate data and function address spaces

Conor P. Cahill cpcahil at virtech.uucp
Fri Nov 10 23:38:28 AEST 1989


In article <10984 at csli.Stanford.EDU>, poser at csli.Stanford.EDU (Bill Poser) writes:
> 	Is there a reason why someone would write code like:
> 
> 	char *p;
> 	int fn();
> 	p = (char *)fn;
> 
> whose non-portability has been under discussion?

Yes, at least that kind of operation (where data and function pointers are 
converted an used).  I worked on a project that used shared memory to
implement shared libraries, so functions had to be in data space and the 
pointers to those functions were based upon the shmaddr returned by 
shmat().

This was definately not portable to every machine, but was usable on many 
system V.2 systems with just a bit of tweaking (mostly in the initialization
code and loader scripts).  Here the advantage of the non-portable code 
outweighed the non-portability, besides it was coded so that it could
be turn on/off at compile time, so if the system did not support it, we just
turned it off.

-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.lang.c mailing list