313: Export fls, flsl, flsll.
314: Export explicit_bzero.
315: Export pthread_mutex_timedlock.
+ 316: Export pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 315
+#define CYGWIN_VERSION_API_MINOR 316
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
}
int
-pthread_rwlock::rdlock ()
+pthread_rwlock::rdlock (PLARGE_INTEGER timeout)
{
int result = 0;
struct RWLOCK_READER *reader;
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
++waiting_readers;
- cond_readers.wait (&mtx);
+ cond_readers.wait (&mtx, timeout);
--waiting_readers;
pthread_cleanup_pop (0);
}
int
-pthread_rwlock::wrlock ()
+pthread_rwlock::wrlock (PLARGE_INTEGER timeout)
{
int result = 0;
pthread_t self = pthread::self ();
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
++waiting_writers;
- cond_writers.wait (&mtx);
+ cond_writers.wait (&mtx, timeout);
--waiting_writers;
pthread_cleanup_pop (0);
return (*rwlock)->rdlock ();
}
+extern "C" int
+pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock,
+ const struct timespec *abstime)
+{
+ LARGE_INTEGER timeout;
+
+ pthread_testcancel ();
+
+ if (pthread_rwlock::is_initializer (rwlock))
+ pthread_rwlock::init (rwlock, NULL);
+ if (!pthread_rwlock::is_good_object (rwlock))
+ return EINVAL;
+
+ /* According to SUSv3, abstime need not be checked for validity,
+ if the rwlock can be locked immediately. */
+ if (!(*rwlock)->tryrdlock ())
+ return 0;
+
+ __try
+ {
+ int err = pthread_convert_abstime (CLOCK_REALTIME, abstime, &timeout);
+ if (err)
+ return err;
+
+ return (*rwlock)->rdlock (&timeout);
+ }
+ __except (NO_ERROR) {}
+ __endtry
+ return EINVAL;
+}
+
extern "C" int
pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
{
return (*rwlock)->wrlock ();
}
+extern "C" int
+pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock,
+ const struct timespec *abstime)
+{
+ LARGE_INTEGER timeout;
+
+ pthread_testcancel ();
+
+ if (pthread_rwlock::is_initializer (rwlock))
+ pthread_rwlock::init (rwlock, NULL);
+ if (!pthread_rwlock::is_good_object (rwlock))
+ return EINVAL;
+
+ /* According to SUSv3, abstime need not be checked for validity,
+ if the rwlock can be locked immediately. */
+ if (!(*rwlock)->trywrlock ())
+ return 0;
+
+ __try
+ {
+ int err = pthread_convert_abstime (CLOCK_REALTIME, abstime, &timeout);
+ if (err)
+ return err;
+
+ return (*rwlock)->wrlock (&timeout);
+ }
+ __except (NO_ERROR) {}
+ __endtry
+ return EINVAL;
+}
+
extern "C" int
pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
{