Date: Wed, 12 Jun 2024 15:51:02 GMT From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a7ae78caaa17 - main - cdefs: Add __writeonly to mark write only vars Message-ID: <202406121551.45CFp29C057428@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a7ae78caaa17ff840da844c1dcaa780d194c9e20 commit a7ae78caaa17ff840da844c1dcaa780d194c9e20 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2024-06-12 13:04:13 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2024-06-12 13:04:13 +0000 cdefs: Add __writeonly to mark write only vars When a variable in write only and can't be removed, e.g. for API reasons, it is useful to document this fact similar to __diagused and __witness_used. Add __writeonly to tell the compiler and anyone looking at the code that this variable is expected to only be written to, and to not raise and error. Reviewed by: imp, kib Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45561 --- sys/sys/cdefs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 037dfa55f923..c3268791787f 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -180,6 +180,7 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __section(x) __attribute__((__section__(x))) #endif +#define __writeonly __unused #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) #define __alloc_size(x) __attribute__((__alloc_size__(x))) #define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202406121551.45CFp29C057428>