From 0ff2fb128bf35dffaa302f15e9ae004b65ee0827 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Tue, 9 May 2017 19:39:47 -0400 Subject: [PATCH] meson: Detect strlcat/strlcpy/reallocarray in libbsd If we're linking with libbsd anyway, we might as well use the functions it provides instead of compiling our replacements. Signed-off-by: Peter Harris Reviewed-by: Eric Anholt --- include/meson.build | 6 +++--- include/os.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/meson.build b/include/meson.build index c3d7a8150..358e04976 100644 --- a/include/meson.build +++ b/include/meson.build @@ -112,15 +112,15 @@ conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid')) conf_data.set('HAVE_MMAP', cc.has_function('mmap')) conf_data.set('HAVE_POLL', cc.has_function('poll')) conf_data.set('HAVE_POSIX_FALLOCATE', cc.has_function('posix_fallocate')) -conf_data.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray')) +conf_data.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray', dependencies: libbsd_dep)) conf_data.set('HAVE_SETEUID', cc.has_function('seteuid')) conf_data.set('HAVE_SETITIMER', cc.has_function('setitimer')) conf_data.set('HAVE_SHMCTL64', cc.has_function('shmctl64')) conf_data.set('HAVE_SIGACTION', cc.has_function('sigaction')) conf_data.set('HAVE_STRCASECMP', cc.has_function('strcasecmp')) conf_data.set('HAVE_STRCASESTR', cc.has_function('strcasestr')) -conf_data.set('HAVE_STRLCAT', cc.has_function('strlcat')) -conf_data.set('HAVE_STRLCPY', cc.has_function('strlcpy')) +conf_data.set('HAVE_STRLCAT', cc.has_function('strlcat', dependencies: libbsd_dep)) +conf_data.set('HAVE_STRLCPY', cc.has_function('strlcpy', dependencies: libbsd_dep)) conf_data.set('HAVE_STRNCASECMP', cc.has_function('strncasecmp')) conf_data.set('HAVE_STRNDUP', cc.has_function('strndup')) conf_data.set('HAVE_TIMINGSAFE_MEMCMP', cc.has_function('timingsafe_memcmp')) diff --git a/include/os.h b/include/os.h index fb09d00c7..e141a6b02 100644 --- a/include/os.h +++ b/include/os.h @@ -54,6 +54,12 @@ SOFTWARE. #ifdef MONOTONIC_CLOCK #include #endif +#if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY) +#include /* for reallocarray */ +#endif +#if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY) +#include /* for strlcpy, strlcat */ +#endif #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1