Mercurial > libjeffpc
changeset 622:e7ac3c21c816
mem: include alloca.h only if it exists
Some OSes (notably FreeBSD) do not have alloca.h at all. Instead, they
define alloca in stdlib.h.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 03 Nov 2018 07:43:27 -0400 |
parents | 255297676cd6 |
children | 64b6b0639001 |
files | cmake/config.cmake include/jeffpc/config.h.in include/jeffpc/mem.h |
diffstat | 3 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cmake/config.cmake Sat Nov 03 07:54:45 2018 -0400 +++ b/cmake/config.cmake Sat Nov 03 07:43:27 2018 -0400 @@ -69,6 +69,7 @@ JEFFPC_HAVE_PTHREAD_COND_RELTIMEDWAIT_NP) check_function_exists(reallocarray JEFFPC_HAVE_REALLOCARRAY) check_function_exists(recallocarray JEFFPC_HAVE_RECALLOCARRAY) +check_include_files(alloca.h JEFFPC_HAVE_ALLOCA_H) check_include_files(sys/debug.h JEFFPC_HAVE_SYS_DEBUG_H) check_symbol_exists(EAI_ADDRFAMILY "netdb.h" JEFFPC_HAVE_EAI_ADDRFAMILY) check_symbol_exists(EAI_NODATA "netdb.h" JEFFPC_HAVE_EAI_NODATA)
--- a/include/jeffpc/config.h.in Sat Nov 03 07:54:45 2018 -0400 +++ b/include/jeffpc/config.h.in Sat Nov 03 07:43:27 2018 -0400 @@ -34,6 +34,7 @@ #cmakedefine JEFFPC_HAVE_PTHREAD_COND_RELTIMEDWAIT_NP #cmakedefine JEFFPC_HAVE_REALLOCARRAY #cmakedefine JEFFPC_HAVE_RECALLOCARRAY +#cmakedefine JEFFPC_HAVE_ALLOCA_H #cmakedefine JEFFPC_HAVE_SYS_DEBUG_H #cmakedefine JEFFPC_HAVE_EAI_ADDRFAMILY #cmakedefine JEFFPC_HAVE_EAI_NODATA
--- a/include/jeffpc/mem.h Sat Nov 03 07:54:45 2018 -0400 +++ b/include/jeffpc/mem.h Sat Nov 03 07:43:27 2018 -0400 @@ -25,8 +25,13 @@ #include <stdlib.h> #include <stdint.h> +#include <string.h> + +#include <jeffpc/config.h> + +#ifdef JEFFPC_HAVE_ALLOCA_H #include <alloca.h> -#include <string.h> +#endif /* * zeroed allocation