Hi, I guess the only way to make more applications or others running on Haiku seemed like this, I must placing the codes to Haiku source tree then create Jamfile, etc. In order to avoid those things, I find a way to create i586-pc-haiku-g++ can work with autoconf, etc on Linux, then use it to build a native gcc for Haiku. But when I compile applications on Haiku, I just notice that gcc 4.x is buggy likes François said, Sometimes, gcc print a message "received system's interrupt call" and quit when compiling. Second, I can't delete the files (except on Dano) after perl's "./Configure -d" or "./configure.gnu" run. I doubt the disk issue cause that, but nothing wrong to use "chkbfs /Haiku" on Dano. The procedures of that attached to this mail, hope the team could find out what's the problem. Thanks you for bringing Haiku to be a modern & powerful system. A.L.
Index: gcc/gcc/config/haiku.h =================================================================== --- gcc/gcc/config/haiku.h (revision 23146) +++ gcc/gcc/config/haiku.h (working copy) @@ -50,7 +50,10 @@ /* LIB_SPEC for Haiku */ #undef LIB_SPEC -#define LIB_SPEC "-lroot" +#define LIB_SPEC "\ + %{@:-o %f%u.out}%{!@:%{o*}%{!o:-o a.out}} \ + --no-undefined \ + -lroot" /* gcc runtime lib is built into libroot.so on Haiku */ /* ??? This is gonna be lovely when the next release of gcc has @@ -62,7 +65,7 @@ it was i386-mcount.o, but that doesn't exist in gcc 2.95.3 either. */ #undef STARTFILE_SPEC -#define STARTFILE_SPEC "crti.o%s crtbegin.o%s %{!nostart:start_dyn.o%s} init_term_dyn.o%s %{p:mcount.o%s}" +#define STARTFILE_SPEC "crti.o%s crtbegin.o%s %{!nostart:%{!shared:start_dyn.o%s}} init_term_dyn.o%s %{p:mcount.o%s}" #undef ENDFILE_SPEC #define ENDFILE_SPEC "crtend.o%s crtn.o%s" Index: gcc/gcc/gthr-haiku.h =================================================================== --- gcc/gcc/gthr-haiku.h (revision 23146) +++ gcc/gcc/gthr-haiku.h (working copy) @@ -91,9 +91,18 @@ 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; + #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 +163,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 */ Index: gcc/libstdc++-v3/src/mt_allocator.cc =================================================================== --- gcc/libstdc++-v3/src/mt_allocator.cc (revision 23146) +++ gcc/libstdc++-v3/src/mt_allocator.cc (working copy) @@ -225,7 +225,7 @@ ::operator delete(__bin._M_first); ::operator delete(__bin._M_free); ::operator delete(__bin._M_used); - ::operator delete(__bin._M_mutex); + ::operator delete((void*)__bin._M_mutex); } } else