LinuxKPI: add __counted_by() and __nonstring

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 compile.

Sposnored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste, dim
Differential Revision: https://reviews.freebsd.org/D44587
This commit is contained in:
Bjoern A. Zeeb 2024-04-02 09:41:54 +00:00
parent 3f115b864b
commit 2a8c50592f

View File

@ -67,6 +67,17 @@
#define ____cacheline_aligned_in_smp __aligned(CACHE_LINE_SIZE) #define ____cacheline_aligned_in_smp __aligned(CACHE_LINE_SIZE)
#define fallthrough /* FALLTHROUGH */ do { } while(0) #define fallthrough /* FALLTHROUGH */ do { } while(0)
#if __has_attribute(__nonstring__)
#define __nonstring __attribute__((__nonstring__))
#else
#define __nonstring
#endif
#if __has_attribute(__counted_by__)
#define __counted_by(_x) __attribute__((__counted_by__(_x)))
#else
#define __counted_by(_x)
#endif
#define likely(x) __builtin_expect(!!(x), 1) #define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0) #define unlikely(x) __builtin_expect(!!(x), 0)
#define typeof(x) __typeof(x) #define typeof(x) __typeof(x)