[tor-bugs] #23953 [Core Tor/Tor]: Use stdatomic counters where available

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Nov 20 19:10:51 UTC 2017


#23953: Use stdatomic counters where available
-----------------------------+------------------------------------
 Reporter:  nickm            |          Owner:  nickm
     Type:  enhancement      |         Status:  needs_revision
 Priority:  Medium           |      Milestone:  Tor: 0.3.3.x-final
Component:  Core Tor/Tor     |        Version:
 Severity:  Normal           |     Resolution:
 Keywords:  review-group-25  |  Actual Points:
Parent ID:                   |         Points:
 Reviewer:  dgoulet          |        Sponsor:
-----------------------------+------------------------------------
Changes (by dgoulet):

 * status:  needs_review => needs_revision


Comment:

 * The destroy function, can't we just NOP it instead of doing this
 function call that I think the compiler will never optimize out because of
 this `(void)` thing?

 {{{
 +void
 +atomic_counter_destroy(atomic_counter_t *counter)
 +{
 +  (void)counter;
 +}
 }}}

 Into something like:

 {{{
 #define atomic_counter_destroy(c)
 }}}

 Second thing, in terms of performance, shouldn't those be better as
 `static inline`? I'm not sure how much they are used in Tor but if it is a
 _lot_, that could help a bit instead of a function jump.

 One last tiny thing, if you could put the comment in the #else and #endif,
 it would be grand!

 {{{
 #ifdef HAVE_STDATOMIC_H
 ...
 #else /* HAVE_STDATOMIC_H */
 ...
 #endif /* HAVE_STDATOMIC_H */
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23953#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list