diff options
author | Doug Luce <doug@github.con.com> | 2015-06-18 11:07:16 -0700 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2015-06-18 19:19:15 -0500 |
commit | 3cbefde37656f2d3655e020e5922d33f44834187 (patch) | |
tree | d0ee04f93eb73a3eadd4ce689e770e81265f9c05 | |
parent | 0b424579291c1da2d5adb439b66a090dc023c1ea (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.
-rw-r--r-- | builtin.c | 21 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | util.c | 18 |
3 files changed, 35 insertions, 6 deletions
@@ -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" diff --git a/configure.ac b/configure.ac index bf236194..ccbe8dcb 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,8 @@ AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes]) AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes]) +AC_FUNC_ALLOCA + AC_FIND_FUNC([isatty], [c], [#include <unistd.h>], [0]) AC_FIND_FUNC([_isatty], [c], [#include <io.h>], [0]) AC_FIND_FUNC([strptime], [c], [#include <time.h>], [0, 0, 0]) @@ -10,8 +10,24 @@ #include <fcntl.h> #include <limits.h> #include <string.h> -#include <stdlib.h> #include <unistd.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 #ifndef WIN32 #include <pwd.h> #endif |