Module Name: src Committed By: christos Date: Tue Jun 12 23:52:56 UTC 2018
Modified Files: src/tools/compat: compat_defs.h Log Message: Move the typedefs before the header inclusions (except <features.h>) and explain why. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/tools/compat/compat_defs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tools/compat/compat_defs.h diff -u src/tools/compat/compat_defs.h:1.110 src/tools/compat/compat_defs.h:1.111 --- src/tools/compat/compat_defs.h:1.110 Mon Jun 11 14:48:24 2018 +++ src/tools/compat/compat_defs.h Tue Jun 12 19:52:56 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: compat_defs.h,v 1.110 2018/06/11 18:48:24 maya Exp $ */ +/* $NetBSD: compat_defs.h,v 1.111 2018/06/12 23:52:56 christos Exp $ */ #ifndef __NETBSD_COMPAT_DEFS_H__ #define __NETBSD_COMPAT_DEFS_H__ @@ -30,6 +30,48 @@ #define __USE_ISOC99 1 #endif /* __linux__ && HAVE_FEATURES_H */ +/* + * Type substitutes. + * These are controlled via HAVE_TYPE protections and some of them are needed + * in other header files (in the build tree not in the host). This is because + * we are mixing the header files (which don't need them) with extensions + * such as the Solaris headers which depend on types defined by the native + * system headers, and might be missing in the build host. + */ + +#if !HAVE_ID_T +typedef unsigned int id_t; +#endif + +#if !HAVE_SOCKLEN_T +/* + * This is defined as int for compatibility with legacy systems (and not + * unsigned int), since universally it was int in most systems that did not + * define it. + */ +typedef int socklen_t; +#endif + +#if !HAVE_U_LONG +typedef unsigned long u_long; +#endif + +#if !HAVE_U_CHAR +typedef unsigned char u_char; +#endif + +#if !HAVE_U_INT +typedef unsigned int u_int; +#endif + +#if !HAVE_U_SHORT +typedef unsigned short u_short; +#endif + +#if !HAVE_U_LONGLONG_T +typedef uint64_t u_longlong_t; +#endif + /* System headers needed for (re)definitions below. */ #include <sys/types.h> @@ -193,37 +235,6 @@ struct group; # endif #endif -/* Type substitutes. */ - -#if !HAVE_ID_T -typedef unsigned int id_t; -#endif - -#if !HAVE_SOCKLEN_T -/* - * This is defined as int for compatibility with legacy systems (and not - * unsigned int), since universally it was int in most systems that did not - * define it. - */ -typedef int socklen_t; -#endif - -#if !HAVE_U_LONG -typedef unsigned long u_long; -#endif - -#if !HAVE_U_CHAR -typedef unsigned char u_char; -#endif - -#if !HAVE_U_INT -typedef unsigned int u_int; -#endif - -#if !HAVE_U_SHORT -typedef unsigned short u_short; -#endif - /* Prototypes for replacement functions. */ #if !HAVE_DECL_ATOLL @@ -1298,10 +1309,6 @@ __GEN_ENDIAN_DEC(64, le) #define NBBY 8 #endif -#if !HAVE_U_LONGLONG_T -typedef uint64_t u_longlong_t; -#endif - #if !HAVE_U_QUAD_T /* #define, not typedef, as quad_t exists as a struct on some systems */ #define quad_t long long