History

bitops: define const_*() versions of the non-atomics

Define const_*() variants of the non-atomic bitops to be used when the input arguments are compile-time constants, so that the compiler will be always able to resolve those to compile-time constants as well. Those are mostly direct aliases for generic_*() with one exception for const_test_bit(): the original one is declared atomic-safe and thus doesn't discard the `volatile` qualifier, so in order to let optimize code, define it separately disregarding the qualifier. Add them to the compile-time type checks as well just in case.

Alexander Lobakin committed 4 years ago

Commit bb7379b1 parent 0e862832 files · +32 −0Browse files

Showing the changes to include/linux/bitops.h (1 of 2 files). Show all

Unified · Split

include/linux/bitops.h+1−0
@@ -37,6 +37,7 @@ extern unsigned long __sw_hweight64(__u64 w); · 36 unmodified lines
37/* Check that the bitops prototypes are sane */37/* Check that the bitops prototypes are sane */
38#define __check_bitop_pr(name) \38#define __check_bitop_pr(name) \
39 static_assert(__same_type(arch_##name, generic_##name) && \39 static_assert(__same_type(arch_##name, generic_##name) && \
40 __same_type(const_##name, generic_##name) && \
40 __same_type(name, generic_##name))41 __same_type(name, generic_##name))
41 42
42__check_bitop_pr(__set_bit);43__check_bitop_pr(__set_bit);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t