I'm too lazy to comment this
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 11 Jul 2002 21:22:55 +0000 (21:22 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Thu, 11 Jul 2002 21:22:55 +0000 (21:22 +0000)
Original commit message from CVS:
combined patch by me and lioux@FreeBSD.org

configure.ac
gst/gstthread.c

index 51566f6..34f9a0f 100644 (file)
@@ -320,6 +320,11 @@ if test "x$USE_ATOMIC_H" = xyes; then
   AC_DEFINE(HAVE_ATOMIC_H, 1, [Define if atomic.h header file is available])
 fi
 
+dnl test if we have pthread_attr_setstack; if not use the older calls
+AC_CHECK_LIB(pthread, pthread_attr_setstack, 
+   AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACK, 1, 
+   [Defined if libpthread has pthread_attr_setstack]))
+
 if test "x$PLUGINS_USE_BUILDDIR" = xyes; then
   AC_DEFINE(PLUGINS_USE_BUILDDIR, 1, [Define if plugins should be loaded from the build tree - only developers should use this])
 fi
index 061fa0e..3d23116 100644 (file)
@@ -178,7 +178,7 @@ gst_thread_init (GstThread *thread)
   thread->cond = g_cond_new ();
 
   thread->ppid = getpid ();
-  thread->thread_id = -1;
+  thread->thread_id = (pthread_t) -1;
   thread->sched_policy = SCHED_OTHER;
   thread->priority = 0;
 }
@@ -329,11 +329,23 @@ gst_thread_change_state (GstElement * element)
       if (pthread_attr_init (&thread->attr) != 0)
        g_warning ("pthread_attr_init returned an error !");
 
-      if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) {
+      if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), 
+                                            &thread->stack, &stacksize)) {
+#ifdef HAVE_PTHREAD_ATTR_SETSTACK
         if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) {
-          g_warning ("pthread_attr_setstack failed");
+          g_warning ("pthread_attr_setstack failed\n");
           return GST_STATE_FAILURE;
         }
+#else
+        if (pthread_attr_setstackaddr (&thread->attr, thread->stack) != 0) {
+         g_warning ("pthread_attr_setstackaddr failed\n");
+         return GST_STATE_FAILURE;
+       }
+        if (pthread_attr_setstacksize (&thread->attr, stacksize) != 0) {
+         g_warning ("pthread_attr_setstacksize failed\n");
+         return GST_STATE_FAILURE;
+       }
+#endif
        GST_DEBUG (GST_CAT_THREAD, "pthread attr set stack at %p of size %ld", 
                   thread->stack, stacksize);
       }