OSHeap_Resize Should Have R3 as Output.
Tony van der Hoff
tony at mk-net.demon.co.uk
Thu Nov 8 13:34:40 GMT 2001
On 6 Nov 2001, in message <1b9131d54a.kbracey at kbracey.cam.pace.co.uk>,
Kevin Bracey <kevin.bracey at pace.co.uk> wrote:
> In message <0e712dd54a.Tony at mk-net.demon.co.uk>
> Tony van der Hoff <tony at mk-net.demon.co.uk> wrote:
>
> > We had to patch round this for OS_ReadVarVal, and I guess we could do
> > something similar here, if there was demand for it. It would be possible to
> > define new veneers, say OSHeap_ResizeReturnAmount, and
> > OS_ChangeDynamicAreaReturnAmount, which could interpret any error return,
> > and if appropriate, then return R3 with V clear, and R0 preserved, as if no
> > error occurred.
> >
> > Is this worth doing?
>
> I would wholeheartedly say yes. Ideally with a standard suffix for the
> "returning registers even after an error" form. Just for the SWIs that need
> it though.
>
OK, guys, here's a choice (who designed the API for this SWI anyway?).
Take OS_Heap 5. It is passed a signed int in R3 to specify the amount to
extend; i.e. a negative number to shrink. If the change succeeds, then R3 is
preserved, i.e, it returns the number we first asked for. If it fails to
shrink, then it returns a *positive* number indicating by how much the heap
actually shrunk. Not very intuitive, and it makes it hard for user code to
test. I believe the more logical thing to do would be to return a negative
number, indicating by how much the heap expanded.
Normally, I would say that it's none of OSLib's busines to re-interpret the
API, but since I'm doing exactly that, by hand coding this veneer, and
suppressing error_HEAP_EXCESSIVE_SHRINK, I would suggest negating R3 if that
error occurred. That way, the sign of the return value would be consistent,
indicating the value that was *actually* changed in all cases.
Naturally, we will still return an error with out returning anything for any
other error condition.
The same argument applies to OS_ChangeDynamicArea.
Oh, I'm adding the suffix _no_fail to both of the standard calls for the
"fixed" version.
Any comments?
--
Tony van der Hoff | MailTo:tony at mk-net.demon.co.uk
| MailTo:avanderhoff at iee.org
Buckinghamshire, England | http:www.mk-net.demon.co.uk
More information about the oslib-user
mailing list