diff mbox series

[i386] Don't use errno when freestanding (was: config/i386/xmmintrin.h: Only #include <mm_malloc.h> if __STDC_HOSTED__)

Message ID alpine.LSU.2.21.1908181811260.14047@anthias.pfeifer.com
State New
Headers show
Series [i386] Don't use errno when freestanding (was: config/i386/xmmintrin.h: Only #include <mm_malloc.h> if __STDC_HOSTED__) | expand

Commit Message

Gerald Pfeifer Aug. 18, 2019, 4:29 p.m. UTC
On Sat, 9 Dec 2017, Jakub Jelinek 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.
> 
> Wouldn't it be better to just ifdef out parts of gmm_malloc.h (pmm_malloc.h
> should be ok)?

Very good point, Jakub.  Thank you!  

Somehow I thought I had submitted this updated patch, but apparently 
not so. :-(  (This has been on my autotester for ages.)

Okay?  And if so, okay for GCC 9 after a while?

Gerald


2019-08-18  Gerald Pfeifer  <gerald@pfeifer.com>
 
	* config/i386/gmm_malloc.h: Only include errno.h and use errno
	if __STDC_HOSTED__.

Comments

Jeff Law Aug. 19, 2019, 10:49 p.m. UTC | #1
On 8/18/19 10:29 AM, Gerald Pfeifer wrote:
> On Sat, 9 Dec 2017, Jakub Jelinek 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.
>>
>> Wouldn't it be better to just ifdef out parts of gmm_malloc.h (pmm_malloc.h
>> should be ok)?
> 
> Very good point, Jakub.  Thank you!  
> 
> Somehow I thought I had submitted this updated patch, but apparently 
> not so. :-(  (This has been on my autotester for ages.)
> 
> Okay?  And if so, okay for GCC 9 after a while?
> 
> Gerald
> 
> 
> 2019-08-18  Gerald Pfeifer  <gerald@pfeifer.com>
>  
> 	* config/i386/gmm_malloc.h: Only include errno.h and use errno
> 	if __STDC_HOSTED__.
OK.
jeff
diff mbox series

Patch

Index: config/i386/gmm_malloc.h
===================================================================
--- config/i386/gmm_malloc.h	(revision 274618)
+++ config/i386/gmm_malloc.h	(working copy)
@@ -25,7 +25,9 @@ 
 #define _MM_MALLOC_H_INCLUDED
 
 #include <stdlib.h>
+#if __STDC_HOSTED__
 #include <errno.h>
+#endif
 
 static __inline__ void * 
 _mm_malloc (size_t __size, size_t __align)
@@ -36,7 +38,9 @@  _mm_malloc (size_t __size, size_t __align)
   /* Error if align is not a power of two.  */
   if (__align & (__align - 1))
     {
+#if __STDC_HOSTED__
       errno = EINVAL;
+#endif
       return ((void *) 0);
     }