From bb1dcc9aab5f517d963b601289aa75508d6e088e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 2 Feb 2010 12:45:38 +0100 Subject: more thorough fix for systems with strange socklen_t Signed-off-by: Denys Vlasenko --- include/inet_common.h | 8 +++++++- include/libbb.h | 40 +++++++++++++++++++++++----------------- include/platform.h | 12 ------------ include/unicode.h | 4 ++++ networking/ifconfig.c | 2 +- networking/interface.c | 2 +- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/include/inet_common.h b/include/inet_common.h index f4374e5a2..4638aa9eb 100644 --- a/include/inet_common.h +++ b/include/inet_common.h @@ -6,8 +6,10 @@ * Heavily modified by Manuel Novoa III Mar 12, 2001 * */ +#ifndef INET_COMMON_H +#define INET_COMMON_H 1 -#include "platform.h" +PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN /* hostfirst!=0 If we expect this to be a hostname, try hostname database first @@ -24,3 +26,7 @@ int INET6_resolve(const char *name, struct sockaddr_in6 *sin6) FAST_FUNC; /* These return malloced string */ char *INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t netmask) FAST_FUNC; char *INET6_rresolve(struct sockaddr_in6 *sin6, int numeric) FAST_FUNC; + +POP_SAVED_FUNCTION_VISIBILITY + +#endif diff --git a/include/libbb.h b/include/libbb.h index 3b7eea286..9e3c18407 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -30,10 +30,6 @@ #include #include #include -#if defined __FreeBSD__ -# include -# include -#endif #include #include #include @@ -44,39 +40,26 @@ /* Try to pull in PATH_MAX */ #include #include -#ifndef PATH_MAX -# define PATH_MAX 256 -#endif - -#ifndef BUFSIZ -# define BUFSIZ 4096 -#endif - #ifdef HAVE_MNTENT_H #include #endif - #ifdef HAVE_SYS_STATFS_H #include #endif - #if ENABLE_SELINUX #include #include #include #include #endif - #if ENABLE_LOCALE_SUPPORT # include #else # define setlocale(x,y) ((void)0) #endif - #ifdef DMALLOC # include #endif - #include #include #if ENABLE_FEATURE_SHADOWPASSWDS @@ -87,6 +70,23 @@ # include # endif #endif +#if defined __FreeBSD__ +# include +# include +#elif defined __APPLE__ +# include +#else +# include +# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) +/* We #define socklen_t *after* includes, otherwise we get + * typedef redefinition errors from system headers + * (in case "is it defined already" detection above failed) + */ +# define socklen_t bb_socklen_t + typedef unsigned socklen_t; +# endif +#endif + /* Some libc's forget to declare these, do it ourself */ @@ -121,6 +121,12 @@ struct sysinfo { char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding: libc5 uses this.. */ }; int sysinfo(struct sysinfo* info); +#ifndef PATH_MAX +# define PATH_MAX 256 +#endif +#ifndef BUFSIZ +# define BUFSIZ 4096 +#endif /* Make all declarations hidden (-fvisibility flag only affects definitions) */ diff --git a/include/platform.h b/include/platform.h index c34a46e79..b58b14936 100644 --- a/include/platform.h +++ b/include/platform.h @@ -210,18 +210,6 @@ } while (0) #endif -/* ---- Networking ------------------------------------------ */ - -#ifndef __APPLE__ -# include -# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) -# define socklen_t bb_socklen_t -typedef int socklen_t; -# endif -#else -# include -#endif - /* ---- Compiler dependent settings ------------------------- */ #if (defined __digital__ && defined __unix__) \ diff --git a/include/unicode.h b/include/unicode.h index 25ef7407e..7ab044e17 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -5,6 +5,8 @@ #ifndef UNICODE_H #define UNICODE_H 1 +PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN + enum { UNICODE_UNKNOWN = 0, UNICODE_OFF = 1, @@ -79,4 +81,6 @@ int iswpunct(wint_t wc) FAST_FUNC; #endif /* FEATURE_ASSUME_UNICODE */ +POP_SAVED_FUNCTION_VISIBILITY + #endif diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 1e960d45c..1a56c1cd5 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -36,8 +36,8 @@ #include #include #endif -#include "inet_common.h" #include "libbb.h" +#include "inet_common.h" #if ENABLE_FEATURE_IFCONFIG_SLIP # include diff --git a/networking/interface.c b/networking/interface.c index b64d24a58..0d5a0f97d 100644 --- a/networking/interface.c +++ b/networking/interface.c @@ -33,8 +33,8 @@ #include #include -#include "inet_common.h" #include "libbb.h" +#include "inet_common.h" #if ENABLE_FEATURE_HWIB -- cgit v1.2.3