diff --git a/qse/include/qse/si/spl.h b/qse/include/qse/si/spl.h index c826e9da..33bfa9a9 100644 --- a/qse/include/qse/si/spl.h +++ b/qse/include/qse/si/spl.h @@ -211,13 +211,13 @@ asm void qse_spl_unlock (qse_spl_t* spl) __asm__ volatile ( "__back:\n" - "lwarx %0,0,%1\n" /* load and reserve. rc(%0) = *spl(%1) */ - "cmpwi cr0,%0,0\n" /* cr0 = (rc compare-with 0) */ - "li %0,0\n" /* rc = 0(failure) */ - "bne- __exit\n" /* if cr0 != 0, goto _exit; */ - "li %0,1\n" /* rc = 1(success) */ - "stwcx. %0,0,%1\n" /* *spl(%1) = 1(value in rc) if reserved */ - "bne- __back\n" /* if reservation is lost, goto __back */ + "lwarx %0,0,%1\n" /* load and reserve. rc(%0) = *spl(%1) */ + "cmpwi cr0,%0,0\n" /* cr0 = (rc compare-with 0) */ + "li %0,0\n" /* rc = 0(failure) */ + "bne cr0,__exit\n" /* if cr0 != 0, goto _exit; */ + "li %0,1\n" /* rc = 1(success) */ + "stwcx. %0,0,%1\n" /* *spl(%1) = 1(value in rc) if reserved */ + "bne cr0,__back\n" /* if reservation is lost, goto __back */ #if 1 "lwsync\n" #else @@ -233,20 +233,17 @@ asm void qse_spl_unlock (qse_spl_t* spl) } static QSE_INLINE void qse_spl_lock (qse_spl_t* spl) { - int x; - do - { - x = qse_spl_trylock(spl); - } - while (x); + while (!qse_spl_trylock(spl)) /* nothing */; } static QSE_INLINE void qse_spl_unlock (qse_spl_t* spl) { __asm__ volatile ( #if 1 "lwsync\n" - #else + #elif 0 "sync\n" + #else + "eieio\n" #endif : : diff --git a/qse/lib/awk/mod-math.c b/qse/lib/awk/mod-math.c index 0e4ad845..929f5b45 100644 --- a/qse/lib/awk/mod-math.c +++ b/qse/lib/awk/mod-math.c @@ -35,7 +35,7 @@ #include #if defined(HAVE_QUADMATH_H) # include -#elif defined(QSE_USE_AWK_FLTMAX) && (QSE_AWK_SIZEOF_FLT_T == 16) +#elif defined(QSE_USE_AWK_FLTMAX) && (QSE_AWK_SIZEOF_FLT_T == 16) && defined(QSE_FLTMAX_REQUIRE_QUADMATH) # error QUADMATH.H NOT AVAILABLE or NOT COMPILABLE #endif diff --git a/qse/lib/si/thr.c b/qse/lib/si/thr.c index 78fd1cba..95329b3d 100644 --- a/qse/lib/si/thr.c +++ b/qse/lib/si/thr.c @@ -30,6 +30,10 @@ #include #include +#if defined(HAVE_UNISTD_H) +# include +#endif + #if (!defined(__unix__) && !defined(__unix)) || defined(HAVE_PTHREAD) qse_thr_t* qse_thr_open (qse_mmgr_t* mmgr, qse_size_t xtnsize) @@ -208,14 +212,24 @@ static int __create_thread (qse_thr_t* thr) if (thr->__stacksize > 0) { - if (pthread_attr_setstacksize (&attr, thr->__stacksize) != 0) + int x; + qse_size_t ss = thr->__stacksize; + #if defined(PTHREAD_STACK_MIN) + if (ss < PTHREAD_STACK_MIN) ss = PTHREAD_STACK_MIN; + #endif + #if defined(_SC_PAGESIZE) + /* some systems(e.g. darwin 8.11.0/macosx) require the size + * to be page size aligned. */ + ss = QSE_ALIGNTO(ss, sysconf(_SC_PAGESIZE)); + #endif + if ((x = pthread_attr_setstacksize(&attr, ss)) != 0) { pthread_attr_destroy (&attr); return -1; } } - if (pthread_create (&thr->__handle, &attr, __thread_main, thr) != 0) + if (pthread_create(&thr->__handle, &attr, __thread_main, thr) != 0) { pthread_attr_destroy (&attr); return -1;