The pthread wrapper uses semaphores to simulate condition variables,
but it is easy to hit the 3DS' limit of available semaphores. libctru
2.0 supplies a lightweight condition variable API. We will use that
when it exists, and backport it when it doesn't.
Older devkitARM toolchains incorrectly prevent _pthreadtypes.h from being included. Newer versions include it.
In order to make a version of ctr_pthread.h that works under both old and new toolchains, the typedefs are guarded by a define in _pthreadtypes.h that is only active if the other types are defined.
I've also added casts in order to make sure this compiles correctly with the standard pthread.h type definitions.