[PATCH] kdelibs/kjs

Adriaan de Groot <[email protected]>
Newsgroups gmane.comp.kde.solaris
Message-ID <[email protected]>
In order to get kdelibs/kjs to compile, you must:

1) work around compiler bugs in templates
2) make some types more explicit in template returns

This is done in patch kjs-wtf-solaris.diff. Then

3) the c99 float classification macros isinf, signbit do not exist in C++
4) pthread_attr_get is missing

This is handled (badly!) in kjs-solaris.diff.

Find both attached. This just makes it compile. On my system, isinf() falls 
back to finite() and signbit just doesn't exist at all, so I use (f<0.0) 
which is probably very wrong).




-- 
These are your friends - Adem
    GPG: FEA2 A3FE Adriaan de Groot

___________________________________________________
This message is from the kde-solaris mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde-solaris.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.
kjs-solaris.diff (text/x-diff, 2.2 KB)
Index: math_object.cpp
===================================================================
--- math_object.cpp	(revision 701565)
+++ math_object.cpp	(working copy)
@@ -48,6 +48,10 @@
 
 #endif
 
+#if PLATFORM(SOLARIS_OS)
+#define signbit(d) (d<0.0)
+#endif
+
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
 #endif  /*  M_PI  */
Index: collector.cpp
===================================================================
--- collector.cpp	(revision 701565)
+++ collector.cpp	(working copy)
@@ -325,9 +325,15 @@
         // also on NetBSD 3 and 4, [email protected]
         pthread_attr_get_np(thread, &sattr);
 #else
+#if PLATFORM(SOLARIS_OS)
+	// Assume the default parameters were used.
+	// Solaris has no way to retrieve the values for a running thread.
+	pthread_attr_init(&sattr);
+#else
         // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
         pthread_getattr_np(thread, &sattr);
 #endif
+#endif
         // Should work but fails on Linux (?)
         //  pthread_attr_getstack(&sattr, &stackBase, &stackSize);
         pthread_attr_getstackaddr(&sattr, &stackBase);
Index: operations.cpp
===================================================================
--- operations.cpp	(revision 701565)
+++ operations.cpp	(working copy)
@@ -64,7 +64,7 @@
 #if PLATFORM(WIN_OS)
     int fpClass = _fpclass(d);
     return _FPCLASS_PINF == fpClass || _FPCLASS_NINF == fpClass;
-#elif HAVE(FUNC_ISINF)
+#elif HAVE(FUNC_ISINF) && !PLATFORM(SOLARIS_OS)
     return isinf(d);
 #elif HAVE(FUNC_FINITE)
     return finite(d) == 0 && d == d;
@@ -80,7 +80,7 @@
     // FIXME: should be HAVE(_FPCLASS)
 #if PLATFORM(WIN_OS)
     return _FPCLASS_PINF == _fpclass(d);
-#elif HAVE(FUNC_ISINF)
+#elif HAVE(FUNC_ISINF) && !PLATFORM(SOLARIS_OS)
     return (isinf(d) == 1);
 #elif HAVE(FUNC_FINITE)
     return !finite(d) && d == d; // ### can we distinguish between + and - ?
@@ -96,7 +96,7 @@
     // FIXME: should be HAVE(_FPCLASS)
 #if PLATFORM(WIN_OS)
     return _FPCLASS_NINF == _fpclass(d);
-#elif HAVE(FUNC_ISINF)
+#elif HAVE(FUNC_ISINF) && !PLATFORM(SOLARIS_OS)
     return (isinf(d) == -1);
 #elif HAVE(FUNC_FINITE)
     return finite(d) == 0 && d == d; // ###
kjs-wtf-solaris.diff (text/x-diff, 5.1 KB)
Index: wtf/HashSet.h
===================================================================
--- wtf/HashSet.h	(revision 701565)
+++ wtf/HashSet.h	(working copy)
@@ -265,7 +265,8 @@
     {
         const bool canReplaceDeletedValue = !ValueTraits::needsDestruction || StorageTraits::needsDestruction;
         typedef HashSetTranslator<canReplaceDeletedValue, ValueType, StorageTraits, HashFunctions> Translator;
-        return m_impl.template add<ValueType, ValueType, Translator>(value, value);
+        std::pair<HashTableType::iterator,bool> p = m_impl.template add<ValueType, ValueType, Translator>(value, value);
+	return std::make_pair(iterator(p.first),p.second);
     }
 
     template<typename Value, typename HashFunctions, typename Traits>
@@ -275,7 +276,8 @@
     {
         const bool canReplaceDeletedValue = !ValueTraits::needsDestruction || StorageTraits::needsDestruction;
         typedef HashSetTranslatorAdapter<canReplaceDeletedValue, ValueType, StorageTraits, T, Translator> Adapter;
-        return m_impl.template add<T, T, Adapter>(value, value);
+        std::pair<HashTableType::iterator,bool> p = m_impl.template add<T, T, Adapter>(value, value);
+	return std::make_pair(iterator(p.first),p.second);
     }
 
     template<typename T, typename U, typename V>
