[patch i386]:Ensure intrinsic functions are declared "C"

Kai Tietz ktietz70@googlemail.com
Wed May 12 15:48:00 GMT 2010


2010/5/12 Richard Guenther <richard.guenther@gmail.com>:
> On Wed, May 12, 2010 at 5:18 PM, Jason Merrill <jason@redhat.com> wrote:
>> On 05/12/2010 11:10 AM, Richard Guenther wrote:
>>>
>>> On Wed, May 12, 2010 at 5:07 PM, Jason Merrill<jason@redhat.com>  wrote:
>>>>
>>>> You'd only get an ODR violation if you have a class/enum/inline/template
>>>> defined in multiple translation units that uses the intrinsics but
>>>> sometimes
>>>> sees the definitions in xmmintrin and sometimes not.
>>>
>>> Can you show us a testcase that shows an example of the conflict?
>>
>> a.h:
>>
>> inline __m128 myfn (__m128 m) { ...code that uses intrinsics... }
>>
>> a.C:
>>
>> #include <windowsheader.h>
>> #include "a.h"
>>
>> void f ()
>> {
>>  ...myfn(...
>> }
>>
>> b.C:
>>
>> #include <xmmintrin.h>
>> #include "a.h"
>>
>> void g ()
>> {
>>  ...myfn(...
>> }
>>
>> -----------
>>
>> So in both a.C and b.C myfn is using intrinsics.  But in a.C it's using the
>> external definitions, and in b.C it's using the inline definitions from
>> xmmintrin.h.  I wouldn't expect this to be a problem in practice (surely the
>> semantics are the same either way), but technically myfn would violate the
>> ODR.
>>
>> Of course, if a.h included xmmintrin.h itself so that it doesn't rely on
>> being included after something else that provides the declarations it needs,
>> this couldn't happen.
>>
>> I don't think this issue is significant compared to the problem of people
>> not being able to include both xmmintrin.h and the relevant windows header
>> in the same translation unit.
>
> Yeah.  I meant how does the windowsheader.h variant look like compared
> to the xmmintrin.h variant?
>
> Richard.
>
>> Jason
>>
>

Simplest example is

#include <xmmintrin.h>
#include <windows.h>

int main() { return 0; }

The windows.h header internally includes the intrinsinc header
intrin.h as defined by MS documentation (some intrinsic are also
(re-)declared in platform headers and standard-c-headers (eg. rotl &
co). Our implementation of this header (intrin.h) can be found at
http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-headers/crt/intrin.h?revision=1747&view=markup
as example (we work-a-round here some other issues existing for win32
and gcc's header)

Regards,
Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination



More information about the Gcc-patches mailing list