summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorDoug Luce <doug@github.con.com>2015-06-18 11:07:16 -0700
committerNicolas Williams <nico@cryptonector.com>2015-06-18 19:19:15 -0500
commit3cbefde37656f2d3655e020e5922d33f44834187 (patch)
treed0ee04f93eb73a3eadd4ce689e770e81265f9c05 /builtin.c
parent0b424579291c1da2d5adb439b66a090dc023c1ea (diff)
Add alloca() discovery to configure.ac
The build failed on FreeBSD as there is no alloca.h. This patch is lifted from the autoconf documentation.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 1e3f0854..4d538eac 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1,10 +1,22 @@
#define _BSD_SOURCE
#define _XOPEN_SOURCE
#include <sys/time.h>
-#ifdef WIN32
- #include <malloc.h>
-#else
- #include <alloca.h>
+#include <stdlib.h>
+#include <stddef.h>
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif !defined alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# elif defined _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# elif !defined HAVE_ALLOCA
+# ifdef __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
+# endif
#endif
#include <assert.h>
#include <ctype.h>
@@ -13,7 +25,6 @@
#ifdef HAVE_ONIGURUMA
#include <oniguruma.h>
#endif
-#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "builtin.h"