summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-11-16 10:07:43 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-11-16 10:07:43 +0000
commit5eef9ba483e5ad4fa44110b4b3797ebf5adede7a (patch)
tree96086686a03391a0f8a73f381964236ff4f44e04 /clang/lib
parent6dd263e31ba59d70d7bb678a8ecbf90aa9cf6358 (diff)
downloadbcm5719-llvm-5eef9ba483e5ad4fa44110b4b3797ebf5adede7a.tar.gz
bcm5719-llvm-5eef9ba483e5ad4fa44110b4b3797ebf5adede7a.zip
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. llvm-svn: 119343
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Headers/limits.h6
-rw-r--r--clang/lib/Headers/mm_malloc.h18
2 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 26275337d58..ecd09a4a246 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -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. */
diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index e7da5434587..a402b57fd24 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -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__,
OpenPOWER on IntegriCloud