Commit fa9f4361 authored by Éric Thiébaut's avatar Éric Thiébaut
Browse files

Replace struct timespec by tao_time_t

parent 74709383
......@@ -572,9 +572,7 @@ on_start(tao_camera_t* cam)
/* Instanciate camera acquisition buffers. Buffer data and size
are instanciated by the on_wait_buffer method. */
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 0;
tao_time_t unset_time = TAO_UNKNOWN_TIME;
for (int i = 0; i < cam->nbufs; ++i) {
cam->bufs[i].data = NULL;
cam->bufs[i].size = 0;
......@@ -584,9 +582,9 @@ on_start(tao_camera_t* cam)
cam->bufs[i].stride = stride;
cam->bufs[i].encoding = bufferencoding;
cam->bufs[i].frame_number = 0;
cam->bufs[i].frame_start = ts;
cam->bufs[i].frame_end = ts;
cam->bufs[i].buffer_ready = ts;
cam->bufs[i].frame_start = unset_time;
cam->bufs[i].frame_end = unset_time;
cam->bufs[i].buffer_ready = unset_time;
}
/* Allocate new device acquisition buffers as needed and queue them.
......@@ -720,7 +718,7 @@ on_wait_buffer(tao_camera_t* cam, double secs)
/* Set acquisition buffer information. FIXME: Use Andor meta-data
information. */
struct timespec now;
tao_time_t now;
if (tao_get_monotonic_time(&now) != TAO_OK) {
tao_panic();
}
......
......@@ -536,7 +536,7 @@ invalid_state(tao_camera_state_t state)
#define STATE_FINISHED TAO_CAMERA_STATE_FINISHED
// Callback for processing acquisition buffers.
typedef void processor(void* data, struct timespec* ts,
typedef void processor(void* data, tao_time_t* t,
const void* buf, long siz);
#define KILO 1000
......@@ -682,8 +682,8 @@ process_frame(const tao_acquisition_buffer_t* buf)
TAO_GET_SHARED_ARRAY_DIM(arr, 2) == height) {
andor_convert_buffer(TAO_GET_SHARED_ARRAY_DATA(arr), arrenc,
data, bufenc, width, height, stride);
arr->ts_sec = buf->frame_start.tv_sec;
arr->ts_nsec = buf->frame_start.tv_nsec;
arr->ts_sec = buf->frame_start.sec;
arr->ts_nsec = buf->frame_start.nsec;
wrlock_shared_camera();
(void)tao_post_framegrabber_buffer(vfg);
unlock_shared_camera();
......@@ -899,15 +899,15 @@ on_get_ping(tao_server_t* srv, void* ctx,
void** bufptr, size_t* sizptr)
{
char str[32];
struct timespec ts;
tao_time_t t;
if (argc != 1) {
send_usage(srv, argv[0], NULL);
return TAO_ERROR;
}
if (tao_get_monotonic_time(&ts) != TAO_OK) {
if (tao_get_monotonic_time(&t) != TAO_OK) {
return TAO_ERROR;
}
tao_sprintf_time(str, &ts);
tao_sprintf_time(str, &t);
strcat(str, "\n");
return set_string_result(srv, str, bufptr, sizptr);
}
......
......@@ -15,10 +15,10 @@
#include <time.h>
#include <tao-andor-private.h>
static double elapsed_seconds(const struct timespec* t1,
const struct timespec* t0)
static double elapsed_seconds(const tao_time_t* t1,
const tao_time_t* t0)
{
struct timespec dt;
tao_time_t dt;
return tao_time_to_seconds(tao_subtract_times(&dt, t1, t0));
}
......@@ -28,7 +28,7 @@ int main(int argc, char* argv[])
tao_camera_config_t cfg;
long dev, ndevices;
char* end;
struct timespec t0, t1;
tao_time_t t0, t1;
ndevices = andor_get_ndevices();
if (ndevices < 0) {
......
......@@ -17,10 +17,10 @@
#include <tao-fits.h>
#include <tao-andor-private.h>
static double elapsed_seconds(const struct timespec* t1,
const struct timespec* t0)
static double elapsed_seconds(const tao_time_t* t1,
const tao_time_t* t0)
{
struct timespec dt;
tao_time_t dt;
return tao_time_to_seconds(tao_subtract_times(&dt, t1, t0));
}
......@@ -31,7 +31,7 @@ int main(int argc, char* argv[])
tao_camera_config_t cfg;
long dev, ndevices, nimgs, imgsiz;
uint16_t* imgptr;
struct timespec t0, t1;
tao_time_t t0, t1;
// Get number of devices (and initialize internals).
ndevices = andor_get_ndevices();
......
......@@ -134,10 +134,9 @@ tao_get_camera_state_name(tao_camera_state_t state)
/*---------------------------------------------------------------------------*/
/* UNIFIED CAMERAS */
static void
get_monotonic_time(struct timespec* ts)
static inline void get_monotonic_time(tao_time_t* t)
{
if (tao_get_monotonic_time(ts) != TAO_OK) {
if (tao_get_monotonic_time(t) != TAO_OK) {
tao_panic();
}
}
......@@ -368,7 +367,7 @@ tao_wait_camera(tao_camera_t* cam)
tao_status_t
tao_abstimed_wait_camera(tao_camera_t* cam,
const struct timespec* abstime)
const tao_time_t* abstime)
{
return tao_abstimed_wait_condition(&cam->notify,
&cam->mutex, abstime);
......@@ -660,18 +659,18 @@ tao_status_t tao_reflect_camera_information(tao_shared_camera_t* dest,
}
void
tao_set_camera_origin_of_time(tao_camera_t* cam, const struct timespec* t)
tao_set_camera_origin_of_time(tao_camera_t* cam, const tao_time_t* t)
{
struct timespec ts;
tao_time_t now;
if (t == NULL) {
get_monotonic_time(&ts);
t = &ts;
get_monotonic_time(&now);
t = &now;
}
cam->info.origin = *t;
}
const struct timespec*
tao_get_camera_origin_of_time(struct timespec* t, const tao_camera_t* cam)
const tao_time_t*
tao_get_camera_origin_of_time(tao_time_t* t, const tao_camera_t* cam)
{
if (t == NULL) {
return &cam->info.origin;
......@@ -684,9 +683,9 @@ tao_get_camera_origin_of_time(struct timespec* t, const tao_camera_t* cam)
#define ENCODE(w) \
double \
tao_get_camera_elapsed_##w(const tao_camera_t* cam, \
const struct timespec* t) \
const tao_time_t* t) \
{ \
struct timespec dt; \
tao_time_t dt; \
if (t == NULL) { \
get_monotonic_time(&dt); \
t = &dt; \
......@@ -1031,10 +1030,10 @@ tao_post_framegrabber_buffer(tao_framegrabber_t* fg)
if (arr->ts_sec == NO_TIMESTAMP_SEC &&
arr->ts_nsec == NO_TIMESTAMP_NSEC) {
/* The owner did not set frame time-stamp. */
struct timespec ts;
get_monotonic_time(&ts);
arr->ts_sec = ts.tv_sec;
arr->ts_nsec = ts.tv_nsec;
tao_time_t t;
get_monotonic_time(&t);
arr->ts_sec = t.sec;
arr->ts_nsec = t.nsec;
}
fg->counter += 1;
arr->counter = fg->counter;
......
......@@ -43,7 +43,10 @@
*/
#define EMULATE_TIMEDWAIT(try, abstime) \
do { \
struct timespec lim = *(abstime); \
struct timespec lim = { \
.tv_sec = abstime->sec, \
.tv_nsec = abstime->nsec, \
}; \
if (lim.tv_nsec < 0 || lim.tv_nsec >= NANOSECONDS_PER_SECOND) { \
/* See POSIX standard. */ \
return EINVAL; \
......@@ -86,7 +89,7 @@
#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
static int
pthread_mutex_timedlock(pthread_mutex_t *mutex,
const struct timespec* abstime)
const tao_time_t* abstime)
{
EMULATE_TIMEDWAIT(pthread_mutex_trylock(mutex), abstime);
}
......@@ -95,7 +98,7 @@ pthread_mutex_timedlock(pthread_mutex_t *mutex,
#ifndef HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK
static int
pthread_rwlock_timedrdlock(pthread_rwlock_t* rwlock,
const struct timespec* abstime)
const tao_time_t* abstime)
{
EMULATE_TIMEDWAIT(pthread_rwlock_tryrdlock(rwlock), abstime);
}
......@@ -104,7 +107,7 @@ pthread_rwlock_timedrdlock(pthread_rwlock_t* rwlock,
#ifndef HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK
static int
pthread_rwlock_timedwrlock(pthread_rwlock_t* rwlock,
const struct timespec* abstime)
const tao_time_t* abstime)
{
EMULATE_TIMEDWAIT(pthread_rwlock_trywrlock(rwlock), abstime);
}
......@@ -207,16 +210,20 @@ tao_try_lock_mutex(pthread_mutex_t* mutex)
tao_status_t
tao_abstimed_lock_mutex(pthread_mutex_t* mutex,
const struct timespec* abstime)
const tao_time_t* abstime)
{
struct timespec ts = {
.tv_sec = abstime->sec,
.tv_nsec = abstime->nsec,
};
CALL_TIMED_PTHREAD_FUNC(pthread_mutex_timedlock,
(mutex, abstime), ETIMEDOUT);
(mutex, &ts), ETIMEDOUT);
}
tao_status_t
tao_timed_lock_mutex(pthread_mutex_t* mutex, double secs)
{
struct timespec abstime;
tao_time_t abstime;
switch (tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
return TAO_TIMEOUT;
......@@ -340,10 +347,14 @@ tao_wait_condition(pthread_cond_t* cond,
tao_status_t
tao_abstimed_wait_condition(pthread_cond_t* cond,
pthread_mutex_t* mutex,
const struct timespec* abstime)
const tao_time_t* abstime)
{
struct timespec ts = {
.tv_sec = abstime->sec,
.tv_nsec = abstime->nsec,
};
CALL_TIMED_PTHREAD_FUNC(pthread_cond_timedwait,
(cond, mutex, abstime), ETIMEDOUT);
(cond, mutex, &ts), ETIMEDOUT);
}
tao_status_t
......@@ -351,7 +362,7 @@ tao_timed_wait_condition(pthread_cond_t* cond,
pthread_mutex_t* mutex,
double secs)
{
struct timespec abstime;
tao_time_t abstime;
switch(tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
case TAO_TIMEOUT_NOW:
......@@ -438,18 +449,26 @@ tao_try_wrlock_rwlock(pthread_rwlock_t* lock)
tao_status_t
tao_abstimed_rdlock_rwlock(pthread_rwlock_t* lock,
const struct timespec* abstime)
const tao_time_t* abstime)
{
struct timespec ts = {
.tv_sec = abstime->sec,
.tv_nsec = abstime->nsec,
};
CALL_TIMED_PTHREAD_FUNC(pthread_rwlock_timedrdlock,
(lock, abstime), ETIMEDOUT);
(lock, &ts), ETIMEDOUT);
}
tao_status_t
tao_abstimed_wrlock_rwlock(pthread_rwlock_t* lock,
const struct timespec* abstime)
const tao_time_t* abstime)
{
struct timespec ts = {
.tv_sec = abstime->sec,
.tv_nsec = abstime->nsec,
};
CALL_TIMED_PTHREAD_FUNC(pthread_rwlock_timedwrlock,
(lock, abstime), ETIMEDOUT);
(lock, &ts), ETIMEDOUT);
}
tao_status_t
......@@ -461,7 +480,7 @@ tao_unlock_rwlock(pthread_rwlock_t* lock)
tao_status_t
tao_timed_rdlock_rwlock(pthread_rwlock_t* lock, double secs)
{
struct timespec abstime;
tao_time_t abstime;
switch (tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
return TAO_TIMEOUT;
......@@ -483,7 +502,7 @@ tao_timed_rdlock_rwlock(pthread_rwlock_t* lock, double secs)
tao_status_t
tao_timed_wrlock_rwlock(pthread_rwlock_t* lock, double secs)
{
struct timespec abstime;
tao_time_t abstime;
switch (tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
return TAO_TIMEOUT;
......
......@@ -86,9 +86,13 @@ tao_try_wait_semaphore(sem_t* sem)
}
tao_status_t
tao_abstimed_wait_semaphore(sem_t* sem, const struct timespec* abstime)
tao_abstimed_wait_semaphore(sem_t* sem, const tao_time_t* abstime)
{
if (sem_timedwait(sem, abstime) != 0) {
struct timespec ts = {
.tv_sec = abstime->sec,
.tv_nsec = abstime->nsec,
};
if (sem_timedwait(sem, &ts) != 0) {
int code = errno;
if (code == ETIMEDOUT) {
return TAO_TIMEOUT;
......@@ -103,7 +107,7 @@ tao_abstimed_wait_semaphore(sem_t* sem, const struct timespec* abstime)
tao_status_t
tao_timed_wait_semaphore(sem_t* sem, double secs)
{
struct timespec abstime;
tao_time_t abstime;
switch(tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
return TAO_TIMEOUT;
......
......@@ -150,10 +150,10 @@ tao_create_shared_array(const char* owner, tao_eltype_t eltype,
}
arr->eltype = eltype;
arr->counter = 0;
struct timespec ts;
if (tao_get_monotonic_time(&ts) == TAO_OK) {
arr->ts_sec = ts.tv_sec;
arr->ts_nsec = ts.tv_nsec;
tao_time_t t;
if (tao_get_monotonic_time(&t) == TAO_OK) {
arr->ts_sec = t.sec;
arr->ts_nsec = t.nsec;
} else {
tao_report_errors();
}
......
......@@ -75,15 +75,13 @@ TAO_XJOIN2(tao_try_rdlock_,NAME)(TYPE* obj)
}
tao_status_t
TAO_XJOIN2(tao_abstimed_rdlock_,NAME)(TYPE* obj,
const struct timespec* abstime)
TAO_XJOIN2(tao_abstimed_rdlock_,NAME)(TYPE* obj, const tao_time_t* abstime)
{
return tao_abstimed_rdlock(obj, abstime);
}
tao_status_t
TAO_XJOIN2(tao_timed_rdlock_,NAME)(TYPE* obj,
double secs)
TAO_XJOIN2(tao_timed_rdlock_,NAME)(TYPE* obj, double secs)
{
return tao_timed_rdlock(obj, secs);
}
......@@ -101,15 +99,13 @@ TAO_XJOIN2(tao_try_wrlock_,NAME)(TYPE* obj)
}
tao_status_t
TAO_XJOIN2(tao_abstimed_wrlock_,NAME)(TYPE* obj,
const struct timespec* abstime)
TAO_XJOIN2(tao_abstimed_wrlock_,NAME)(TYPE* obj, const tao_time_t* abstime)
{
return tao_abstimed_wrlock(obj, abstime);
}
tao_status_t
TAO_XJOIN2(tao_timed_wrlock_,NAME)(TYPE* obj,
double secs)
TAO_XJOIN2(tao_timed_wrlock_,NAME)(TYPE* obj, double secs)
{
return tao_timed_wrlock(obj, secs);
}
......
......@@ -380,7 +380,7 @@ try_rdlock_shared_data(tao_shared_data_t* data)
static tao_status_t
abstimed_rdlock_shared_data(tao_shared_data_t* data,
const struct timespec* abstime)
const tao_time_t* abstime)
{
tao_status_t status = TIMED_LOCK_MUTEX(data, abstime);
if (status == TAO_OK) {
......@@ -439,7 +439,7 @@ try_wrlock_shared_data(tao_shared_data_t* data)
static tao_status_t
abstimed_wrlock_shared_data(tao_shared_data_t* data,
const struct timespec* abstime)
const tao_time_t* abstime)
{
tao_status_t status = TIMED_LOCK_MUTEX(data, abstime);
if (status == TAO_OK) {
......@@ -501,14 +501,14 @@ tao_try_wrlock_shared_data(tao_shared_data_t* data)
tao_status_t
tao_abstimed_rdlock_shared_data(tao_shared_data_t* data,
const struct timespec* abstime)
const tao_time_t* abstime)
{
return abstimed_rdlock_shared_data(data, abstime);
}
tao_status_t
tao_abstimed_wrlock_shared_data(tao_shared_data_t* data,
const struct timespec* abstime)
const tao_time_t* abstime)
{
return abstimed_wrlock_shared_data(data, abstime);
}
......@@ -521,7 +521,7 @@ tao_timed_rdlock_shared_data(tao_shared_data_t* data,
tao_push_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
struct timespec abstime;
tao_time_t abstime;
switch(tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
/* The timeout is assumed to have expired. */
......@@ -553,7 +553,7 @@ tao_timed_wrlock_shared_data(tao_shared_data_t* data,
tao_push_error(__func__, TAO_BAD_ADDRESS);
return TAO_ERROR;
}
struct timespec abstime;
tao_time_t abstime;
switch(tao_get_absolute_timeout(&abstime, secs)) {
case TAO_TIMEOUT_PAST:
/* The timeout is assumed to have expired. */
......
......@@ -223,7 +223,7 @@ typedef struct _tao_camera_info {
tao_camera_config_t config;/**< Configurable parameters. */
tao_camera_state_t state;/**< State of the camera. */
double temperature;/**< Camera temperature (in degrees Celsius). */
struct timespec origin;/**< Origin of time. */
tao_time_t origin;/**< Origin of time. */
int64_t frames;/**< Number of frames received so far. */
int64_t overruns;/**< Number of frames lost so far because of
overruns. */
......@@ -439,7 +439,7 @@ extern tao_status_t tao_try_rdlock_shared_camera(tao_shared_camera_t* cam);
* `TAO_WRITE_ACCESS`.
*
* @param secs Maximum time to wait (in seconds). If this amount of time is
* very large, e.g. more than `TAO_MAX_SIGNED_INT(time_t)`, the
* very large, e.g. more than @ref TAO_MAX_TIME_SECONDS, the
* effect is the same as calling tao_rdlock_shared_camera(). If
* this amount of time is very short, the effect is the same as
* calling tao_try_rdlock_shared_camera().
......@@ -449,7 +449,7 @@ extern tao_status_t tao_try_rdlock_shared_camera(tao_shared_camera_t* cam);
* before or @ref TAO_ERROR in case of error.
*/
extern tao_status_t tao_abstimed_rdlock_shared_camera(tao_shared_camera_t* cam,
const struct timespec* abstime);
const tao_time_t* abstime);
extern tao_status_t tao_timed_rdlock_shared_camera(tao_shared_camera_t* cam,
double secs);
......@@ -459,7 +459,7 @@ extern tao_status_t tao_wrlock_shared_camera(tao_shared_camera_t* cam);
extern tao_status_t tao_try_wrlock_shared_camera(tao_shared_camera_t* cam);
extern tao_status_t tao_abstimed_wrlock_shared_camera(tao_shared_camera_t* cam,
const struct timespec* abstime);
const tao_time_t* abstime);
extern tao_status_t tao_timed_wrlock_shared_camera(tao_shared_camera_t* cam,
double secs);
......@@ -870,9 +870,9 @@ typedef struct _tao_acquisition_buffer {
long stride;/**< Bytes per line in buffer. */
tao_encoding_t encoding;/**< Pixel encoding in buffer. */
uint64_t frame_number;/**< Number of frames so far. */
struct timespec frame_start;/**< Start time of frame. */
struct timespec frame_end;/**< End time of frame. */
struct timespec buffer_ready;/**< Buffer ready time. */
tao_time_t frame_start;/**< Start time of frame. */
tao_time_t frame_end;/**< End time of frame. */
tao_time_t buffer_ready;/**< Buffer ready time. */
} tao_acquisition_buffer_t;
/**
......@@ -1151,7 +1151,7 @@ extern void tao_notify_camera(tao_camera_t* cam);
extern tao_status_t tao_wait_camera(tao_camera_t* cam);
extern tao_status_t tao_abstimed_wait_camera(tao_camera_t* cam,
const struct timespec* abstime);
const tao_time_t* abstime);
extern tao_status_t tao_timed_wait_camera(tao_camera_t* cam, double secs);
......@@ -1261,7 +1261,7 @@ extern tao_status_t tao_reflect_camera_information(tao_shared_camera_t* dest,
*
* @param secs Maximum number of seconds to wait. Must be nonnegative.
* Wait forever if @b secs is too large, e.g. more than
* `TAO_MAX_SIGNED_INT(time_t)`.
* @ref TAO_MAX_TIME_SECONDS.
*
* @param drop This parameter specifies how to deal with pending acquisition
* buffers. If there are no pending acquisition buffers, the
......@@ -1340,7 +1340,7 @@ extern tao_status_t tao_reset_camera(tao_camera_t* cam);
* to the current time (using the monotonic clock if available).
*/
extern void tao_set_camera_origin_of_time(tao_camera_t* cam,
const struct timespec* t);
const tao_time_t* t);
/**
* Get the origin of time of a camera.
......@@ -1351,8 +1351,8 @@ extern void tao_set_camera_origin_of_time(tao_camera_t* cam,
*
* @return A pointer to a structure with the origin of time of @b cam.
*/
extern const struct timespec* tao_get_camera_origin_of_time(struct timespec* t,
const tao_camera_t* cam);
extern const tao_time_t* tao_get_camera_origin_of_time(tao_time_t* t,
const tao_camera_t* cam);
/**
* Get the number of seconds since a camera origin of time.
......@@ -1373,7 +1373,7 @@ extern const struct timespec* tao_get_camera_origin_of_time(struct timespec* t,
* tao_get_monotonic_time().
*/
extern double tao_get_camera_elapsed_seconds(const tao_camera_t* cam,
const struct timespec* t);
const tao_time_t* t);
/**
* Get the number of milliseconds since a camera origin of time.
......@@ -1394,7 +1394,7 @@ extern double tao_get_camera_elapsed_seconds(const tao_camera_t* cam,
* tao_get_monotonic_time().
*/
extern double tao_get_camera_elapsed_milliseconds(const tao_camera_t* cam,
const struct timespec* t);
const tao_time_t* t);
/**
* Get the number of microseconds since a camera origin of time.
......@@ -1415,7 +1415,7 @@ extern double tao_get_camera_elapsed_milliseconds(const tao_camera_t* cam,
* tao_get_monotonic_time().
*/
extern double tao_get_camera_elapsed_microseconds(const tao_camera_t* cam,
const struct timespec* t);
const tao_time_t* t);
/**
* Get the number of nanoseconds since a camera origin of time.
......@@ -1436,7 +1436,7 @@ extern double tao_get_camera_elapsed_microseconds(const tao_camera_t* cam,
* tao_get_camera_elapsed_microseconds(), tao_get_monotonic_time().
*/
extern double tao_get_camera_elapsed_nanoseconds(const tao_camera_t* cam,
const struct timespec* t);
const tao_time_t* t);
/** @} */
......
......@@ -164,7 +164,7 @@ extern tao_status_t tao_rdlock_shared_mirror(tao_shared_mirror_t* dm);
extern tao_status_t tao_try_rdlock_shared_mirror(tao_shared_mirror_t* dm);
extern tao_status_t tao_abstimed_rdlock_shared_mirror(tao_shared_mirror_t* dm,
const struct timespec* abstime);
const tao_time_t* abstime);
extern tao_status_t tao_timed_rdlock_shared_mirror(tao_shared_mirror_t* dm,
double secs);
......@@ -174,7 +174,7 @@ extern tao_status_t tao_wrlock_shared_mirror(tao_shared_mirror_t* dm);
extern tao_status_t tao_try_wrlock_shared_mirror(tao_shared_mirror_t* dm);
extern tao_status_t tao_abstimed_wrlock_shared_mirror(tao_shared_mirror_t* dm,
const struct timespec* abstime);
const tao_time_t* abstime);
extern tao_status_t tao_timed_wrlock_shared_mirror(tao_shared_mirror_t* dm,
double secs);
......@@ -206,7 +206,7 @@ extern tao_status_t tao_timed_wrlock_shared_mirror(tao_shared_mirror_t* dm,
* @param access The requested access mode: `TAO_READ_ACCESS` or
* `TAO_WRITE_ACCESS`.
* @param secs Maximum time to wait (in seconds). If this amount of time is
* very large, e.g. more than `TAO_MAX_SIGNED_INT(time_t)`, the
* very large, e.g. more than @ref TAO_MAX_TIME_SECONDS, the
* effect is the same as calling
* tao_lock_shared_mirror_for_reading(). If this amount of time
* is very short, the effect is the same as calling
......
This diff is collapsed.
......@@ -54,7 +54,7 @@ struct _shared_frame {
pthread_mutex_t mutex; /* Mutex to control access to this structure */
long locks; /* -1 if locked by a writer, 0 if not owned, n>0
if owned by n readers */
struct timespec time; /* Time stamp */
tao_time_t time; /* Time stamp */
frame_number_t number; /* Frame number (at 1kHz, overflow occurs after
more than 292 Myr) */
};
......@@ -84,10 +84,10 @@ struct _shared_data {
/* Type code of the custom TAO shared object. */
#define SHARED_DATA (TAO_SHARED_MAGIC | 5)
static double elapsed(const struct timespec* t1, struct timespec* t0)
static double elapsed(const tao_time_t* t1, const tao_time_t* t0)
{
return ((double)(t1->tv_sec - t0->tv_sec) +
1E-9*(double)(t1->tv_nsec - t0->tv_nsec));
return ((double)(t1->sec - t0->sec) +
1E-9*(double)(t1->nsec - t0->nsec));
}
#define ASSERT(expr) \
......@@ -115,7 +115,7 @@ static void notify_readers(shared_data_t* data)