<div dir="ltr">Yes but all read/write operations doesn't have the syntax of a function as you used in the example here i.e. use(...). When it is a function you can easily just change the implementation to check if it is called inside a read section. Some reads and writes are usually done by this syntax (a = b) and '=' cannot be overridden.<div><br></div><div>BTW just saying that what we're talking about now is not the original topic, but if someone has an elegant solution to this that would be nice!<br><div><br></div><div>Thanks</div><div>Thobias</div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">tir. 2. sep. 2025 kl. 23:34 skrev Ondřej Surý <<a href="mailto:ondrej@sury.org">ondrej@sury.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If I understand you correctly, you can do something like this:<br>
<br>
#undef rcu_read_lock<br>
#define rcu_read_lock() urcu_memb_read_lock(); {<br>
<br>
#undef rcu_read_unlock<br>
#define rcu_read_lock() } urcu_memb_read_unlock();<br>
<br>
(replace memb with your RCU variant of course)<br>
<br>
and make your code declare all the RCU protected pointers inside the RCU critical section, e.g.<br>
<br>
rcu_read_lock();<br>
my_pointer *foo = rcu_dereference(...);<br>
<br>
use(foo); /* valid */<br>
<br>
rcu_read_unlock();<br>
<br>
<br>
use(foo); /* invalid and caught by the compiler */<br>
<br>
Ondrej<br>
--<br>
Ondřej Surý (He/Him)<br>
<a href="mailto:ondrej@sury.org" target="_blank">ondrej@sury.org</a><br>
<br>
> On 2. 9. 2025, at 23:06, Thobias Knudsen via lttng-dev <<a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a>> wrote:<br>
> <br>
> Yes, that is what I'm worried about. For my case when using URCU that is my biggest concern, as the debug macro "library" I made checks everything else, if I haven't overlooked anything.<br>
> <br>
<br>
</blockquote></div>