code optimization and parameters marshalling question

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi folks,

 I've recently discovered that if I ask my NC30 compiler to optimize
 my C code, it passes function parameters through the registers and not
 through the stack. The question is:

 What happens if I call a function that belongs to a library which
 was compiled using optimizing options (parameters passed through
 the registers), from a function that was compiled without optimizing
 options (parameters passed through the stack)?

thanks,
 Enrico

Re: code optimization and parameters marshalling question

Quoted text here. Click to load it
not
It won't work!


Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

thanks!

I in fact suspected that....
That explains why, in the past, each time I tried to enable
any kind of optimization, I experienced problems...

ciao,
 Enrico

Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

And this is why you recompile your libraries when you change options like
that.

--
Richard

Re: code optimization and parameters marshalling question

Quoted text here. Click to load it
optimize
and
optimizing
like

This is preferrable, provided you have the source code!


Re: code optimization and parameters marshalling question
@g14g2000cwa.googlegroups.com:

Quoted text here. Click to load it

Well, yes, but then, where I work, we generally don't use any library
that we can't get the source for, or RTOS for that matter.

--
Richard

Re: code optimization and parameters marshalling question

Quoted text here. Click to load it
options


You, *spoiled* ones :)


Re: code optimization and parameters marshalling question
Quoted text here. Click to load it

No, just practical, IMO.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on
We've slightly trimmed the long signature. Click to see the full one.
Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

I have just made a proposal for a prospective customer who won't
accept to pay too high a price for a basic functionality. This
is a problem of balance between safety levels and costs.

As for the original problem, a solution could be to wrap calls
to the library and place them in a separate source file which is
compiled with optimizations enabled. This is possible if you can
afford the time penalty.


Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

Check if your compiler supports the "cdecl" keyword (or maybe
"Cdecl", "_cdecl", etc.) This keyword tells the compiler to use
the normal, stack-based calling convention.

The compiler may also have a command-line option to force the
use of the stack calling convention, even with optimizations
enabled.


Re: code optimization and parameters marshalling question
@yahoo.com:

Quoted text here. Click to load it

Yep, that is one of the primary considerations when we are out shopping for
one of the above.

--
Richard

Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

I have just made a proposal for a prospective customer who won't
accept to pay too high a price for a basic functionality. This
is a problem of balance between safety levels and costs


Re: code optimization and parameters marshalling question

Quoted text here. Click to load it

Or you should have received two (or more ) kinds of libraries.


--
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: code optimization and parameters marshalling question

Quoted text here. Click to load it
not
You could try to enable optimization with pragma directives in the
portions of code that call the library routines.


Re: code optimization and parameters marshalling question
Quoted text here. Click to load it

There should be some way of indicating the fact in the headers,
similar to the use of 'fastcall' in Microsoft systems.  Check your
documentation.  Once you use such things you are getting outside of
standard C.  At any rate the library headers should handle it.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline