mingw bridge and -freg-struct-return

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mingw bridge and -freg-struct-return

Takashi Ono
Hi all,

I have copied most part of the current mingw c++ uno bridge code from linux
implementation and it works if -fpcc-struct-return is specified in
solenv/inc/wntgcci6.mk

However, the default is -freg-struct-return on mingw.

Recently kendy proposed to remove stlport from mingw port and it seems to work provided
that system stl library (libstdc++) has been rebuilt with -fpcc-struct-return.

As mingw tools still have some bugs that will not be fixed soon, I am distributing
patched binaries. So I can distriute the library (Actually I am already doing so) or
even change the default to fpcc-struct-return for all tools.

However, as -freg-struct-return is the default in cuurent mingw community, I think it
is a better solution to rewrite bridge code.

I wonder if there is a bridge implementation for gcc with -freg-struct-return default,
which can be a kind of example for me.

I would appreciate any help.

Regards,

Takashi Ono ([hidden email])

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: mingw bridge and -freg-struct-return

Jan Holesovsky
Hi Takashi,

On Thursday 13 of November 2008, Takashi Ono wrote:

> I have copied most part of the current mingw c++ uno bridge code from linux
> implementation and it works if -fpcc-struct-return is specified in
> solenv/inc/wntgcci6.mk
>
> However, the default is -freg-struct-return on mingw.

Generally it should not be that hard to extend it so that we can
handle -freg-struct-return ;-)  According to what I've read in the gcc man
page, the only difference is that small structs are returned in registers.  
To extend the code, you should find an ABI description of exactly what
structures (how big) are involved, and either create a new
privateSnippetExecutorSmallClass [see below] + change cpp2uno.cxx so that
that one is called for the small classes, or modify
updateprivateSnippetExecutorClass accordingly [so that it decides the actual
size of the class, and acts as needed].

To me, the easiest way to do something like this was to create a small example
function that returns what you need [in this case a small structure - the ABI
description should be more verbose on what it actually is ;-)], and run:

gcc -S -freg-struct-return your_example.c -o your_example_reg_return.s
gcc -S -fpcc-struct-return your_example.c -o your_example_pcc_return.s

your_example_*.s then contains the actual assembler that you can use in
call.s; you can compare both to see what is the actual difference.  
Unfortunately, I don't have time now to help with this :-( - though I'd be
very interested...

[Generally, your_example.c would look something like:
struct my_struct {
    int a;
};

struct my_struct function( int b )
{
    struct my_struct s;
    s.a = b;
    return s;
}
]

HTH,
Kendy

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]