Opened 7 years ago
Closed 7 years ago
#11722 closed Bugs (fixed)
boost::lockfree should use BOOST_LIKELY/UNLIKELY macros instead of defining likely/unlikely as inline fns
Reported by: | Owned by: | timblechmann | |
---|---|---|---|
Milestone: | To Be Determined | Component: | lockfree |
Version: | Boost 1.58.0 | Severity: | Problem |
Keywords: | likely, BOOST_LIKELY | Cc: |
Description
Currently boost::lockfree defines unlikely/unlikely inline functions in branch_hints.hpp. This name is generic and causes conflicts with other (external) libs which also defines likely/unlikely. (linux kernel also defines them the same). boost already has macros defined for this as BOOST_LIKELY/UNLIKELY in boost/config.hpp, and lockfree should use these to avoid conflicts and to be consistent.
The following changes were done in boost_1_58_0, and tested to avoid a conflict case.
* Comment out the following lines: (not required; those files don’t use likely/unlikely) detail/tagged_ptr_dcas.hpp:#include <boost/lockfree/detail/branch_hints.hpp> detail/tagged_ptr_ptrcompression.hpp:#include <boost/lockfree/detail/branch_hints.hpp> * Replace the following include line with “#include <boost/config.hpp> // for BOOST_LIKELY” spsc_queue.hpp:#include <boost/lockfree/detail/branch_hints.hpp> * Add “#include <boost/config.hpp> // for BOOST_LIKELY” to queue.hpp * Change the following likely/unlikely to BOOST_LIKELY/BOOST_UNLIKELY queue.hpp: using detail::likely; queue.hpp: if (likely(tail == tail2)) { queue.hpp: using detail::likely; queue.hpp: if (likely(head == head2)) { spsc_queue.hpp: while (unlikely(ret >= max_size)) * note that this makes the branch_hints.hpp redundant.
Change History (4)
comment:1 by , 7 years ago
comment:3 by , 7 years ago
Pull request submitted. https://github.com/wolfie2x/lockfree/commit/14039a027433a0a9d6b5f7bfd7b54c157997ea90
Let me know if there's anything more I could do.
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note that the mentioned changes were done in a "local copy" of boost_1_58_0; not committed to boost.