[PATCH xserver 4/4] meson: Detect strlcat/strlcpy/reallocarray in libbsd
Eric Engestrom
eric.engestrom at imgtec.com
Wed May 10 09:11:05 UTC 2017
On Tuesday, 2017-05-09 19:39:47 -0400, Peter Harris wrote:
> 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 <pharris at opentext.com>
> ---
> 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 40614e23b..7296b47b5 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..8fd8fb212 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -54,6 +54,12 @@ SOFTWARE.
> #ifdef MONOTONIC_CLOCK
> #include <time.h>
> #endif
> +#if defined HAVE_LIBBSD && defined HAVE_REALLOCARRAY
nit: most of the codebase uses `defined(FOO)` (313 vs 5 occurences)
quick sed to fix it: s/defined\s+(\w+)/defined\(\1\)/g
> +#include <bsd/stdlib.h> /* for reallocarray */
> +#endif
> +#if defined HAVE_LIBBSD && defined HAVE_STRLCPY
> +#include <bsd/string.h> /* for strlcpy, strlcat */
> +#endif
>
> #define SCREEN_SAVER_ON 0
> #define SCREEN_SAVER_OFF 1
> --
> 2.11.0
>
More information about the xorg-devel
mailing list