From: Francesco Chemolli Date: Fri, 6 Nov 2009 16:22:16 +0000 (+0100) Subject: Bug 2778: fix linking issues using SunCC X-Git-Tag: SQUID_3_2_0_1~600 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=001771880aaad74b3931c231b20d8518e4fbecd6;p=thirdparty%2Fsquid.git Bug 2778: fix linking issues using SunCC SunCC doesn't handle inline extern functions, and misses some duplicate code detection features gcc has; as a result squid-specific operator new and operator delete get defined multiple times and fail linking. Implemented a compiler-specific workaround by de-inlining the code. Improved Solaris OS detection logic (and dropped _SQUID_SUNOS_ which was not used anyways) --- diff --git a/compat/compat.h b/compat/compat.h index 1600291711..fc9eb9360e 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -49,6 +49,7 @@ /* OS-macro wrapping should be done inside the OS .h */ /*****************************************************/ +#include "compat/os/solaris.h" #include "compat/os/aix.h" #include "compat/os/dragonfly.h" #include "compat/os/freebsd.h" @@ -60,7 +61,6 @@ #include "compat/os/os2.h" #include "compat/os/qnx.h" #include "compat/os/sgi.h" -#include "compat/os/solaris.h" #include "compat/os/sunos.h" #include "compat/os/windows.h" diff --git a/compat/os/solaris.h b/compat/os/solaris.h index 7c63a9bf51..b77db6de67 100644 --- a/compat/os/solaris.h +++ b/compat/os/solaris.h @@ -5,7 +5,8 @@ #ifndef SQUID_OS_SOLARIS_H #define SQUID_OS_SOLARIS_H -#ifdef _SQUID_SOLARIS_ + +#if _SQUID_SOLARIS_ /* * On Solaris 9 x86, gcc may includes a "fixed" set of old system @@ -44,6 +45,13 @@ SQUIDCEXTERN int getpagesize(void); SQUIDCEXTERN int gethostname(char *, int); #endif +/* + * SunPro CC handles extern inline as inline, PLUS extern symbols. + */ + +#if !defined(_SQUID_EXTERNNEW_) && defined(__SUNPRO_CC) +#define _SQUID_EXTERNNEW_ extern +#endif #endif /* _SQUID_SOLARIS_ */ diff --git a/compat/osdetect.h b/compat/osdetect.h index 847173fbec..7a68dc705f 100644 --- a/compat/osdetect.h +++ b/compat/osdetect.h @@ -15,76 +15,72 @@ * or other definitions within this if-else structure. */ -#if defined(__sun__) || defined(__sun) /* SUN */ -# define _SQUID_SUN_ -# if defined(__SVR4) /* SOLARIS */ -# define _SQUID_SOLARIS_ -# else /* SUNOS */ -# define _SQUID_SUNOS_ -# endif +/* SUN SOLARIS / OPENSOLARIS */ +#if defined(__sun__) || defined(__sun) || defined(__SUNPRO_CC) || defined(__SunOS_OSversion) +#define _SQUID_SOLARIS_ 1 #elif defined(__hpux) /* HP-UX - SysV-like? */ -#define _SQUID_HPUX_ -#define _SQUID_SYSV_ +#define _SQUID_HPUX_ 1 +#define _SQUID_SYSV_ 1 #elif defined(__osf__) /* OSF/1 */ -#define _SQUID_OSF_ +#define _SQUID_OSF_ 1 #elif defined(__ultrix) /* Ultrix */ -#define _SQUID_ULTRIX_ +#define _SQUID_ULTRIX_ 1 #elif defined(_AIX) /* AIX */ -#define _SQUID_AIX_ +#define _SQUID_AIX_ 1 -#elif defined(__linux__) /* Linux */ -#define _SQUID_LINUX_ +#elif defined(__linux__) /* Linux. WARNING: solaris-x86 also sets this */ +#define _SQUID_LINUX_ 1 #elif defined(__FreeBSD__) /* FreeBSD */ -#define _SQUID_FREEBSD_ +#define _SQUID_FREEBSD_ 1 #elif defined(__FreeBSD_kernel__) /* GNU/kFreeBSD */ -#define _SQUID_KFREEBSD_ +#define _SQUID_KFREEBSD_ 1 #elif defined(__sgi__) || defined(sgi) || defined(__sgi) /* SGI */ -#define _SQUID_SGI_ +#define _SQUID_SGI_ 1 #elif defined(__NeXT__) -#define _SQUID_NEXT_ +#define _SQUID_NEXT_ 1 -#elif defined(__bsdi__) -#define _SQUID_BSDI_ /* BSD/OS */ +#elif defined(__bsdi__) /* BSD/OS */ +#define _SQUID_BSDI_ 1 #elif defined(__NetBSD__) -#define _SQUID_NETBSD_ +#define _SQUID_NETBSD_ 1 #elif defined(__OpenBSD__) -#define _SQUID_OPENBSD_ +#define _SQUID_OPENBSD_ 1 #elif defined(__DragonFly__) -#define _SQUID_DRAGONFLY_ +#define _SQUID_DRAGONFLY_ 1 #elif defined(__CYGWIN32__) || defined(__CYGWIN__) -#define _SQUID_CYGWIN_ -#define _SQUID_WIN32_ +#define _SQUID_CYGWIN_ 1 +#define _SQUID_WIN32_ 1 #elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32) /* We are using _SQUID_MSWIN_ define in cf.data.pre, so it must be defined to 1 to avoid the build failure of cfgen. */ #define _SQUID_MSWIN_ 1 -#define _SQUID_WIN32_ +#define _SQUID_WIN32_ 1 #elif defined(__APPLE__) -#define _SQUID_APPLE_ +#define _SQUID_APPLE_ 1 #elif defined(sony_news) && defined(__svr4) -#define _SQUID_NEWSOS6_ +#define _SQUID_NEWSOS6_ 1 #elif defined(__QNX__) -#define _SQUID_QNX_ +#define _SQUID_QNX_ 1 #elif defined(__EMX__) || defined(OS2) || defined(__OS2__) -#define _SQUID_OS2_ +#define _SQUID_OS2_ 1 #endif /* OS automatic detection */ diff --git a/include/SquidNew.h b/include/SquidNew.h index 37b50c83ef..e30f7b46c1 100644 --- a/include/SquidNew.h +++ b/include/SquidNew.h @@ -35,6 +35,7 @@ #include "util.h" +#ifndef __SUNPRO_CC /* Any code using libstdc++ must have externally resolvable overloads * for void * operator new - which means in the .o for the binary, * or in a shared library. static libs don't propogate the symbol @@ -60,4 +61,7 @@ _SQUID_EXTERNNEW_ void operator delete[] (void *address) throw() xfree (address); } + +#endif /* __SUNPRO_CC */ + #endif /* SQUID_NEW_H */ diff --git a/src/SquidNew.cc b/src/SquidNew.cc index f6e7dcce37..74ba3719e4 100644 --- a/src/SquidNew.cc +++ b/src/SquidNew.cc @@ -33,5 +33,28 @@ * */ -#define _SQUID_EXTERNNEW_ +/* #define _SQUID_EXTERNNEW_ */ /* Why? kinkie */ #include "squid.h" + + +#ifdef __SUNPRO_CC + +#include +void *operator new(size_t size) throw (std::bad_alloc) +{ + return xmalloc(size); +} +void operator delete (void *address) throw() +{ + xfree (address); +} +void *operator new[] (size_t size) throw (std::bad_alloc) +{ + return xmalloc(size); +} +void operator delete[] (void *address) throw() +{ + xfree (address); +} + +#endif /* __SUNPRO_CC */