This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Gregor Richards <gregor dot richards at uwaterloo dot ca>, Rich Felker <dalias at libc dot org>, Szabolcs Nagy <nsz at port70 dot net>
- Date: Fri, 15 May 2015 10:02:09 -0700
- Subject: Re: [PATCH 13/13] fix incompatible posix_memalign declaration on x86
- Authentication-results: sourceware.org; auth=none
- References: <55354A4A dot 4060702 at arm dot com> <55354CC3 dot 6070103 at arm dot com> <CAMe9rOqONE0nn1X-QFBhf_W+76W7VBi8Mm8zQkmUz_A4UC=6Uw at mail dot gmail dot com> <55561A40 dot 4080202 at arm dot com>
On Fri, May 15, 2015 at 9:09 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>
>
> On 15/05/15 16:05, H.J. Lu wrote:
>> On Mon, Apr 20, 2015 at 12:00 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
>>> The posix_memalign declaration is incompatible with musl for C++,
>>> because of the exception specification. It also pollutes the
>>> namespace and lacks protection against a potential macro definition
>>> that is allowed by POSIX. The fix avoids source level namespace
>>> pollution but retains the dependency on the posix_memalign extern
>>> libc symbol.
>>>
>>> The fix is ugly, but it is not possible to correctly redeclare a
>>> libc function in a public gcc header for C++.
>>>
>>>
>>> gcc/Changelog:
>>>
>>> 2015-04-16 Szabolcs Nagy <szabolcs.nagy@arm.com>
>>>
>>> * config/i386/pmm_malloc.h (posix_memalign): Renamed to ...
>>> (__gcc_posix_memalign): This. Use posix_memalign as extern
>>> symbol only.
>>
>> What does this try to achieve? Do you have a testcase which
>> fails before and passes with this patch?
>
> if posix_memalign is defined in stdlib.h according to posix then
> the exception specifier used in mm_malloc.h is incompatible:
>
> $ echo "#include <mm_malloc.h>" | ./x86_64-linux-musl-g++ -pedantic -c -xc++ -D_POSIX_C_SOURCE=200809L -
> In file included from <stdin>:1:0:
> /data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:34:64: error: declaration of 'int posix_memalign(void**, size_t,
> size_t) throw ()' has a different exception specifier
> extern "C" int posix_memalign (void **, size_t, size_t) throw ()
> ^
> In file included from /data/cross/x86_64-linux-musl/lib/gcc/x86_64-linux-musl/6.0.0/include/mm_malloc.h:27:0,
> from <stdin>:1:
> /data/cross/x86_64-linux-musl/x86_64-linux-musl/include/stdlib.h:98:5: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
> int posix_memalign (void **, size_t, size_t);
> ^
>
> however it seems without -pedantic there is no error anymore,
> the code is accepted even in standard conforming mode.
> (it used to be an error that could not be silenced).
>
> this means the patch is no longer critical for musl support.
>
2 more comments:
1. You need a tecase, independent of MUSL.
2. Please replace __gcc_posix_memalign with _mm_posix_memalign.
--
H.J.