winpthreads: mutex.c: improve `pthread_mutex_timedlock`

POSIX[1] does not specify behavior when the second argument to
`pthread_mutex_timedlock` is NULL; assume it is always non-NULL.

Follow POSIX[1] specification and fail with EINVAL if `tv_nsec` field of passed
`struct timespec` is less than zero or greater than or equal to 1000000000.

Replace uses of `unsigned long long` with more MSVC-friendly `unsigned __int64`.

Cast `patience` variable to `DWORD` when calling `pthread_mutex_lock_intern`;
this avoids MSVC warning C4244.

[1] https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/pthread_mutex_clocklock.html

Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
1 file changed