Merge branch 'master' into urcu/rcuja-range-merge
[userspace-rcu.git] / tests / regression / test_urcu_ja_range.h
CommitLineData
91233b5b
MD
1#ifndef _TEST_URCU_JA_RANGE_H
2#define _TEST_URCU_JA_RANGE_H
3
4/*
5 * test_urcu_ja.h
6 *
7 * Userspace RCU library - test program
8 *
9 * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
26#include "../config.h"
27#include <stdio.h>
28#include <pthread.h>
29#include <stdlib.h>
30#include <string.h>
31#include <sys/types.h>
32#include <sys/wait.h>
33#include <unistd.h>
34#include <stdio.h>
35#include <assert.h>
36#include <sched.h>
37#include <errno.h>
38#include <signal.h>
39
40#include <urcu/tls-compat.h>
b10c8ba8 41#include "thread-id.h"
91233b5b
MD
42
43#define DEFAULT_RAND_POOL 1000000
44
45/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
46#define CACHE_LINE_SIZE 4096
47
48/* hardcoded number of CPUs */
49#define NR_CPUS 16384
50
51#ifdef POISON_FREE
52#define poison_free(ptr) \
53 do { \
54 memset(ptr, 0x42, sizeof(*(ptr))); \
55 free(ptr); \
56 } while (0)
57#else
58#define poison_free(ptr) free(ptr)
59#endif
60
91233b5b
MD
61#ifndef DYNAMIC_LINK_TEST
62#define _LGPL_SOURCE
63#else
64#define debug_yield_read()
65#endif
66#include <urcu-qsbr.h>
67#include <urcu/rcuja-range.h>
68#include <urcu-call-rcu.h>
69
70struct wr_count {
71 unsigned long update_ops;
72 unsigned long add;
73 unsigned long add_exist;
74 unsigned long remove;
75};
76
77extern DECLARE_URCU_TLS(unsigned int, rand_lookup);
78extern DECLARE_URCU_TLS(unsigned long, nr_add);
79extern DECLARE_URCU_TLS(unsigned long, nr_addexist);
80extern DECLARE_URCU_TLS(unsigned long, nr_del);
81extern DECLARE_URCU_TLS(unsigned long, nr_delnoent);
82extern DECLARE_URCU_TLS(unsigned long, lookup_fail);
83extern DECLARE_URCU_TLS(unsigned long, lookup_ok);
84
85extern struct cds_ja *test_ja;
86
87extern volatile int test_go, test_stop;
88
89extern unsigned long wdelay;
90
91extern unsigned long duration;
92
93/* read-side C.S. duration, in loops */
94extern unsigned long rduration;
95
96extern unsigned long init_populate;
97extern int add_only;
98
99extern unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset;
100extern unsigned long init_pool_size,
101 lookup_pool_size,
102 write_pool_size;
103extern int validate_lookup;
104
105extern int count_pipe[2];
106
107static inline void loop_sleep(unsigned long l)
108{
109 while(l-- != 0)
110 caa_cpu_relax();
111}
112
113extern int verbose_mode;
114
115#define printf_verbose(fmt, args...) \
116 do { \
117 if (verbose_mode) \
118 printf(fmt, ## args); \
119 } while (0)
120
121extern unsigned int cpu_affinities[NR_CPUS];
122extern unsigned int next_aff;
123extern int use_affinity;
124
125extern pthread_mutex_t affinity_mutex;
126
127#ifndef HAVE_CPU_SET_T
128typedef unsigned long cpu_set_t;
129# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0)
130# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)
131#endif
132
133void set_affinity(void);
134
135/*
136 * returns 0 if test should end.
137 */
138static inline int test_duration_write(void)
139{
140 return !test_stop;
141}
142
143static inline int test_duration_read(void)
144{
145 return !test_stop;
146}
147
148extern DECLARE_URCU_TLS(unsigned long long, nr_writes);
149extern DECLARE_URCU_TLS(unsigned long long, nr_reads);
150
151extern unsigned int nr_readers;
152extern unsigned int nr_writers;
153
154void rcu_copy_mutex_lock(void);
155void rcu_copy_mutex_unlock(void);
156
157#endif /* _TEST_URCU_JA_RANGE_H */
This page took 0.028015 seconds and 4 git commands to generate.