#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
+#include <limits.h>
#include <compiler.h>
#include <arch.h>
* Using a int rather than a char to eliminate false register dependencies
* causing stalls on some architectures.
*/
-extern long urcu_gp_ctr;
+extern unsigned long urcu_gp_ctr;
-extern long __thread rcu_reader_qs_gp;
+extern unsigned long __thread rcu_reader_qs_gp;
-static inline int rcu_gp_ongoing(long *value)
+static inline int rcu_gp_ongoing(unsigned long *value)
{
- long reader_gp;
+ unsigned long reader_gp;
if (value == NULL)
return 0;
reader_gp = LOAD_SHARED(*value);
- return reader_gp && (reader_gp - urcu_gp_ctr < 0);
+ return reader_gp && (reader_gp - urcu_gp_ctr > ULONG_MAX / 2);
}
static inline void _rcu_read_lock(void)
/*
* Global grace period counter.
*/
-long urcu_gp_ctr = 1;
+unsigned long urcu_gp_ctr = 1;
/*
* Written to only by each individual reader. Read by both the reader and the
* writers.
*/
-long __thread rcu_reader_qs_gp;
+unsigned long __thread rcu_reader_qs_gp;
/* Thread IDs of registered readers */
#define INIT_NUM_THREADS 4
struct reader_registry {
pthread_t tid;
- long *rcu_reader_qs_gp;
+ unsigned long *rcu_reader_qs_gp;
};
#ifdef DEBUG_YIELD
void synchronize_rcu(void)
{
- long was_online;
+ unsigned long was_online;
was_online = rcu_reader_qs_gp;