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 13/13] fix incompatible posix_memalign declaration on x86


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.


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