From 8f66822b2a2d6d33871dbdb2a8a413a3b331f55a Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 4 Nov 2019 10:55:52 +0100 Subject: [PATCH] Check for getprogname() et al, and use config.h for #ifndefs Signed-off-by: Joachim Nilsson --- configure.ac | 3 +++ src/compat.h | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index dab5bbe..e5b55e1 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,9 @@ PKG_PROG_PKG_CONFIG AC_REPLACE_FUNCS([pidfile strlcpy strlcat utimensat]) AC_CONFIG_LIBOBJ_DIR([lib]) +# Check for other library functions +AC_CHECK_FUNCS([getprogname strtobytes]) + # Command line options AC_ARG_WITH(suspend-time, AS_HELP_STRING([--with-suspend-time=SEC], [Retry timeout for remote syslogd servers, default: 180]), diff --git a/src/compat.h b/src/compat.h index d140d8a..54b614d 100644 --- a/src/compat.h +++ b/src/compat.h @@ -30,6 +30,7 @@ #ifndef SYSKLOGD_COMPAT_H_ #define SYSKLOGD_COMPAT_H_ +#include #include #include #include @@ -48,33 +49,38 @@ /* Pthread wrapper for BSD LWP mutexes */ typedef pthread_mutex_t mutex_t; +#ifndef mutex_lock #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define mutex_lock(m) pthread_mutex_lock(m) #define mutex_unlock(m) pthread_mutex_unlock(m) +#endif /* BSD have sa_len, Linux/GNU doesn't */ #if defined(_AIX) || (defined(BSD) && (BSD >= 199006)) /* sa_len was added with 4.3-Reno */ #define HAVE_SA_LEN #endif -#ifndef strlcpy +#ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz); #endif -#ifndef strlcat +#ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz); #endif -#ifndef pidfile +#ifndef HAVE_PIDFILE int pidfile(const char *basename); #endif +#ifndef HAVE_GETPROGNAME static inline char *getprogname(void) { extern char *__progname; return __progname; } +#endif +#ifndef HAVE_STRTOBYTES static inline int strtobytes(char *arg) { int mod = 0, bytes; @@ -103,6 +109,7 @@ static inline int strtobytes(char *arg) return bytes; } +#endif static inline void parse_rotation(char *optarg, off_t *size, int *num) {