Hi,
Forgive me, here is the corrected one, and do not modify
"buildtools/gcc/libstdc++-v3/src/mt_allocator.cc"
Index: buildtools/gcc/gcc/gthr-haiku.h
===================================================================
--- buildtools/gcc/gcc/gthr-haiku.h (revision 23146)
+++ buildtools/gcc/gcc/gthr-haiku.h (working copy)
@@ -91,9 +91,20 @@
typedef vint32 __gthread_once_t;
typedef vint32 __gthread_mutex_t;
+typedef struct {
+ thread_id holder;
+ __gthread_mutex_t mutex;
+ uint32 count;
+} __gthread_recursive_mutex_t;
+
+typedef vint32 __gthread_recursive_mutex_t;
+
#define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0
+#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
__gthread_recursive_mutex_init_function
+#define __GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT {-1, 0, 0}
+
static inline int __gthread_active_p ()
{
return 1;
@@ -154,4 +165,59 @@
return 0;
}
+
+static inline void __gthread_recursive_mutex_init_function
(__gthread_recursive_mutex_t *mutex)
+{
+ mutex->holder = -1;
+ mutex->mutex = 0;
+ mutex->count = 0;
+}
+
+static inline int __gthread_recursive_mutex_lock
(__gthread_recursive_mutex_t *mutex)
+{
+ thread_id cur_tid = find_thread(NULL);
+
+ __gthread_mutex_lock (&mutex->mutex);
+ while (mutex->holder != -1 && mutex->holder != cur_tid)
+ {
+ __gthread_mutex_unlock (&mutex->mutex);
+ snooze (3000);
+ __gthread_mutex_lock (&mutex->mutex);
+ }
+ mutex->holder = cur_tid;
+ mutex->count += 1;
+ __gthread_mutex_unlock (&mutex->mutex);
+
+ return 0;
+}
+
+static inline int __gthread_recursive_mutex_trylock
(__gthread_recursive_mutex_t *mutex)
+{
+ thread_id cur_tid = find_thread(NULL);
+
+ __gthread_mutex_lock (&mutex->mutex);
+ if (!(mutex->holder == -1 || mutex->holder == cur_tid))
+ {
+ __gthread_mutex_unlock (&mutex->mutex);
+ return EBUSY;
+ }
+ mutex->holder = cur_tid;
+ mutex->count += 1;
+ __gthread_mutex_unlock (&mutex->mutex);
+
+ return 0;
+}
+
+static inline int
+__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
+{
+ __gthread_mutex_lock (&mutex->mutex);
+ mutex->count -= 1;
+ if (mutex->count == 0)
+ mutex->holder = -1;
+ __gthread_mutex_unlock(&mutex->mutex);
+
+ return 0;
+}
+
#endif /* ! GCC_GTHR_HAIKU_H */
On Dec 27, 2007 6:29 AM, Anthony Lee <don.anthony.lee@xxxxxxxxx> wrote:
> sorry, recursive_mutex section is wrong !!!
> you should consider to change it...
>