| 943 | } |
| 944 | |
| 945 | static int pthread_mutex_timedlock(pthread_mutex_t *m, struct timespec *ts) |
| 946 | { |
| 947 | unsigned long long t, ct; |
| 948 | |
| 949 | struct _pthread_crit_t |
| 950 | { |
| 951 | void *debug; |
| 952 | LONG count; |
| 953 | LONG r_count; |
| 954 | HANDLE owner; |
| 955 | HANDLE sem; |
| 956 | ULONG_PTR spin; |
| 957 | }; |
| 958 | |
| 959 | /* Try to lock it without waiting */ |
| 960 | if (!pthread_mutex_trylock(m)) return 0; |
| 961 | |
| 962 | ct = (DWORD)_pthread_time_in_ms(); |
| 963 | t = (DWORD)_pthread_time_in_ms_from_timespec(ts); |
| 964 | |
| 965 | while (1) |
| 966 | { |
| 967 | /* Have we waited long enough? */ |
| 968 | if (ct > t) return ETIMEDOUT; |
| 969 | |
| 970 | /* Wait on semaphore within critical section */ |
| 971 | WaitForSingleObject(((struct _pthread_crit_t *)m)->sem, (DWORD)(t - ct)); |
| 972 | |
| 973 | /* Try to grab lock */ |
| 974 | if (!pthread_mutex_trylock(m)) return 0; |
| 975 | |
| 976 | /* Get current time */ |
| 977 | ct = _pthread_time_in_ms(); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | #define _PTHREAD_BARRIER_FLAG (1<<30) |
| 982 |
nothing calls this directly
no test coverage detected