win32: Check and avoid using TLS index 0

Zero is a valid TLS index so it needs to be checked. It’s also the
integer used to indicate that no TLS has been allocated yet, so it can’t
be used as a TLS identifier.

Incorporates changes from Philip Withnall.

Fixes: #2058
10 jobs for issue-2058 in 17 minutes and 55 seconds (queued for 6 seconds)
latest
Status Job ID Name Coverage
  Style Check
passed #1341869
check-todos

00:01:46

failed #1341868
allowed to fail
style-check-diff

00:02:03

 
  Build
passed #1341872
cross-android_api21_arm64

00:01:42

passed #1341873
cross-android_api28_arm64

00:00:54

passed #1341874
cross-mingw64

00:02:46

passed #1341871
debian-stable-x86_64

00:02:25

passed #1341870
fedora-x86_64

00:09:09

passed #1341875
win32-ps
msys2-mingw32

00:12:59

passed #1341876
win32-ps
vs2017-x64

00:08:13

 
  Coverage
passed #1341877
coverage

00:01:32

76.1%
 
Name Stage Failure
failed
style-check-diff Style Check
 
- if G_UNLIKELY (impl == 0)
+ if
+ G_UNLIKELY (impl == 0)
{
/* Ignore TLS index 0 temporarily (as 0 is the indicator that we
* haven't allocated TLS yet) and alloc again;
Cleaning up file based variables
ERROR: Job failed: exit code 1