* cygwin.din (pthread_condattr_getclock): Export.
(pthread_condattr_setclock): Export. * posix.sgml (std-notimpl): Move pthread_condattr_getclock and pthread_condattr_setclock from here... (std-susv4): ... to here. * sysconf.cc (sca): Set _SC_CLOCK_SELECTION to _POSIX_CLOCK_SELECTION. * thread.cc: (pthread_condattr::pthread_condattr): Initialize clock_id. (pthread_cond::pthread_cond): Initialize clock_id. (pthread_cond_timedwait): Use clock_gettime() instead of gettimeofday() in order to support all allowed clocks. (pthread_condattr_getclock): New function. (pthread_condattr_setclock): New function. * thread.h (class pthread_condattr): Add clock_id member. (class pthread_cond): Ditto. * include/pthread.h: Remove obsolete comment. (pthread_condattr_getclock): Declare. (pthread_condattr_setclock): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
This commit is contained in:
parent
792c8bcff2
commit
8a7b0a00df
@ -1,3 +1,24 @@
|
|||||||
|
2011-07-21 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
||||||
|
|
||||||
|
* cygwin.din (pthread_condattr_getclock): Export.
|
||||||
|
(pthread_condattr_setclock): Export.
|
||||||
|
* posix.sgml (std-notimpl): Move pthread_condattr_getclock and
|
||||||
|
pthread_condattr_setclock from here...
|
||||||
|
(std-susv4): ... to here.
|
||||||
|
* sysconf.cc (sca): Set _SC_CLOCK_SELECTION to _POSIX_CLOCK_SELECTION.
|
||||||
|
* thread.cc: (pthread_condattr::pthread_condattr): Initialize clock_id.
|
||||||
|
(pthread_cond::pthread_cond): Initialize clock_id.
|
||||||
|
(pthread_cond_timedwait): Use clock_gettime() instead of gettimeofday()
|
||||||
|
in order to support all allowed clocks.
|
||||||
|
(pthread_condattr_getclock): New function.
|
||||||
|
(pthread_condattr_setclock): New function.
|
||||||
|
* thread.h (class pthread_condattr): Add clock_id member.
|
||||||
|
(class pthread_cond): Ditto.
|
||||||
|
* include/pthread.h: Remove obsolete comment.
|
||||||
|
(pthread_condattr_getclock): Declare.
|
||||||
|
(pthread_condattr_setclock): Declare.
|
||||||
|
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
|
||||||
|
|
||||||
2011-07-18 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
2011-07-18 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
||||||
|
|
||||||
* sysconf.cc (sca): Return -1 for _SC_THREAD_ROBUST_PRIO_INHERIT,
|
* sysconf.cc (sca): Return -1 for _SC_THREAD_ROBUST_PRIO_INHERIT,
|
||||||
|
@ -1209,8 +1209,10 @@ pthread_cond_signal SIGFE
|
|||||||
pthread_cond_timedwait SIGFE
|
pthread_cond_timedwait SIGFE
|
||||||
pthread_cond_wait SIGFE
|
pthread_cond_wait SIGFE
|
||||||
pthread_condattr_destroy SIGFE
|
pthread_condattr_destroy SIGFE
|
||||||
|
pthread_condattr_getclock SIGFE
|
||||||
pthread_condattr_getpshared SIGFE
|
pthread_condattr_getpshared SIGFE
|
||||||
pthread_condattr_init SIGFE
|
pthread_condattr_init SIGFE
|
||||||
|
pthread_condattr_setclock SIGFE
|
||||||
pthread_condattr_setpshared SIGFE
|
pthread_condattr_setpshared SIGFE
|
||||||
pthread_continue SIGFE
|
pthread_continue SIGFE
|
||||||
pthread_create SIGFE
|
pthread_create SIGFE
|
||||||
|
@ -417,12 +417,13 @@ details. */
|
|||||||
247: Export error, error_at_line, error_message_count, error_one_per_line,
|
247: Export error, error_at_line, error_message_count, error_one_per_line,
|
||||||
error_print_progname.
|
error_print_progname.
|
||||||
248: Export __fpurge.
|
248: Export __fpurge.
|
||||||
|
249: Export pthread_condattr_getclock, pthread_condattr_setclock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||||
|
|
||||||
#define CYGWIN_VERSION_API_MAJOR 0
|
#define CYGWIN_VERSION_API_MAJOR 0
|
||||||
#define CYGWIN_VERSION_API_MINOR 248
|
#define CYGWIN_VERSION_API_MINOR 249
|
||||||
|
|
||||||
/* There is also a compatibity version number associated with the
|
/* There is also a compatibity version number associated with the
|
||||||
shared memory regions. It is incremented when incompatible
|
shared memory regions. It is incremented when incompatible
|
||||||
|
@ -27,12 +27,6 @@ extern "C"
|
|||||||
/* Defines. (These are correctly defined here as per
|
/* Defines. (These are correctly defined here as per
|
||||||
http://www.opengroup.org/onlinepubs/7908799/xsh/pthread.h.html */
|
http://www.opengroup.org/onlinepubs/7908799/xsh/pthread.h.html */
|
||||||
|
|
||||||
/* FIXME: this should allocate a new cond variable, and return the value that
|
|
||||||
would normally be written to the passed parameter of pthread_cond_init(lvalue, NULL); */
|
|
||||||
/* #define PTHREAD_COND_INITIALIZER 0 */
|
|
||||||
|
|
||||||
/* the default : joinable */
|
|
||||||
|
|
||||||
#define PTHREAD_CANCEL_ASYNCHRONOUS 1
|
#define PTHREAD_CANCEL_ASYNCHRONOUS 1
|
||||||
/* defaults are enable, deferred */
|
/* defaults are enable, deferred */
|
||||||
#define PTHREAD_CANCEL_ENABLE 0
|
#define PTHREAD_CANCEL_ENABLE 0
|
||||||
@ -132,8 +126,10 @@ int pthread_cond_timedwait (pthread_cond_t *,
|
|||||||
pthread_mutex_t *, const struct timespec *);
|
pthread_mutex_t *, const struct timespec *);
|
||||||
int pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *);
|
int pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *);
|
||||||
int pthread_condattr_destroy (pthread_condattr_t *);
|
int pthread_condattr_destroy (pthread_condattr_t *);
|
||||||
|
int pthread_condattr_getclock (const pthread_condattr_t *, clockid_t *);
|
||||||
int pthread_condattr_getpshared (const pthread_condattr_t *, int *);
|
int pthread_condattr_getpshared (const pthread_condattr_t *, int *);
|
||||||
int pthread_condattr_init (pthread_condattr_t *);
|
int pthread_condattr_init (pthread_condattr_t *);
|
||||||
|
int pthread_condattr_setclock (pthread_condattr_t *, clockid_t);
|
||||||
int pthread_condattr_setpshared (pthread_condattr_t *, int);
|
int pthread_condattr_setpshared (pthread_condattr_t *, int);
|
||||||
|
|
||||||
int pthread_create (pthread_t *, const pthread_attr_t *,
|
int pthread_create (pthread_t *, const pthread_attr_t *,
|
||||||
|
@ -554,8 +554,10 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
|||||||
pthread_cond_timedwait
|
pthread_cond_timedwait
|
||||||
pthread_cond_wait
|
pthread_cond_wait
|
||||||
pthread_condattr_destroy
|
pthread_condattr_destroy
|
||||||
|
pthread_condattr_getclock
|
||||||
pthread_condattr_getpshared
|
pthread_condattr_getpshared
|
||||||
pthread_condattr_init
|
pthread_condattr_init
|
||||||
|
pthread_condattr_setclock
|
||||||
pthread_condattr_setpshared
|
pthread_condattr_setpshared
|
||||||
pthread_create
|
pthread_create
|
||||||
pthread_detach
|
pthread_detach
|
||||||
@ -1390,8 +1392,6 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
|||||||
posix_typed_[...]
|
posix_typed_[...]
|
||||||
powl
|
powl
|
||||||
pthread_barrier[...]
|
pthread_barrier[...]
|
||||||
pthread_condattr_getclock
|
|
||||||
pthread_condattr_setclock
|
|
||||||
pthread_mutexattr_getrobust
|
pthread_mutexattr_getrobust
|
||||||
pthread_mutexattr_setrobust
|
pthread_mutexattr_setrobust
|
||||||
pthread_mutex_consistent
|
pthread_mutex_consistent
|
||||||
|
@ -158,7 +158,7 @@ static struct
|
|||||||
{cons, {c:BC_DIM_MAX}}, /* 58, _SC_BC_DIM_MAX */
|
{cons, {c:BC_DIM_MAX}}, /* 58, _SC_BC_DIM_MAX */
|
||||||
{cons, {c:BC_SCALE_MAX}}, /* 59, _SC_BC_SCALE_MAX */
|
{cons, {c:BC_SCALE_MAX}}, /* 59, _SC_BC_SCALE_MAX */
|
||||||
{cons, {c:BC_STRING_MAX}}, /* 60, _SC_BC_STRING_MAX */
|
{cons, {c:BC_STRING_MAX}}, /* 60, _SC_BC_STRING_MAX */
|
||||||
{cons, {c:-1L}}, /* 61, _SC_CLOCK_SELECTION */
|
{cons, {c:_POSIX_CLOCK_SELECTION}}, /* 61, _SC_CLOCK_SELECTION */
|
||||||
{nsup, {c:0}}, /* 62, _SC_COLL_WEIGHTS_MAX */
|
{nsup, {c:0}}, /* 62, _SC_COLL_WEIGHTS_MAX */
|
||||||
{cons, {c:_POSIX_CPUTIME}}, /* 63, _SC_CPUTIME */
|
{cons, {c:_POSIX_CPUTIME}}, /* 63, _SC_CPUTIME */
|
||||||
{cons, {c:EXPR_NEST_MAX}}, /* 64, _SC_EXPR_NEST_MAX */
|
{cons, {c:EXPR_NEST_MAX}}, /* 64, _SC_EXPR_NEST_MAX */
|
||||||
|
@ -1099,7 +1099,8 @@ pthread_attr::~pthread_attr ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
pthread_condattr::pthread_condattr ():verifyable_object
|
pthread_condattr::pthread_condattr ():verifyable_object
|
||||||
(PTHREAD_CONDATTR_MAGIC), shared (PTHREAD_PROCESS_PRIVATE)
|
(PTHREAD_CONDATTR_MAGIC), shared (PTHREAD_PROCESS_PRIVATE),
|
||||||
|
clock_id (CLOCK_REALTIME)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,17 +1125,21 @@ pthread_cond::init_mutex ()
|
|||||||
|
|
||||||
pthread_cond::pthread_cond (pthread_condattr *attr) :
|
pthread_cond::pthread_cond (pthread_condattr *attr) :
|
||||||
verifyable_object (PTHREAD_COND_MAGIC),
|
verifyable_object (PTHREAD_COND_MAGIC),
|
||||||
shared (0), waiting (0), pending (0), sem_wait (NULL),
|
shared (0), clock_id (CLOCK_REALTIME), waiting (0), pending (0),
|
||||||
mtx_cond(NULL), next (NULL)
|
sem_wait (NULL), mtx_cond(NULL), next (NULL)
|
||||||
{
|
{
|
||||||
pthread_mutex *verifyable_mutex_obj;
|
pthread_mutex *verifyable_mutex_obj;
|
||||||
|
|
||||||
if (attr)
|
if (attr)
|
||||||
|
{
|
||||||
|
clock_id = attr->clock_id;
|
||||||
|
|
||||||
if (attr->shared != PTHREAD_PROCESS_PRIVATE)
|
if (attr->shared != PTHREAD_PROCESS_PRIVATE)
|
||||||
{
|
{
|
||||||
magic = 0;
|
magic = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
verifyable_mutex_obj = &mtx_in;
|
verifyable_mutex_obj = &mtx_in;
|
||||||
if (!pthread_mutex::is_good_object (&verifyable_mutex_obj))
|
if (!pthread_mutex::is_good_object (&verifyable_mutex_obj))
|
||||||
@ -2716,7 +2721,7 @@ extern "C" int
|
|||||||
pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||||
const struct timespec *abstime)
|
const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timespec tp;
|
||||||
DWORD waitlength;
|
DWORD waitlength;
|
||||||
|
|
||||||
myfault efault;
|
myfault efault;
|
||||||
@ -2731,17 +2736,18 @@ pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
|||||||
|| abstime->tv_nsec > 999999999)
|
|| abstime->tv_nsec > 999999999)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
gettimeofday (&tv, NULL);
|
clock_gettime ((*cond)->clock_id, &tp);
|
||||||
|
|
||||||
/* Check for immediate timeout before converting to microseconds, since
|
/* Check for immediate timeout before converting to microseconds, since
|
||||||
the resulting value can easily overflow long. This also allows to
|
the resulting value can easily overflow long. This also allows to
|
||||||
evaluate microseconds directly in DWORD. */
|
evaluate microseconds directly in DWORD. */
|
||||||
if (tv.tv_sec > abstime->tv_sec
|
if (tp.tv_sec > abstime->tv_sec
|
||||||
|| (tv.tv_sec == abstime->tv_sec
|
|| (tp.tv_sec == abstime->tv_sec
|
||||||
&& tv.tv_usec > abstime->tv_nsec / 1000))
|
&& tp.tv_nsec > abstime->tv_nsec))
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
|
|
||||||
waitlength = (abstime->tv_sec - tv.tv_sec) * 1000;
|
waitlength = (abstime->tv_sec - tp.tv_sec) * 1000;
|
||||||
waitlength += (abstime->tv_nsec / 1000 - tv.tv_usec) / 1000;
|
waitlength += (abstime->tv_nsec - tp.tv_nsec) / 1000000;
|
||||||
return __pthread_cond_dowait (cond, mutex, waitlength);
|
return __pthread_cond_dowait (cond, mutex, waitlength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2792,6 +2798,32 @@ pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
pthread_condattr_getclock (const pthread_condattr_t *attr, clockid_t *clock_id)
|
||||||
|
{
|
||||||
|
if (!pthread_condattr::is_good_object (attr))
|
||||||
|
return EINVAL;
|
||||||
|
*clock_id = (*attr)->clock_id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" int
|
||||||
|
pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock_id)
|
||||||
|
{
|
||||||
|
if (!pthread_condattr::is_good_object (attr))
|
||||||
|
return EINVAL;
|
||||||
|
switch (clock_id)
|
||||||
|
{
|
||||||
|
case CLOCK_REALTIME:
|
||||||
|
case CLOCK_MONOTONIC:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
(*attr)->clock_id = clock_id;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
pthread_condattr_destroy (pthread_condattr_t *condattr)
|
pthread_condattr_destroy (pthread_condattr_t *condattr)
|
||||||
{
|
{
|
||||||
|
@ -488,6 +488,7 @@ class pthread_condattr: public verifyable_object
|
|||||||
public:
|
public:
|
||||||
static bool is_good_object(pthread_condattr_t const *);
|
static bool is_good_object(pthread_condattr_t const *);
|
||||||
int shared;
|
int shared;
|
||||||
|
clockid_t clock_id;
|
||||||
|
|
||||||
pthread_condattr ();
|
pthread_condattr ();
|
||||||
~pthread_condattr ();
|
~pthread_condattr ();
|
||||||
@ -504,6 +505,7 @@ public:
|
|||||||
static int init (pthread_cond_t *, const pthread_condattr_t *);
|
static int init (pthread_cond_t *, const pthread_condattr_t *);
|
||||||
|
|
||||||
int shared;
|
int shared;
|
||||||
|
clockid_t clock_id;
|
||||||
|
|
||||||
unsigned long waiting;
|
unsigned long waiting;
|
||||||
unsigned long pending;
|
unsigned long pending;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user