Kludge around TLS setup for Haiku by adapting the relevant code from the Windows port. Will need to switch to a non-hardcoded TLS slot.