Add checks for counted_by(_x) and nonstring as and depending
on compiler support enable the attribute/feature.
This is needed to make mtk76 and ath1xk drivers to compile.
Sposnored by: The FreeBSD Foundation
MFC after: 3 days
Differential D44587
LinuxKPI: add __counted_by() and __nonstring bz on Apr 2 2024, 10:00 AM. Authored by Tags None Referenced Files
Details Add checks for counted_by(_x) and nonstring as and depending This is needed to make mtk76 and ath1xk drivers to compile. Sposnored by: The FreeBSD Foundation
Diff Detail
Event TimelineComment Actions In general __has_attribute(foo) to check Comment Actions From a textcase in the LLVM review that introduced it (https://reviews.llvm.org/D148381): #if !__has_attribute(counted_by) #error "has attribute broken" #endif #ifdef COUNTED_BY #define __counted_by(member) __attribute__((__counted_by__(member))) #else #define __counted_by(member) #endif Comment Actions Hmm. Thanks! That review is a year old. I wonder if I had mis-spelled it. Comment Actions @emaste it seems most attributes in cdef.h have the __x__ instea dof just x. This seems to work with gcc as well for as much as I could test. It seems up-to gcc14-devel non of our gccs recognizes the counter_by in either spelling. Is this fine now? Comment Actions LGTM. (The forms without underscores have a higher probability of clashing with user-defined macros, which is why the forms with underscores are normally preferred.) |