[cfe-commits] r119343 - in /cfe/trunk/lib/Headers: limits.h mm_malloc.h
Chandler Carruth
chandlerc at gmail.com
Tue Nov 16 02:07:43 PST 2010
Author: chandlerc
Date: Tue Nov 16 04:07:43 2010
New Revision: 119343
URL: http://llvm.org/viewvc/llvm-project?rev=119343&view=rev
Log:
Futher reduce the includes of our builtin headers, and teach limits.h to avoid
include_next when not hosted or unavailable. This follows the pattern in
stdint.h and allows these headers to work even in a freestanding configuration
without a standard library.
Modified:
cfe/trunk/lib/Headers/limits.h
cfe/trunk/lib/Headers/mm_malloc.h
Modified: cfe/trunk/lib/Headers/limits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/limits.h?rev=119343&r1=119342&r2=119343&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/limits.h (original)
+++ cfe/trunk/lib/Headers/limits.h Tue Nov 16 04:07:43 2010
@@ -31,8 +31,12 @@
#define _GCC_LIMITS_H_
#endif
-/* System headers include a number of constants from POSIX in <limits.h>. */
+/* System headers include a number of constants from POSIX in <limits.h>.
+ Include it if we're hosted. */
+#if __STDC_HOSTED__ && \
+ defined(__has_include_next) && __has_include_next(<limits.h>)
#include_next <limits.h>
+#endif
/* Many system headers try to "help us out" by defining these. No really, we
know how big each datatype is. */
Modified: cfe/trunk/lib/Headers/mm_malloc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mm_malloc.h?rev=119343&r1=119342&r2=119343&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/mm_malloc.h (original)
+++ cfe/trunk/lib/Headers/mm_malloc.h Tue Nov 16 04:07:43 2010
@@ -24,20 +24,28 @@
#ifndef __MM_MALLOC_H
#define __MM_MALLOC_H
-#include <stdlib.h>
+#include <stddef.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 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.
+// 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__));
extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size);
#endif
+
#endif
static __inline__ void *__attribute__((__always_inline__, __nodebug__,
More information about the cfe-commits
mailing list