git: 16672453f125 - main - cdefs: Add __deprecated

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 15 Oct 2024 21:18:06 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=16672453f12586703f1c51d909bd1900691bf884

commit 16672453f12586703f1c51d909bd1900691bf884
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-10-15 19:49:53 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-10-15 21:05:49 +0000

    cdefs: Add __deprecated
    
    Add __deprecated decorator. This is for a deprecated interface. copystr
    is tagged with this today in copy(9), but don't actually provide it or
    use it. copystr is a #define so adding it will have to wait.
    
    LinuxKPI was defining this away completely in compiler.h. Since this is
    shared between Linux KPI consumers and OpenZFS, if it's already defined,
    use the FreeBSD sys/cdefs.h version, otherwise define it away. For
    OpenZFS this will retain it, while for Linux KPI it will tend to drop it
    (I think always, but I didn't look at everything).
    
    Sponsored by:           Netflix
    Reviewed by:            jhb, emaste
    Differential Revision:  https://reviews.freebsd.org/D46137
---
 share/man/man9/cdefs.9                              | 6 +++++-
 sys/compat/linuxkpi/common/include/linux/compiler.h | 2 ++
 sys/sys/cdefs.h                                     | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/share/man/man9/cdefs.9 b/share/man/man9/cdefs.9
index 8c127694ab6e..3d1f6159bc60 100644
--- a/share/man/man9/cdefs.9
+++ b/share/man/man9/cdefs.9
@@ -85,8 +85,12 @@ linkage.
 .It Sy __weak_symbol Ta Declare the symbol to be a weak symbol
 .It Sy __dead2 Ta Function will not return
 .It Sy __pure2 Ta Function has no side effects
-.It Sy __unused Ta To Variable may be unused (usually arguments), so do not warn about it
+.It Sy __unused Ta To Variable may be unused (usually arguments), so do not
+warn about it
 .It Sy __used Ta Function really is used, so emit it even if it appears unused.
+.It Sy __deprecated Ta Function interface has been deprecated, and clients
+should migrate to a new interface.
+A warning will be issued for clients of this interface.
 .It Sy __packed Ta \&Do not have space between structure elements for natural alignment.
 Used when communicating with external protocols.
 .It Sy __aligned(x) Ta Specify in bytes the minimum alignment for the specified field, structure or variable
diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h
index c82b9acd53fb..fb5ad3bf4fe4 100644
--- a/sys/compat/linuxkpi/common/include/linux/compiler.h
+++ b/sys/compat/linuxkpi/common/include/linux/compiler.h
@@ -48,7 +48,9 @@
 #define __cond_lock(x,c)		(c)
 #define	__bitwise
 #define __devinitdata
+#ifndef	__deprecated
 #define	__deprecated
+#endif
 #define __init
 #define	__initconst
 #define	__devinit
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 9c4c8e0a324a..353090db6995 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -154,6 +154,7 @@
 #define	__pure2		__attribute__((__const__))
 #define	__unused	__attribute__((__unused__))
 #define	__used		__attribute__((__used__))
+#define __deprecated	__attribute__((__deprecated__))
 #define	__packed	__attribute__((__packed__))
 #define	__aligned(x)	__attribute__((__aligned__(x)))
 #define	__section(x)	__attribute__((__section__(x)))