/usr/include/xenomai/nucleus/seqlock.h is in libxenomai-dev 2.6.2.1-2ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #ifndef __SEQLOCK_H
#define __SEQLOCK_H
/* Originally from the linux kernel, adapted for userland and Xenomai */
#include <asm/xenomai/atomic.h>
typedef struct xnseqcount {
unsigned sequence;
} xnseqcount_t;
#define XNSEQCNT_ZERO { 0 }
#define xnseqcount_init(x) do { *(x) = (xnseqcount_t) SEQCNT_ZERO; } while (0)
/* Start of read using pointer to a sequence counter only. */
static inline unsigned xnread_seqcount_begin(const xnseqcount_t *s)
{
unsigned ret;
repeat:
ret = s->sequence;
xnarch_read_memory_barrier();
if (unlikely(ret & 1)) {
cpu_relax();
goto repeat;
}
return ret;
}
/*
* Test if reader processed invalid data because sequence number has changed.
*/
static inline int xnread_seqcount_retry(const xnseqcount_t *s, unsigned start)
{
xnarch_read_memory_barrier();
return s->sequence != start;
}
/*
* The sequence counter only protects readers from concurrent writers.
* Writers must use their own locking.
*/
static inline void xnwrite_seqcount_begin(xnseqcount_t *s)
{
s->sequence++;
xnarch_write_memory_barrier();
}
static inline void xnwrite_seqcount_end(xnseqcount_t *s)
{
xnarch_write_memory_barrier();
s->sequence++;
}
#endif /* __SEQLOCK_H */
|