From 88efcf30bd731485e380e0e35979b520eee919ca Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Sun, 10 Dec 2000 03:13:53 +0000 Subject: [PATCH] Attempt to fix |address_of| bustage on IRIX. r=scc@mozilla.org b=59414 git-svn-id: svn://10.0.0.236/trunk@83454 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/configure.in | 13 +++++++++++ mozilla/xpcom/base/nsCOMPtr.h | 42 +++++++++++++++++++++++++++++++++++ mozilla/xpcom/glue/nsCOMPtr.h | 42 +++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/mozilla/configure.in b/mozilla/configure.in index db1bd5dbdf4..d1286c65ac8 100644 --- a/mozilla/configure.in +++ b/mozilla/configure.in @@ -2643,6 +2643,19 @@ if test "$ac_cv_need_cpp_template_cast_to_base" = yes ; then AC_DEFINE(NEED_CPP_TEMPLATE_CAST_TO_BASE) fi +dnl Some compilers have trouble resolving the ambiguity between two +dnl functions whose arguments differ only by cv-qualifications. +AC_CACHE_CHECK(whether the compiler cannot resolve const ambiguities correctly, + ac_cv_cant_resolve_const_ambiguity, + [AC_TRY_COMPILE([int a(int *i) { return *i; } + const int a(const int *i) { return *i; } ], + [ int i; a(&i); ], + ac_cv_cant_resolve_const_ambiguity=no, + ac_cv_cant_resolve_const_ambiguity=yes)]) +if test "$ac_cv_cant_resolve_const_ambiguity" = yes ; then + AC_DEFINE(CANT_RESOLVE_CPP_CONST_AMBIGUITY) +fi + dnl dnl We dont do exceptions on unix. The only reason this used to be here dnl is that mozilla/xpcom/tests/TestCOMPtr.cpp has a test which uses diff --git a/mozilla/xpcom/base/nsCOMPtr.h b/mozilla/xpcom/base/nsCOMPtr.h index 68b811b9dfb..b4df3f7f053 100644 --- a/mozilla/xpcom/base/nsCOMPtr.h +++ b/mozilla/xpcom/base/nsCOMPtr.h @@ -649,6 +649,17 @@ class nsCOMPtr return get(); } +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + // broken version for IRIX + + nsCOMPtr* + get_address() const + { + return NS_CONST_CAST(nsCOMPtr*, this); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + nsCOMPtr* get_address() { @@ -661,6 +672,8 @@ class nsCOMPtr return this; } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + // This is going to become private soon, once all users of // nsCOMPtr stop using it. It may even become: // void operator&() const {} @@ -851,6 +864,17 @@ class nsCOMPtr return get(); } +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + // broken version for IRIX + + nsCOMPtr* + get_address() const + { + return NS_CONST_CAST(nsCOMPtr*, this); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + nsCOMPtr* get_address() { @@ -863,6 +887,8 @@ class nsCOMPtr return this; } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + // This is going to become private soon, once all users of // nsCOMPtr stop using it. It may even become: // void operator&() const {} @@ -943,6 +969,20 @@ nsCOMPtr::begin_assignment() } #endif +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + +// This is the broken version for IRIX, which can't handle the version below. + +template +inline +nsCOMPtr* +address_of( const nsCOMPtr& aPtr ) + { + return aPtr.get_address(); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + template inline nsCOMPtr* @@ -959,6 +999,8 @@ address_of( const nsCOMPtr& aPtr ) return aPtr.get_address(); } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + template class nsGetterAddRefs /* diff --git a/mozilla/xpcom/glue/nsCOMPtr.h b/mozilla/xpcom/glue/nsCOMPtr.h index 68b811b9dfb..b4df3f7f053 100644 --- a/mozilla/xpcom/glue/nsCOMPtr.h +++ b/mozilla/xpcom/glue/nsCOMPtr.h @@ -649,6 +649,17 @@ class nsCOMPtr return get(); } +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + // broken version for IRIX + + nsCOMPtr* + get_address() const + { + return NS_CONST_CAST(nsCOMPtr*, this); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + nsCOMPtr* get_address() { @@ -661,6 +672,8 @@ class nsCOMPtr return this; } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + // This is going to become private soon, once all users of // nsCOMPtr stop using it. It may even become: // void operator&() const {} @@ -851,6 +864,17 @@ class nsCOMPtr return get(); } +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + // broken version for IRIX + + nsCOMPtr* + get_address() const + { + return NS_CONST_CAST(nsCOMPtr*, this); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + nsCOMPtr* get_address() { @@ -863,6 +887,8 @@ class nsCOMPtr return this; } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + // This is going to become private soon, once all users of // nsCOMPtr stop using it. It may even become: // void operator&() const {} @@ -943,6 +969,20 @@ nsCOMPtr::begin_assignment() } #endif +#ifdef CANT_RESOLVE_CPP_CONST_AMBIGUITY + +// This is the broken version for IRIX, which can't handle the version below. + +template +inline +nsCOMPtr* +address_of( const nsCOMPtr& aPtr ) + { + return aPtr.get_address(); + } + +#else // CANT_RESOLVE_CPP_CONST_AMBIGUITY + template inline nsCOMPtr* @@ -959,6 +999,8 @@ address_of( const nsCOMPtr& aPtr ) return aPtr.get_address(); } +#endif // CANT_RESOLVE_CPP_CONST_AMBIGUITY + template class nsGetterAddRefs /*