Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tools/compat Check for declarations, not the existance of fu...
details: https://anonhg.NetBSD.org/src/rev/2a6c071374ec
branches: trunk
changeset: 350173:2a6c071374ec
user: christos <christos%NetBSD.org@localhost>
date: Sat Jan 07 02:52:04 2017 +0000
description:
Check for declarations, not the existance of functions since some are
visible only when _NETBSD_SOURCE is defined. This avoids || defined(__NetBSD__)
hacks.
diffstat:
tools/compat/compat_defs.h | 82 +++++++++++++++++++++++----------------------
tools/compat/configure.ac | 33 ++++++++++++++++-
2 files changed, 72 insertions(+), 43 deletions(-)
diffs (truncated from 308 to 300 lines):
diff -r 80af81a447d7 -r 2a6c071374ec tools/compat/compat_defs.h
--- a/tools/compat/compat_defs.h Sat Jan 07 01:32:35 2017 +0000
+++ b/tools/compat/compat_defs.h Sat Jan 07 02:52:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_defs.h,v 1.104 2016/10/19 21:54:20 christos Exp $ */
+/* $NetBSD: compat_defs.h,v 1.105 2017/01/07 02:52:04 christos Exp $ */
#ifndef __NETBSD_COMPAT_DEFS_H__
#define __NETBSD_COMPAT_DEFS_H__
@@ -46,6 +46,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if HAVE_ERR_H
+#include <err.h>
+#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -63,6 +66,9 @@
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
+#if HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
#if HAVE_RPC_TYPES_H
#include <rpc/types.h>
@@ -219,19 +225,19 @@
/* Prototypes for replacement functions. */
-#if !HAVE_ATOLL
+#if !HAVE_DECL_ATOLL
long long int atoll(const char *);
#endif
-#if !HAVE_ASPRINTF
+#if !HAVE_DECL_ASPRINTF
int asprintf(char **, const char *, ...);
#endif
-#if !HAVE_ASNPRINTF
+#if !HAVE_DECL_ASNPRINTF
int asnprintf(char **, size_t, const char *, ...);
#endif
-#if !HAVE_BASENAME
+#if !HAVE_DECL_BASENAME
char *basename(char *);
#endif
@@ -241,7 +247,7 @@
extern int optind, opterr, optopt;
#endif
-#if !HAVE_DIRNAME
+#if !HAVE_DECL_DIRNAME
char *dirname(char *);
#endif
@@ -323,10 +329,10 @@
int evasprintf(char **, const char *, va_list);
#endif
-#if !HAVE_FGETLN || defined(__NetBSD__)
+#if !HAVE_DECL_FGETLN
char *fgetln(FILE *, size_t *);
#endif
-#if !HAVE_DPRINTF
+#if !HAVE_DECL_DPRINTF
int dprintf(int, const char *, ...);
#endif
@@ -338,7 +344,7 @@
int flock(int, int);
#endif
-#if !HAVE_FPARSELN || BROKEN_FPARSELN || defined(__NetBSD__)
+#if !HAVE_DECL_FPARSELN || BROKEN_FPARSELN
# define FPARSELN_UNESCESC 0x01
# define FPARSELN_UNESCCONT 0x02
# define FPARSELN_UNESCCOMM 0x04
@@ -347,16 +353,18 @@
char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
#endif
-#if !HAVE_GETLINE
+#if !HAVE_DECL_GETDELIM
ssize_t getdelim(char **, size_t *, int, FILE *);
+#endif
+#if !HAVE_DECL_GETLINE
ssize_t getline(char **, size_t *, FILE *);
#endif
-#if !HAVE_ISSETUGID
+#if !HAVE_DECL_ISSETUGID
int issetugid(void);
#endif
-#if !HAVE_ISBLANK && !defined(isblank)
+#if !HAVE_DECL_ISBLANK && !defined(isblank)
#define isblank(x) ((x) == ' ' || (x) == '\t')
#endif
@@ -389,11 +397,11 @@
#define bswap64(x) __nbcompat_bswap64(x)
#endif
-#if !HAVE_MKSTEMP
+#if !HAVE_DECL_MKSTEMP
int mkstemp(char *);
#endif
-#if !HAVE_MKDTEMP
+#if !HAVE_DECL_MKDTEMP
char *mkdtemp(char *);
#endif
@@ -403,11 +411,11 @@
int __nbcompat_gettemp(char *, int *, int);
#endif
-#if !HAVE_PREAD
+#if !HAVE_DECL_PREAD
ssize_t pread(int, void *, size_t, off_t);
#endif
-#if !HAVE_HEAPSORT
+#if !HAVE_DECL_HEAPSORT
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));
#endif
/* Make them use our version */
@@ -484,7 +492,7 @@
int lchown(const char *, uid_t, gid_t);
#endif
-#if !HAVE_PWRITE
+#if !HAVE_DECL_PWRITE
ssize_t pwrite(int, const void *, size_t, off_t);
#endif
@@ -492,11 +500,11 @@
int raise_default_signal(int);
#endif
-#if !HAVE_REALLOCARR
+#if !HAVE_DECL_REALLOCARR
int reallocarr(void *, size_t, size_t);
#endif
-#if !HAVE_SETENV
+#if !HAVE_DECL_SETENV
int setenv(const char *, const char *, int);
#endif
@@ -508,8 +516,10 @@
int setpassent(int);
#endif
-#if !HAVE_SETPROGNAME || defined(__NetBSD__)
+#if !HAVE_DECL_GETPROGNAME
const char *getprogname(void);
+#endif
+#if !HAVE_DECL_SETPROGNAME
void setprogname(const char *);
#endif
@@ -518,27 +528,19 @@
int snprintb_m(char *, size_t, const char *, uint64_t, size_t);
#endif
-#if !HAVE_SNPRINTF
+#if !HAVE_DECL_SNPRINTF
int snprintf(char *, size_t, const char *, ...);
#endif
-#if !HAVE_STRLCAT
-size_t strlcat(char *, const char *, size_t);
-#endif
-
-#if !HAVE_STRLCPY
-size_t strlcpy(char *, const char *, size_t);
-#endif
-
-#if !HAVE_STRMODE
+#if !HAVE_DECL_STRMODE
void strmode(mode_t, char *);
#endif
-#if !HAVE_STRNDUP
+#if !HAVE_DECL_STRNDUP
char *strndup(const char *, size_t);
#endif
-#if !HAVE_STRSEP || defined(__NetBSD__)
+#if !HAVE_DECL_STRSEP
char *strsep(char **, const char *);
#endif
@@ -548,37 +550,37 @@
long long, long long, char *, size_t);
#endif
-#if !HAVE_STRTOLL
+#if !HAVE_DECL_STRTOLL
long long strtoll(const char *, char **, int);
#endif
-#if !HAVE_STRTOI
+#if !HAVE_DECL_STRTOI
intmax_t strtoi(const char * __restrict, char ** __restrict, int,
intmax_t, intmax_t, int *);
#endif
-#if !HAVE_STRTOU
+#if !HAVE_DECL_STRTOU
uintmax_t strtou(const char * __restrict, char ** __restrict, int,
uintmax_t, uintmax_t, int *);
#endif
-#if !HAVE_USER_FROM_UID
+#if !HAVE_DECL_USER_FROM_UID
const char *user_from_uid(uid_t, int);
#endif
-#if !HAVE_GROUP_FROM_GID
+#if !HAVE_DECL_GROUP_FROM_GID
const char *group_from_gid(gid_t, int);
#endif
-#if !HAVE_VASPRINTF
+#if !HAVE_DECL_VASPRINTF
int vasprintf(char **, const char *, va_list);
#endif
-#if !HAVE_VASNPRINTF
+#if !HAVE_DECL_VASNPRINTF
int vasnprintf(char **, size_t, const char *, va_list);
#endif
-#if !HAVE_VSNPRINTF
+#if !HAVE_DECL_VSNPRINTF
int vsnprintf(char *, size_t, const char *, va_list);
#endif
diff -r 80af81a447d7 -r 2a6c071374ec tools/compat/configure.ac
--- a/tools/compat/configure.ac Sat Jan 07 01:32:35 2017 +0000
+++ b/tools/compat/configure.ac Sat Jan 07 02:52:04 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: configure.ac,v 1.85 2016/10/19 21:54:20 christos Exp $
+# $NetBSD: configure.ac,v 1.86 2017/01/07 02:52:04 christos Exp $
#
# Autoconf definition file for libnbcompat.
#
@@ -82,7 +82,7 @@
getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h rpc/types.h)
AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \
- stdint.h util.h resolv.h arpa/nameser.h,,
+ libgen.h stdint.h util.h resolv.h arpa/nameser.h,,
[test -f include/$ac_header || touch include/$ac_header])
AC_CHECK_HEADERS(rpc/types.h netconfig.h,,
[echo '#include "nbtool_config.h"' >include/$ac_header.new
@@ -140,6 +140,33 @@
AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>])
# Global variable decls.
+AC_CHECK_DECLS([asprintf, vasprintf, vasnprintf, vsnprintf, fgetln, fparseln
+ getdelim, getline, snprintf],,, [
+#include <stdio.h>
+])
+
+AC_CHECK_DECLS([atoll, heapsort, mkdtemp, mkstemp, reallocarr,
+ setenv, strtoi, strtoll, strtou, setprogname, getprogname],,, [
+#include <stdlib.h>
+])
+
+AC_CHECK_DECLS([basename, dirname],,, [
+#include <libgen.h>
+])
+
+AC_CHECK_DECLS([raise_default_signal],,, [
+#include <util.h>
+])
+
+AC_CHECK_DECLS([issetugid, pread, pwrite, strmode],,, [
+#include <unistd.h>
+])
+
+AC_CHECK_DECLS([isblank],,, [
+#include <ctype.h>
+])
+
+
AC_CHECK_DECLS([optind, optreset],,, [
#include <stdio.h>
#include <stdlib.h>
@@ -169,7 +196,7 @@
Home |
Main Index |
Thread Index |
Old Index