pthreads: better error handling
pthreads: simulate compare and swap for m68k
pthreads: merge condition in pthread_cond_timedwait