Support some thread stack attr options.

May improve memory management in some games.
Validate and report some thread attributes.
Eat cycles after creating a thread.

Improves things on some tests, should be more accurate.
Creating a thread sure takes a long time.
Set the low mystery bits of the thread attr.

Tests on PSP show this, and I can't find a way to not have them set.
But I don't really know what they mean.

Anyway, since you can refer the status, you can see them, may improve
compatibility.
Reset thread priority on terminate.
Reset waits when terminating a thread.

Terminated threads can't be waiting.
Return a negative error code in __KernelGetWaitID.

This way we can use 0 as a proper wait id.
Fix really stupid heap corruption mistake.
Add a few new syscalls from reporting.
Log when syscalls fail due to intr/dispatch.
Merge pull request #3711 from unknownbrackets/thread-minor

Fixes to various thread functions + heap corruption fix