This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: config/i386/xmmintrin.h: Only #include <mm_malloc.h> if __STDC_HOSTED__
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Andreas Tobler <andreast at FreeBSD dot org>, Alexander Kabaev <kan at freebsd dot org>
- Date: Sat, 9 Dec 2017 19:45:49 +0100
- Subject: Re: config/i386/xmmintrin.h: Only #include <mm_malloc.h> if __STDC_HOSTED__
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LSU.2.21.1712091825580.2983@anthias.pfeifer.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Dec 09, 2017 at 06:41:14PM +0100, Gerald Pfeifer wrote:
> Some users on FreeBSD noticed a problem when trying to use GCC to
> build things in a standalone environment that manifests itself as
>
> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/xmmintrin.h:34 from
> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/immintrin.h:29 from
> /workspace/src/sys/crypto/aesni/intel_sha256.c:62
> In function '_mm_malloc':
> /usr/local/lib/gcc/x86_64-unknown-freebsd11.0/6.3.0/include/mm_malloc.h:39:
> error: 'errno' undeclared (first use in this function)
>
> It turns out the clang version of xmmintrin.h does not include mm_malloc.h
> if !__STDC_HOSTED__ whereas ours unconditionally does so.
>
> Andreas and Alexander have tested the simple patch below that essentially
> mirrors what clang does.
>
> Okay?
Wouldn't it be better to just ifdef out parts of gmm_malloc.h (pmm_malloc.h
should be ok)?
#include <errno.h>
and
/* Error if align is not a power of two. */
if (__align & (__align - 1))
{
errno = EINVAL;
return ((void *) 0);
}
I don't see why the rest wouldn't work in a freestanding environment.
Or perhaps just the errno = EINVAL; and #include <errno.h> lines.
Jakub