This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

scm_heap_org considered harmfull


Guile contains a global variable called `scm_heap_org' which is
documented as "the lowest base address of any heap segment" and is
initialized from the base address of the first heap segment allocated.

This assumes that malloc allocates from the low end of memory, such
that for two pointers p1 and p2 obtained from subsequent calls to
malloc, it holds that p1 < p2.

This may be the convention on a number of popular UNIX implementations
but it does not hold universally, with the pSOS as one exception (pSOS
is an OS used for embedded systems which we are using for a new line
of powerpc based cards).

As far as I can tell, the only use for scm_heap_org is to convert a 32
bit pointer into an offset with a smaller range (to free up some tag
bits perhaps). If so. any offset would do, allowing for a more robust
strategy. I am currently using the address of scm_heap_org itself, as
in:

	  scm_heap_org = CELL_UP (&scm_heap_org);

and it seems to work fine. 

If anybody has a more elegant (or robust) solution, please let me know.


---------------------------+--------------------------------------------------
Christian Lynbech          | Telebit Communications A/S                       
Fax:   +45 8628 8186       | Fabrikvej 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28  | email: chl@tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic@hal.com (Michael A. Petonic)