POV-Ray : Newsgroups : povray.beta-test : Build povray 3.7 beta40 on mac osx : Re: Build povray 3.7 beta40 on mac osx Server Time
7 May 2024 20:35:43 EDT (-0400)
  Re: Build povray 3.7 beta40 on mac osx  
From: jonas bulow
Date: 21 Dec 2010 17:55:01
Message: <web.4d11287fea80a0bb7d4da7460@news.povray.org>
"xoros" <xor### [at] fakehostcom> wrote:
> Hello,
>
> I would like to build povray 3.7 beta40 on mac osx snow leopard, but it doesn't
> work.
> "./configure" works without any problems, but "make" always produces the
> following error:
>
> .../../source/backend/support/task.h:184: error: thread-local storage not
> supported for this target
>
> MacMegaPov isn't an option for me, because I need a command line version of
> povray.
>
> Best regards

The patch below will make povray 3.7 beta40 compile fine on max osx.
Unfortunately, I'm not allowed to post attachements to this newsgroup so I also
put it here: http://pastebin.com/TYugP76L .

The idea is to use the thread local storage API defined by POSIX. It's not as
convenient as gcc's __thread but it is portable on POSIX platforms.

The last part of the patch brings the type uint alive by including sys/types.h.


diff -uwr original/povray-3.7.0.beta.40/source/backend/frame.h
new/povray-3.7.0.beta.40/source/backend/frame.h
--- original/povray-3.7.0.beta.40/source/backend/frame.h 2010-12-06
12:55:33.000000000 +0100
+++ new/povray-3.7.0.beta.40/source/backend/frame.h 2010-12-21
22:59:33.000000000 +0100
@@ -96,6 +96,9 @@

 // Generic header for all modules

+#include <pthread.h>
+
+
 #include <new>

 #include <stdio.h>
@@ -1898,9 +1901,55 @@
 // you'll need to fix your platform-specific config to provide a means to
declare
 // thread-local variables. support for TLS is required for efficient access by
the
 // render threads to their stats and cache data.
+
+
 #ifndef DECLARE_THREAD_LOCAL_PTR
+#ifdef __APPLE__
+template<typename T>
+class Pthread_Thread_Local_Storage
+{
+ public:
+ Pthread_Thread_Local_Storage()
+  {
+    pthread_key_create(&m_key, NULL);
+  }
+
+ Pthread_Thread_Local_Storage(T *ptr)
+  {
+    pthread_key_create(&m_key, NULL);
+    pthread_setspecific(m_key, ptr);
+  }
+ //  ~Pthread_Thread_Local_Storage() {};
+
+  Pthread_Thread_Local_Storage& operator=(T const &rhs)
+  {
+    pthread_setspecific(m_key, rhs);
+    return *this;
+  };
+
+  bool operator!=(T* rhs)
+  {
+    return pthread_getspecific(m_key) != rhs;
+  }
+
+  T* operator->() const
+  {
+    return static_cast<T*>(pthread_getspecific(m_key));
+  }
+
+  operator T*() const
+  {
+    return static_cast<T*>(pthread_getspecific(m_key));
+  }
+
+ private:
+  pthread_key_t m_key;
+};
+#  define DECLARE_THREAD_LOCAL_PTR(ptrType, ptrName)
Pthread_Thread_Local_Storage<ptrType> ptrName;
+#else
 #define DECLARE_THREAD_LOCAL_PTR(ptrType, ptrName)       __thread ptrType
*ptrName;
 #endif
+#endif

 }

diff -uwr original/povray-3.7.0.beta.40/vfe/vfesession.h
new/povray-3.7.0.beta.40/vfe/vfesession.h
--- original/povray-3.7.0.beta.40/vfe/vfesession.h 2010-12-06 12:55:33.000000000
+0100
+++ new/povray-3.7.0.beta.40/vfe/vfesession.h 2010-12-21 22:36:54.000000000
+0100
@@ -94,6 +94,8 @@
 #ifndef __VFESESSION_H__
 #define __VFESESSION_H__

+#include <sys/types.h>
+
 #include <queue>

 namespace vfe


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.