cdefs: Add __deprecated(message) function attribute macro
The legacy version of GCC4 currently in base does not support the parameterized form of this function attribute, as recent introduced in stdlib.h (r355747). As we have done for other function attributes with similar compatibility problems, add a version-compatibile definition in sys/cdefs.h. Note that Clang defines itself to be GCC 4, so one must check for __clang__ in addition to __GNUC__ version. On legacy GCC 4, the macro expands to just the __deprecated__ attribute; on modern GCC or Clang, the macro expands to the parameterized variant with the message. Ignoring legacy or unsupported compilers, the macro is also beneficial in that it is a bit more ergonomic than the full __attribute__((__deprecated__())) boilerplate. Reported by: CI (but not tinderbox); imp and others Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D22817
This commit is contained in:
parent
547a4dba9f
commit
215332ffe7
@ -315,7 +315,7 @@ long long
|
||||
|
||||
/* Deprecated interfaces, to be removed. */
|
||||
static inline void
|
||||
__attribute__((__deprecated__("sranddev to be removed in FreeBSD 13")))
|
||||
__deprecated("sranddev to be removed in FreeBSD 13")
|
||||
sranddev(void)
|
||||
{
|
||||
}
|
||||
|
@ -468,6 +468,14 @@
|
||||
#define __hidden
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 4 || defined(__clang__)
|
||||
#define __deprecated(m) __attribute__((__deprecated__(m)))
|
||||
#elif defined(__GNUC__)
|
||||
#define __deprecated(m) __attribute__((__deprecated__))
|
||||
#else
|
||||
#define __deprecated(m)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
|
||||
* require it.
|
||||
|
Loading…
Reference in New Issue
Block a user