Check for getprogname() et al, and use config.h for #ifndefs

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-04 10:55:52 +01:00
parent ad70b49790
commit 8f66822b2a
2 changed files with 13 additions and 3 deletions

View File

@ -44,6 +44,9 @@ PKG_PROG_PKG_CONFIG
AC_REPLACE_FUNCS([pidfile strlcpy strlcat utimensat]) AC_REPLACE_FUNCS([pidfile strlcpy strlcat utimensat])
AC_CONFIG_LIBOBJ_DIR([lib]) AC_CONFIG_LIBOBJ_DIR([lib])
# Check for other library functions
AC_CHECK_FUNCS([getprogname strtobytes])
# Command line options # Command line options
AC_ARG_WITH(suspend-time, AC_ARG_WITH(suspend-time,
AS_HELP_STRING([--with-suspend-time=SEC], [Retry timeout for remote syslogd servers, default: 180]), AS_HELP_STRING([--with-suspend-time=SEC], [Retry timeout for remote syslogd servers, default: 180]),

View File

@ -30,6 +30,7 @@
#ifndef SYSKLOGD_COMPAT_H_ #ifndef SYSKLOGD_COMPAT_H_
#define SYSKLOGD_COMPAT_H_ #define SYSKLOGD_COMPAT_H_
#include <config.h>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -48,33 +49,38 @@
/* Pthread wrapper for BSD LWP mutexes */ /* Pthread wrapper for BSD LWP mutexes */
typedef pthread_mutex_t mutex_t; typedef pthread_mutex_t mutex_t;
#ifndef mutex_lock
#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define mutex_lock(m) pthread_mutex_lock(m) #define mutex_lock(m) pthread_mutex_lock(m)
#define mutex_unlock(m) pthread_mutex_unlock(m) #define mutex_unlock(m) pthread_mutex_unlock(m)
#endif
/* BSD have sa_len, Linux/GNU doesn't */ /* BSD have sa_len, Linux/GNU doesn't */
#if defined(_AIX) || (defined(BSD) && (BSD >= 199006)) /* sa_len was added with 4.3-Reno */ #if defined(_AIX) || (defined(BSD) && (BSD >= 199006)) /* sa_len was added with 4.3-Reno */
#define HAVE_SA_LEN #define HAVE_SA_LEN
#endif #endif
#ifndef strlcpy #ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz); size_t strlcpy(char *dst, const char *src, size_t siz);
#endif #endif
#ifndef strlcat #ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz); size_t strlcat(char *dst, const char *src, size_t siz);
#endif #endif
#ifndef pidfile #ifndef HAVE_PIDFILE
int pidfile(const char *basename); int pidfile(const char *basename);
#endif #endif
#ifndef HAVE_GETPROGNAME
static inline char *getprogname(void) static inline char *getprogname(void)
{ {
extern char *__progname; extern char *__progname;
return __progname; return __progname;
} }
#endif
#ifndef HAVE_STRTOBYTES
static inline int strtobytes(char *arg) static inline int strtobytes(char *arg)
{ {
int mod = 0, bytes; int mod = 0, bytes;
@ -103,6 +109,7 @@ static inline int strtobytes(char *arg)
return bytes; return bytes;
} }
#endif
static inline void parse_rotation(char *optarg, off_t *size, int *num) static inline void parse_rotation(char *optarg, off_t *size, int *num)
{ {