Index: wtf/HashTraits.h
===================================================================
--- wtf/HashTraits.h	(revision 701565)
+++ wtf/HashTraits.h	(working copy)
@@ -94,15 +94,22 @@
         static unsigned long long deletedValue() { return static_cast<unsigned long long>(-1); }
     };
     
+#if PLATFORM(SOLARIS_OS)
+# warning Assuming all pointers are sized like void *
+# define TEMPLATE_PTR_SIZEOF(P) sizeof(void *)
+#else
+# define TEMPLATE_PTR_SIZEOF(P) sizeof(P*)
+#endif
+
     template<typename P> struct HashTraits<P*> : GenericHashTraits<P*> {
-        typedef HashTraits<typename IntTypes<sizeof(P*)>::SignedType> StorageTraits;
+        typedef HashTraits<typename IntTypes<TEMPLATE_PTR_SIZEOF(P)>::SignedType> StorageTraits;
         static const bool emptyValueIsZero = true;
         static const bool needsDestruction = false;
         static P* deletedValue() { return reinterpret_cast<P*>(-1); }
     };
 
     template<typename P> struct HashTraits<RefPtr<P> > : GenericHashTraits<RefPtr<P> > {
-        typedef HashTraits<typename IntTypes<sizeof(P*)>::SignedType> StorageTraits;
+        typedef HashTraits<typename IntTypes<TEMPLATE_PTR_SIZEOF(P)>::SignedType> StorageTraits;
         static const bool emptyValueIsZero = true;
         static const bool needsRef = true;
         static void ref(const RefPtr<P>& p) { if (p) p->ref(); }
@@ -186,12 +193,12 @@
         typedef TraitsArg Traits;
     };
     template<typename P> struct HashKeyStorageTraits<PtrHash<P*>, HashTraits<P*> > {
-        typedef typename IntTypes<sizeof(P*)>::SignedType IntType;
+        typedef typename IntTypes<TEMPLATE_PTR_SIZEOF(P)>::SignedType IntType;
         typedef IntHash<IntType> Hash;
         typedef HashTraits<IntType> Traits;
     };
     template<typename P> struct HashKeyStorageTraits<PtrHash<RefPtr<P> >, HashTraits<RefPtr<P> > > {
-        typedef typename IntTypes<sizeof(P*)>::SignedType IntType;
+        typedef typename IntTypes<TEMPLATE_PTR_SIZEOF(P)>::SignedType IntType;
         typedef IntHash<IntType> Hash;
         typedef HashTraits<IntType> Traits;
     };
Index: wtf/HashMap.h
===================================================================
--- wtf/HashMap.h	(revision 701565)
+++ wtf/HashMap.h	(working copy)
@@ -260,7 +260,8 @@
     {
         const bool canReplaceDeletedKey = !KeyTraits::needsDestruction || KeyStorageTraits::needsDestruction;
         typedef HashMapTranslator<canReplaceDeletedKey, ValueType, ValueStorageTraits, HashFunctions> TranslatorType;
-        return m_impl.template add<KeyType, MappedType, TranslatorType>(key, mapped);
+        std::pair<HashTableType::iterator,bool> p = m_impl.template add<KeyType, MappedType, TranslatorType>(key, mapped);
+        return std::make_pair(iterator(p.first),p.second);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
Index: wtf/Platform.h
===================================================================
--- wtf/Platform.h	(revision 701565)
+++ wtf/Platform.h	(working copy)
@@ -67,6 +67,14 @@
 #define WTF_PLATFORM_UNIX 1
 #endif
 
+/* PLATFORM(SOLARIS_OS)
+/* Operating system level dependencies for Sun (Open)Solaris 10. */
+/* The detection is a little dodgy -- it's not impossible to use */
+/* Sun Studio (the compiler) on non-Solaris platforms. */
+#if defined(__SUNPRO_CC)
+#define WTF_PLATFORM_SOLARIS_OS 1
+#endif
+
 /* Operating environments */
 
 /* I made the BUILDING_KDE__ macro up for the KDE build system to define */
@@ -144,6 +152,11 @@
 #define WTF_COMPILER_GCC 1
 #endif
 
+/* COMPILER(SUNPRO) */
+#if defined(__SUNPRO_CC)
+#define WTF_COMPILER_SUNPRO 1
+#endif
+
 /* COMPILER(BORLAND) */
 /* not really fully supported - is this relevant any more? */
 #if defined(__BORLANDC__)
@@ -156,6 +169,7 @@
 #define WTF_COMPILER_CYGWIN 1
 #endif
 
+
 /* multiple threads only supported on Mac for now */
 #if PLATFORM(MAC)
 #ifndef WTF_USE_MULTIPLE_THREADS
signature.asc (application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (FreeBSD)

iD8DBQBGx3d6dqzuAf6io/4RAlZHAJ4vkCsZdivDsUrVuSs4iRrIFF7oYgCeOTb4
mX4Jum94fucSyPtcjP8k9sY=
=Zhop
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.