fix threaded PPC build, refactor new semaphore code