🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11136

memalign (can it be simulated?)

#11136
From: Michael Richardson
Date: Mon, 23 Jan 1989 03:14
45 lines
2313 bytes
  I was intending to port (my custom) a lisp interpreter now running on a SUN to the
Amiga this month. The project has been put off for awhile because I realise
I can't do it without a hard disk. But a couple of questions:

  I currently get (4K) blocks aligned on 4K boundaries from SunOS using
memalign (a variation on malloc). The SUN malloc likes to store the size
of the block in the word preceeding the block, and I would waste
4094 bytes of space every time I allocated a block. Until I write/find
a better malloc, I kludge things and allocate 4094 bytes instead.
(I used to just advance brk() by about 500K to make my arena, but
realising I was going to port it, I changed that recently.)
I use the middle 8 bits
 uuuu uuuu uuuu tttt tttt oooo oooo oooo
   u - upper bits
   t - page number (used to index into a table to determine object type)
   o - page offsets

  to determine the type of the page, so I need to allocate the pages
on 2^12=4K boundaries.

  I have discovered that the Manx malloc is a fake - is uses a 40K
arena which is allocated at run time regardless of how much malloc'ing
you intend to do. (Do any of the library functions call malloc? I'd like
to stay away from them if possible)
  The normal AllocMem is fine, I DO know the block size, but it wont
guarantee a 4K boundary. I have thought about AllocMem'ing 8K, taking the
middle 4K chunk and returning the rest, but I am not sure if this will
work. Does AllocMem keep any information of blocks that are in use? If
so, can I do things in a revision-independant way? Or do I have to
walk to memory lists myself? (Worse solution.)

  Thanks!





--

  :!mcr!:
  Michael Richardson                     Amiga
                                  v--------+
 UUCP: uunet!attcan!lsuc!nrcaer!julie!mcr  | INTERNET mcr@doe.carleton.ca
 Fido: Michael Richardson @ 1:163/109.10<--+ Alter @ 7:483/109.10
Technical Details
Message-ID: <0164.AA0164@julie>
Path: arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!julie!mcr

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!julie!mcr
From: mcr@julie.UUCP (Michael Richardson)
Newsgroups: comp.sys.amiga.tech
Subject: memalign (can it be simulated?)
Message-ID: <0164.AA0164@julie>
Date: 23 Jan 89 03:14:01 GMT
Article-I.D.: julie.0164.AA0164
Followup-To: comp.sys.amiga.tech
Distribution: world
Organization: Sandleman Software Works' Debugging Department, Ottawa, ON
Lines: 45