This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


2010/5/12 Richard Guenther <richard.guenther@gmail.com>:
> On Wed, May 12, 2010 at 5:48 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 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; }
>
> I don't have the windows.h header so can you please cut&paste the
> relevant parts(!) of a preprocessed variant?
>
>> 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
>>
>

ok, simplified example by using just intrin.h and xmmintrin.h
t_1.cc:
#include <xmmintrin.h>
#include <intrin.h>

int main() { return 0; }

I sebt preprocessed source for this example directly to our e-mail
(note by first including intrin.h and then xmmintrin.h compilation
doesn't throw errors due guard in xmmintrin.h).

Regards,
Kai


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]