svn commit: r355759 - in head: include sys/sys

Conrad Meyer cem at FreeBSD.org
Sat Dec 14 21:52:50 UTC 2019


Author: cem
Date: Sat Dec 14 21:52:49 2019
New Revision: 355759
URL: https://svnweb.freebsd.org/changeset/base/355759

Log:
  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

Modified:
  head/include/stdlib.h
  head/sys/sys/cdefs.h

Modified: head/include/stdlib.h
==============================================================================
--- head/include/stdlib.h	Sat Dec 14 21:49:47 2019	(r355758)
+++ head/include/stdlib.h	Sat Dec 14 21:52:49 2019	(r355759)
@@ -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)
 {
 }

Modified: head/sys/sys/cdefs.h
==============================================================================
--- head/sys/sys/cdefs.h	Sat Dec 14 21:49:47 2019	(r355758)
+++ head/sys/sys/cdefs.h	Sat Dec 14 21:52:49 2019	(r355759)
@@ -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.


More information about the svn-src-head mailing list