summaryrefslogtreecommitdiffstats
path: root/include/stdlib.h
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-06-15 11:01:52 +0000
committerdes <des@FreeBSD.org>2003-06-15 11:01:52 +0000
commite6811cdce978450f1460814b6644197937ffd4d4 (patch)
tree0f9873860d2ca4f753ac7b3426a2279c58d29f87 /include/stdlib.h
parent8bb15f6592a478029c24ef363cf879a01be0c9c3 (diff)
downloadFreeBSD-src-e6811cdce978450f1460814b6644197937ffd4d4.zip
FreeBSD-src-e6811cdce978450f1460814b6644197937ffd4d4.tar.gz
Use __builtin_alloca() on compilers that have it. Keep the prototype for
the benefit of lint and non-{GNU,Intel} compilers.
Diffstat (limited to 'include/stdlib.h')
-rw-r--r--include/stdlib.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index b553744..4bbd438 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -222,7 +222,23 @@ extern const char *_malloc_options;
extern void (*_malloc_message)(const char *, const char *, const char *,
const char *);
-void *alloca(size_t); /* built-in for gcc */
+#ifndef alloca
+/*
+ * The alloca() function can't be implemented in C, and on some
+ * platforms it can't be implemented at all as a callable function.
+ * The GNU C compiler provides a built-in alloca() which we can use;
+ * in all other cases, provide a prototype, mainly to pacify various
+ * incarnations of lint. On platforms where alloca() is not in libc,
+ * programs which use it will fail to link when compiled with non-GNU
+ * compilers.
+ */
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
+#define alloca(sz) __builtin_alloca(sz)
+#else
+void *alloca(size_t);
+#endif
+#endif
+
__uint32_t
arc4random(void);
void arc4random_addrandom(unsigned char *dat, int datlen);
OpenPOWER on IntegriCloud