15 #include <stdatomic.h>
20 #define MSG_COUNT 1000000
22 static atomic_uint insert_calls;
29 if(atomic_load_explicit(&msg->
flags, memory_order_acquire) ==
30 (MSG_FLAG_ANTI | MSG_FLAG_PROCESSED)){
31 atomic_fetch_add_explicit(&insert_calls, 1U, memory_order_relaxed);
35 static int remote_msg_map_test(
void)
37 struct lp_msg *msgs = malloc(
sizeof(*msgs) * MSG_COUNT);
38 memset(msgs, 0,
sizeof(*msgs) * MSG_COUNT);
40 for (uint64_t i = 0; i < MSG_COUNT; ++i) {
43 atomic_store_explicit(&msgs[i].
flags, MSG_FLAG_PROCESSED,
44 memory_order_release);
49 for (uint64_t i = 0; i < MSG_COUNT; ++i) {
50 remote_msg_map_match(msg_id_get(&msgs[i], i & 1U),
rid,
51 (i & 1U) ? &msgs[i] : NULL);
54 for (uint64_t i = 0; i < MSG_COUNT; ++i) {
55 remote_msg_map_match(msg_id_get(&msgs[i], i & 1U) + 1,
rid,
56 (i & 1U) ? NULL : &msgs[i]);
62 for(uint64_t i = 0; i < MSG_COUNT; ++i){
63 ret -= !(atomic_load_explicit(&msgs[i].
flags,
64 memory_order_acquire) & MSG_FLAG_ANTI);
66 ret -= insert_calls != ((MSG_COUNT - 1) / 3 + 1) * THREAD_CNT;
72 static int remote_msg_map_test_init(
void)
74 remote_msg_map_global_init();
78 static int remote_msg_map_test_fini(
void)
80 remote_msg_map_global_fini();
86 .test_init_fnc = remote_msg_map_test_init,
87 .test_fini_fnc = remote_msg_map_test_fini,
88 .test_fnc = remote_msg_map_test