unbreaking alloca
Dag-Erling Smorgrav
des at ofug.org
Sat Jun 14 15:45:27 PDT 2003
Alexander Leidinger <Alexander at Leidinger.net> writes:
> Please also add a comment about the actual pitfalls (alloca function not
> possible to implement on AMD64, ... in libc and broken on IA32).
How's this?
@@ -222,7 +222,23 @@
extern void (*_malloc_message)(const char *, const char *, const char *,
const char *);
-void *alloca(size_t); /* built-in for gcc */
+/*
+ * 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.
+ */
+#ifdef __GNUC__
+#ifndef alloca
+#define alloca(sz) __builtin_alloca(sz)
+#endif
+#else
+void *alloca(size_t);
+#endif
+
__uint32_t
arc4random(void);
void arc4random_addrandom(unsigned char *dat, int datlen);
DES
--
Dag-Erling Smorgrav - des at ofug.org
More information about the freebsd-arch
mailing list