[cfe-commits] r119958 - in /cfe/trunk: lib/Headers/mm_malloc.h lib/Headers/xmmintrin.h test/Headers/x86-intrinsics-headers.c

Chandler Carruth chandlerc at gmail.com
Mon Nov 22 00:06:32 PST 2010


Author: chandlerc
Date: Mon Nov 22 02:06:31 2010
New Revision: 119958

URL: http://llvm.org/viewvc/llvm-project?rev=119958&view=rev
Log:
Undo part of my previous commit to mm_malloc.h, going back to the use of
stdlib.h. There were numerous problems with forward declaring 'malloc' and
'free', but the most important is that these are reserved by POSIX and may be
implemented via a function-like macro.

As suggested by Dale Johannesen, I'm instead guarding the only include of this
in our builtin headers with __STDC_HOSTED__, and I've removed the include of
the header from the test suite. I'll discuss with folks whether we want to have
a hosted section of the test suite or not, and add it (and perhaps other tests)
back there if that's the direction.

Modified:
    cfe/trunk/lib/Headers/mm_malloc.h
    cfe/trunk/lib/Headers/xmmintrin.h
    cfe/trunk/test/Headers/x86-intrinsics-headers.c

Modified: cfe/trunk/lib/Headers/mm_malloc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mm_malloc.h?rev=119958&r1=119957&r2=119958&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/mm_malloc.h (original)
+++ cfe/trunk/lib/Headers/mm_malloc.h Mon Nov 22 02:06:31 2010
@@ -24,28 +24,20 @@
 #ifndef __MM_MALLOC_H
 #define __MM_MALLOC_H
 
-#include <stddef.h>
+#include <stdlib.h>
 
 #ifdef _WIN32
 #include <malloc.h>
 #else
-
-// Forward declare allocation functions to allow this header to parse without
-// any system headers.
 #ifndef __cplusplus
-extern void free(void *ptr);
-extern void *malloc(size_t size) __attribute__((__malloc__));
 extern int posix_memalign(void **memptr, size_t alignment, size_t size);
 #else
-// Some systems (e.g. those with GNU libc) declare some of these functions with
-// an exception specifier. Via an "egregious workaround" in
-// Sema::CheckEquivalentExceptionSpec, Clang accepts the following as valid
-// redeclarations of glibc's declarations.
-extern "C" void free(void *ptr);
-extern "C" void *malloc(size_t size) __attribute__((__malloc__));
+// Some systems (e.g. those with GNU libc) declare posix_memalign with an
+// exception specifier. Via an "egregious workaround" in
+// Sema::CheckEquivalentExceptionSpec, Clang accepts the following as a valid
+// redeclaration of glibc's declaration.
 extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size);
 #endif
-
 #endif
 
 static __inline__ void *__attribute__((__always_inline__, __nodebug__,

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=119958&r1=119957&r2=119958&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Mon Nov 22 02:06:31 2010
@@ -34,7 +34,11 @@
 typedef float __v4sf __attribute__((__vector_size__(16)));
 typedef float __m128 __attribute__((__vector_size__(16)));
 
+// This header should only be included in a hosted environment as it depends on
+// a standard library to provide allocation routines.
+#if __STDC_HOSTED__
 #include <mm_malloc.h>
+#endif
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
 _mm_add_ss(__m128 a, __m128 b)

Modified: cfe/trunk/test/Headers/x86-intrinsics-headers.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/x86-intrinsics-headers.c?rev=119958&r1=119957&r2=119958&view=diff
==============================================================================
--- cfe/trunk/test/Headers/x86-intrinsics-headers.c (original)
+++ cfe/trunk/test/Headers/x86-intrinsics-headers.c Mon Nov 22 02:06:31 2010
@@ -1,13 +1,9 @@
-// RUN: %clang -fsyntax-only %s
-// RUN: %clang -fsyntax-only -fno-lax-vector-conversions %s
-// RUN: %clangxx -fsyntax-only -x c++ %s
+// RUN: %clang -fsyntax-only -ffreestanding %s
+// RUN: %clang -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s
+// RUN: %clangxx -fsyntax-only -ffreestanding -x c++ %s
 
 #if defined(i386) || defined(__x86_64__)
 
-#ifdef __MMX__
-#include <mm_malloc.h>
-#endif
-
 #ifdef __SSE4_2__
 // nmmintrin forwards to smmintrin.
 #include <nmmintrin.h>





More information about the cfe-commits mailing list