From: kishor on
Hi friends,

I am new to keil-4 RVMDK & luminary micro lm3s6965.
I want to use some functions as re-entrant.

In keil C51, they provide keyword "reentrant", But in RVMDK I didn't
find any clue.

Thanks & Regards,
Kishore
From: Chris H on
In message <28b1633b-6012-44cc-ba7c-0396877f57cf(a)g39g2000pri.googlegroup
s.com>, kishor <kiishor(a)gmail.com> writes
>Hi friends,
>
>I am new to keil-4 RVMDK & luminary micro lm3s6965.
>I want to use some functions as re-entrant.
>
>In keil C51, they provide keyword "reentrant", But in RVMDK I didn't
>find any clue.

Have you asked Keil tech support?


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



From: David Brown on
On 31/05/2010 10:29, kishor wrote:
> Hi friends,
>
> I am new to keil-4 RVMDK& luminary micro lm3s6965.
> I want to use some functions as re-entrant.
>
> In keil C51, they provide keyword "reentrant", But in RVMDK I didn't
> find any clue.
>
> Thanks& Regards,
> Kishore


You make a function re-entrant by writing appropriate C code - avoid
using shared storage (such as global variables or function-scope
statics), avoid calling non-re-entrant functions, etc.

It's only on non-standard compilers for seriously limited processors -
such as Keil's C51 compiler - that you will see a "reentrant" keyword.
For processors that can efficiently access data on a stack, or with
compilers that are smart enough to figure out these things automatically
and thus generate good code while following C standards (I don't know if
such a compiler exists for the 8051), there is no such thing as a
"reentrant" keyword.
From: Chris H on
In message <4c03c115$0$4149$8404b019(a)news.wineasy.se>, David Brown
<david(a)westcontrol.removethisbit.com> writes
>On 31/05/2010 10:29, kishor wrote:
>> Hi friends,
>>
>> I am new to keil-4 RVMDK& luminary micro lm3s6965.
>> I want to use some functions as re-entrant.
>>
>> In keil C51, they provide keyword "reentrant", But in RVMDK I didn't
>> find any clue.
>>
>> Thanks& Regards,
>> Kishore
>
>
>You make a function re-entrant by writing appropriate C code - avoid
>using shared storage (such as global variables or function-scope
>statics), avoid calling non-re-entrant functions, etc.
>
>It's only on non-standard compilers for seriously limited processors -
>such as Keil's C51 compiler - that you will see a "reentrant" keyword.

Keil is no more "non-standard" than most other compilers.... GCC for
example.

>For processors that can efficiently access data on a stack, or with
>compilers that are smart enough to figure out these things
>automatically and thus generate good code while following C standards
>(I don't know if such a compiler exists for the 8051), there is no such
>thing as a "reentrant" keyword.

The only sensible compiler for the 8051 is the Keil which has about 80%
of the market.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



From: David Brown on
Chris H wrote:
> In message <4c03c115$0$4149$8404b019(a)news.wineasy.se>, David Brown
> <david(a)westcontrol.removethisbit.com> writes
>> On 31/05/2010 10:29, kishor wrote:
>>> Hi friends,
>>>
>>> I am new to keil-4 RVMDK& luminary micro lm3s6965.
>>> I want to use some functions as re-entrant.
>>>
>>> In keil C51, they provide keyword "reentrant", But in RVMDK I didn't
>>> find any clue.
>>>
>>> Thanks& Regards,
>>> Kishore
>>
>> You make a function re-entrant by writing appropriate C code - avoid
>> using shared storage (such as global variables or function-scope
>> statics), avoid calling non-re-entrant functions, etc.
>>
>> It's only on non-standard compilers for seriously limited processors -
>> such as Keil's C51 compiler - that you will see a "reentrant" keyword.
>
> Keil is no more "non-standard" than most other compilers.... GCC for
> example.
>

I was wondering if you could resist...

Of course, all embedded compilers have non-standard features - there are
things that an embedded C programmer wants to be able to express that
cannot be expressed in C (such as interrupt functions, embedded
assembly, data in flash or other specific memory areas, etc.).

Additionally, many compilers (embedded or otherwise) have extensions or
extra features to help you write smaller, faster, or otherwise better
code. They also often allow you to mix features from different
standards, such as allowing // comments or inline functions in ANSI C.
gcc has plenty of such extensions if you want to use them, as do many
(all?) other compilers. But as these are optional, they are not
non-standard.

Where Keil's 8051 compiler differs here is that it requires non-standard
extension keywords to write code that can be expressed correctly in
standard C. Re-entrant functions are not a special embedded feature,
but part of the language. If you cannot write a re-entrant (or
recursive) function in plain standard C, then the compiler is
non-standard in a much more serious way than most other embedded
compilers. Of course, it could be that there are command-line switches
for Keil that allow any functions to be re-entrant, thus making the
compiler more standards compliant (but perhaps generating horrible code).

I have never had to use the 8051, so I don't know the tools in detail.
But the little I've seen of code written for either Keil or SDCC for the
8051 has had a mishmash of extra keywords saying whether data is to be
placed in registers, internal ram, xdata, or whatever. That's not
standard C.


That does not mean there is anything wrong with it, of course - the
compiler is a tool to let you write code to run on the target. If it
has to be non-standard to let you generate good object code, then that's
fair enough.

>> For processors that can efficiently access data on a stack, or with
>> compilers that are smart enough to figure out these things
>> automatically and thus generate good code while following C standards
>> (I don't know if such a compiler exists for the 8051), there is no such
>> thing as a "reentrant" keyword.
>
> The only sensible compiler for the 8051 is the Keil which has about 80%
> of the market.
>