Simplify handling of replacement functions; strlcpy() & C:o

- Drop weak bindings, use simple #define in compat.h instead
- No need to #ifdef sources with HAVE_foo, configure handles this for us
- Move utimensat() declaration to compat.h from pidfile.c to be consistent

With these changes we can let libsyslog link with the replacement objs,
just like syslogd and logger does.  Because even if the C-library does
*not* have strlcpy() & C:o *and* an application has a local copy of any
of these APIs, our versions are prefixed with __ in the symbol table.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-01-19 09:07:14 +01:00
parent de4c349930
commit 5fce3001ed
5 changed files with 9 additions and 45 deletions

View File

@@ -31,9 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <config.h>
#ifndef HAVE_PIDFILE
#define _GNU_SOURCE /* Needed with GLIBC to get asprintf() */
#include <sys/stat.h> /* utimensat() */
#include <sys/time.h> /* utimensat() on *BSD */
@@ -42,11 +39,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "compat.h"
#ifndef HAVE_UTIMENSAT
int utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags);
#endif
#include "compat.h" /* For utimensat() if missing */
static char *pidfile_path = NULL;
static pid_t pidfile_pid = 0;
@@ -139,6 +132,3 @@ pidfile_cleanup(void)
pidfile_path = NULL;
}
}
weak_alias(__pidfile, pidfile);
#endif /* HAVE_PIDFILE */