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:
@@ -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 */
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <compat.h>
|
||||
#ifndef HAVE_STRLCAT
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -57,7 +53,3 @@ __strlcat(char *dst, const char *src, size_t dsize)
|
||||
|
||||
return(dlen + (src - osrc)); /* count does not include NUL */
|
||||
}
|
||||
|
||||
weak_alias(__strlcat, strlcat);
|
||||
|
||||
#endif /* HAVE_STRLCAT */
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <compat.h>
|
||||
#ifndef HAVE_STRLCPY
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -52,7 +48,3 @@ __strlcpy(char *dst, const char *src, size_t dsize)
|
||||
|
||||
return(src - osrc - 1); /* count does not include NUL */
|
||||
}
|
||||
|
||||
weak_alias(__strlcpy, strlcpy);
|
||||
|
||||
#endif /* HAVE_STRLCPY */
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#ifndef HAVE_UTIMENSAT
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
@@ -47,7 +44,3 @@ __utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int fl
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
weak_alias(__utimensat, utimensat);
|
||||
|
||||
#endif /* HAVE_UTIMENSAT */
|
||||
|
||||
Reference in New Issue
Block a user