Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #393 > unrolled thread

DragAnObject_Start flags bit 17

Started byMatthew Phillips <mnews@sinenomine.freeserve.co.uk>
First post2011-06-02 22:20 +0100
Last post2011-06-03 15:40 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  DragAnObject_Start flags bit 17 Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-06-02 22:20 +0100
    Re: DragAnObject_Start flags bit 17 James Lampard <dontreplytothis@mailinator.com> - 2011-06-03 05:54 -0700
    Re: DragAnObject_Start flags bit 17 Martin Wuerthner <spamtrap@mw-software.com> - 2011-06-03 15:40 +0200

#393 — DragAnObject_Start flags bit 17

FromMatthew Phillips <mnews@sinenomine.freeserve.co.uk>
Date2011-06-02 22:20 +0100
SubjectDragAnObject_Start flags bit 17
Message-ID<32d538dd51.Matthew@sinenomine.freeserve.co.uk>
I have inherited some C code which uses DragAnObject.  While tracking down an
incompatibility with RISC OS 4 I noticed that the call to DragAnObject_Start
had bit 17 of the flags word set, meaning that the C function would be called
back in SVC mode.

I wondered whether this was the cause of the incompatibility (it turned out
not to be) and so removed it.  I had been using the StrongHelp OS manual as
my reference.  However, when reading PRM 5 later I noticed that it says
of bit 17 "1: SVC mode (use for modules; also allows access to statics)".

My use is for a plain application, not a module.

I take it this means that if my function (or functions it in turn calls?)
needs to access any static variables I will need to set this bit.  Do you
think it means statics in the sense of statics declared in that function
(local to the function and retained between calls) or statics declared in
that C source file (global in that file, but inaccessible outside it)?

-- 
Matthew Phillips
Durham

[toc] | [next] | [standalone]


#394

FromJames Lampard <dontreplytothis@mailinator.com>
Date2011-06-03 05:54 -0700
Message-ID<dd968d15-13ad-4f4b-a736-74152f76dcb3@c26g2000vbq.googlegroups.com>
In reply to#393
On Jun 2, 10:20 pm, Matthew Phillips
<mn...@sinenomine.freeserve.co.uk> wrote:
> I have inherited some C code which uses DragAnObject.  While tracking down an
> incompatibility with RISC OS 4 I noticed that the call to DragAnObject_Start
> had bit 17 of the flags word set, meaning that the C function would be called
> back in SVC mode.
>
> I wondered whether this was the cause of the incompatibility (it turned out
> not to be) and so removed it.  I had been using the StrongHelp OS manual as
> my reference.  However, when reading PRM 5 later I noticed that it says
> of bit 17 "1: SVC mode (use for modules; also allows access to statics)".
>
> My use is for a plain application, not a module.
>
> I take it this means that if my function (or functions it in turn calls?)
> needs to access any static variables I will need to set this bit.  Do you
> think it means statics in the sense of statics declared in that function
> (local to the function and retained between calls) or statics declared in
> that C source file (global in that file, but inaccessible outside it)?

From http://www.riscosopen.org/viewer/view/castle/RiscOS/Sources/Desktop/DragAnObj/VersionASM

The "call user mode function" option for DragAnObject has always been
broken -
it has always actually called you in SVC mode. Despite this clients
have
coped (such as Browse). But on 32-bit systems, this option leads to a
stack limit that looks higher than the (SVC) stack pointer, leading to
stack overflows and aborts. The module has been adjusted so that the
stack
limit is set to the bottom of the SVC stack rather than 0 to fix this.

I've chosen not to fix this option to actually call clients in user
mode, as
our broken behaviour may have led to broken clients with the option
set wrong.

Instead, I've added a new flag bit 18 that indicates to really call
the
client in user mode. Bit 17 should be clear if bit 18 is set. This
recovers
sl,fp and sp from the SVC stack and calls the client. The environment
should
be set up well enough to allow full access to user and C library
statics.
For this to work, DragAnObject_Start must have been called in user
mode
from an APCS program, and any SWI veneer used to issue the SWI must
have
left R10 and R11 (sl & fp) intact. _kernel_swi is fine, and _swi is
fine
except in an unpatched RISC OS 3.70/3.71.

Version 0.09. Tagged as 'DragAnObj-0_09'

--
James.
To reply use james underline lampard at talk 21 dot com

[toc] | [prev] | [next] | [standalone]


#395

FromMartin Wuerthner <spamtrap@mw-software.com>
Date2011-06-03 15:40 +0200
Message-ID<e49292dd51.martin@bach.planiverse.com>
In reply to#393
In message <32d538dd51.Matthew@sinenomine.freeserve.co.uk>
          Matthew Phillips <mnews@sinenomine.freeserve.co.uk> wrote:

> I have inherited some C code which uses DragAnObject.  While tracking down an
> incompatibility with RISC OS 4 I noticed that the call to DragAnObject_Start
> had bit 17 of the flags word set, meaning that the C function would be called
> back in SVC mode.

> I wondered whether this was the cause of the incompatibility (it turned out
> not to be) and so removed it.  I had been using the StrongHelp OS manual as
> my reference.  However, when reading PRM 5 later I noticed that it says
> of bit 17 "1: SVC mode (use for modules; also allows access to statics)".

> My use is for a plain application, not a module.

> I take it this means that if my function (or functions it in turn calls?)
> needs to access any static variables I will need to set this bit.

No, this bit and the reference to statics is only relevant for module 
code. Your USR mode application will be able to access its statics in 
any case. So, if your program is an ordinary application it should 
clear bit 17 and set bit 18, so it really gets called back in USR 
mode.

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web