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]

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


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__.
 
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);
     }
 


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