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

Richard Guenther richard.guenther@gmail.com
Wed May 12 14:05:00 GMT 2010


On Wed, May 12, 2010 at 4:02 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, May 12, 2010 at 3:57 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 2010/5/12 Richard Guenther <richard.guenther@gmail.com>:
>>> On Wed, May 12, 2010 at 3:43 PM, Kai Tietz <Kai.Tietz@onevision.com> wrote:
>>>> "H.J. Lu" <hjl.tools@gmail.com> wrote on 12.05.2010 15:31:07:
>>>>
>>>>> On Wed, May 12, 2010 at 3:23 AM, Kai Tietz <Kai.Tietz@onevision.com>
>>>> wrote:
>>>>> > Hello,
>>>>> >
>>>>> > At the moment intrinsic functions for headers don't have a explicit
>>>>> > language binding. As types, structures, and functions are quite
>>>> different
>>>>> > handled in c++ and c, this cause at least for x86/x64 windows to
>>>> issues,
>>>>> > as for this platforms the intrinsic functions have "C" language scope
>>>> by
>>>>> > definition.
>>>>> > I tested for x86_64-pc-linux-gnu, i686-pc-mingw32, x86_64-w64-mingw32,
>>>> and
>>>>> > i686-pc-cygwin. And I didn't found any regressions.
>>>>> >
>>>>> > 2010-05-12  Kai Tietz
>>>>> >
>>>>> >        * config/i386/abmintrin.h: Add extern "C" guard for c++.
>>>>> >        * config/i386/ammintrin.h: Likewise.
>>>>> >        * config/i386/avxintrin.h: Likewise.
>>>>> >        * config/i386/cpuid.h: Likewise.
>>>>> >        * config/i386/emmintrin.h: Likewise.
>>>>> >        * config/i386/fma4intrin.h: Likewise.
>>>>> >        * config/i386/gmm_malloc.h: Likewise.
>>>>> >        * config/i386/ia32intrin.h: Likewise.
>>>>> >        * config/i386/lwpintrin.h: Likewise.
>>>>> >        * config/i386/mm3dnow.h: Likewise.
>>>>> >        * config/i386/mmintrin.h: Likewise.
>>>>> >        * config/i386/pmm_malloc.h: Likewise.
>>>>> >        * config/i386/pmmintrin.h: Likewise.
>>>>> >        * config/i386/popcntintrin.h: Likewise.
>>>>> >        * config/i386/smmintrin.h: Likewise.
>>>>> >        * config/i386/tmmintrin.h: Likewise.
>>>>> >        * config/i386/wmmintrin.h: Likewise.
>>>>> >        * config/i386/xmmintrin.h: Likewise.
>>>>> >        * config/i386/xopintrin.h: Likewise.
>>>>> >
>>>>> > Ok for apply to trunk?
>>>>> >
>>>>>
>>>>> Those function are always inlined. What do we need extern "C"?
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> H.J.
>>>>>
>>>>
>>>> As I described above. C++ and C have different name mangling and for win32
>>>> intrinsic have C scope. And as far as I can see it doesn't hurt, so the
>>>> question is here more why we should stick here not unifying the language
>>>> scope?
>>>
>>> They won't have external linkage so why would we care?
>>>
>>> Richard.
>>>
>>>> Regards,
>>>> Kai
>>>>
>>>> |  (\_/)  This is Bunny. Copy and paste Bunny
>>>> | (='.'=) into your signature to help him gain
>>>> | (")_(") world domination.
>>>>
>>>>
>>>
>>
>> The issue, which occures here is, that a user wants - for example - to
>> include <xmmintrin.h> header in C++. Now he includes afterwards for
>> windows the math.h/intrin.h (which both have explicit C language
>> scope). What happens here? A bunch of warnings/failures caused by C++
>> vs. C language scope.
>> So why we shouldn't care?
>
> You'll get ODR violation errors anyway in that case.

And in the odd case where'd we care for the linkage it would be an
ABI change which is bad.

Richard.

> Richard.
>
>> 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