Revert "Revert "Delete platform preprocessing macros. Rewrite semaphores as named. Delete unnamed semaphore""

This reverts commit 12bcb1d0d34a384a816dc1ff1e7d29a54c3a31ce.