mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] deprecated function attribute
@ 2002-12-28 23:32 william stinson
  0 siblings, 0 replies; 5+ messages in thread
From: william stinson @ 2002-12-28 23:32 UTC (permalink / raw)
  To: Robert Love
  Cc: Alexander Kellett, Rusty Russell, torvalds, linux-kernel, trivial

Hi Robert,

here's a patch to mark check_region "deprecated".

I have not done much testing with it yet (and maybe there is a more elegant implementation)

I do get nice warning messages for programs that still use check_region for example
	drivers/parport/parport_pc.c:2215: warning: `__check_region' is deprecated (declared at include/linux/ioport.h:111)

Best regards
William

--- linux-2.5.53/kernel/resource.c	2002-12-28 23:05:37.000000000 +0100
+++ linux-local/kernel/resource.c	2002-12-28 23:05:55.000000000 +0100
@@ -237,7 +237,7 @@
 	return res;
 }
 
-int __check_region(struct resource *parent, unsigned long start, unsigned long n)
+int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n)
 {
 	struct resource * res;
 
--- linux-2.5.53/include/linux/ioport.h	2002-12-28 23:02:52.000000000 +0100
+++ linux-local/include/linux/ioport.h	2002-12-28 23:14:46.000000000 +0100
@@ -8,6 +8,7 @@
 #ifndef _LINUX_IOPORT_H
 #define _LINUX_IOPORT_H
 
+#include <linux/compiler.h>
 /*
  * Resources are tree-like, allowing
  * nesting etc..
@@ -107,7 +108,7 @@
 #define check_mem_region(start,n)	__check_region(&iomem_resource, (start), (n))
 #define release_mem_region(start,n)	__release_region(&iomem_resource, (start), (n))
 
-extern int __check_region(struct resource *, unsigned long, unsigned long);
+extern int deprecated __check_region(struct resource *, unsigned long, unsigned long);
 extern void __release_region(struct resource *, unsigned long, unsigned long);
 
 #define get_ioport_list(buf)	get_resource_list(&ioport_resource, buf, PAGE_SIZE)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] deprecated function attribute
  2002-12-28 18:53       ` Daniel Jacobowitz
@ 2002-12-28 20:50         ` Robert Love
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Love @ 2002-12-28 20:50 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: linux-kernel

On Sat, 2002-12-28 at 13:53, Daniel Jacobowitz wrote:

> > If we want to be preemptive, we can rename the above to "__deprecated__"
> > but I think plain "deprecated" is much better looking.
> 
> Eek, please call it something else - something that looks visibly like
> a syntax rather than a name.  __deprecated or __deprecated__ or
> DEPRECATED.

Like I said, that is fine with me...

Attached.  Still untested :-)

	Robert Love

 compiler.h |   13 +++++++++++++
 1 files changed, 13 insertions(+)


diff -urN linux-2.5.53/include/linux/compiler.h linux/include/linux/compiler.h
--- linux-2.5.53/include/linux/compiler.h	2002-12-28 12:38:56.000000000 -0500
+++ linux/include/linux/compiler.h	2002-12-28 12:45:03.000000000 -0500
@@ -13,6 +13,19 @@
 #define likely(x)	__builtin_expect((x),1)
 #define unlikely(x)	__builtin_expect((x),0)
 
+/*
+ * Allow us to mark functions as 'deprecated' and have gcc emit a nice
+ * warning for each use, in hopes of speeding the functions removal.
+ * Usage is:
+ * 		int deprecated foo(void)
+ * and then gcc will emit a warning for each usage of the function.
+ */
+#if __GNUC__ == 3
+#define __deprecated__		__attribute__((deprecated))
+#else
+#define __deprecated__
+#endif
+
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] deprecated function attribute
  2002-12-28 18:03     ` Robert Love
@ 2002-12-28 18:53       ` Daniel Jacobowitz
  2002-12-28 20:50         ` Robert Love
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2002-12-28 18:53 UTC (permalink / raw)
  To: linux-kernel

On Sat, Dec 28, 2002 at 01:03:52PM -0500, Robert Love wrote:
> On Sat, 2002-12-28 at 12:51, Robert Love wrote:
> 
> > +#if __GNUC__ == 3
> > +#define deprecated	__attribute__((deprecated))
> > +#else
> > +#define deprecated
> > +#endif
> 
> Before someone points it out: I grepped the tree and did not see any
> uses of "deprecated" as a token on first glance.  So the above is safe.
> 
> If we want to be preemptive, we can rename the above to "__deprecated__"
> but I think plain "deprecated" is much better looking.

Eek, please call it something else - something that looks visibly like
a syntax rather than a name.  __deprecated or __deprecated__ or
DEPRECATED.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] deprecated function attribute
  2002-12-28 17:51   ` [PATCH] deprecated function attribute Robert Love
@ 2002-12-28 18:03     ` Robert Love
  2002-12-28 18:53       ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Love @ 2002-12-28 18:03 UTC (permalink / raw)
  To: Alexander Kellett
  Cc: Rusty Russell, torvalds, linux-kernel, william stinson, trivial

On Sat, 2002-12-28 at 12:51, Robert Love wrote:

> +#if __GNUC__ == 3
> +#define deprecated	__attribute__((deprecated))
> +#else
> +#define deprecated
> +#endif

Before someone points it out: I grepped the tree and did not see any
uses of "deprecated" as a token on first glance.  So the above is safe.

If we want to be preemptive, we can rename the above to "__deprecated__"
but I think plain "deprecated" is much better looking.

	Robert Love


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] deprecated function attribute
  2002-12-28 15:30 ` Alexander Kellett
@ 2002-12-28 17:51   ` Robert Love
  2002-12-28 18:03     ` Robert Love
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Love @ 2002-12-28 17:51 UTC (permalink / raw)
  To: Alexander Kellett
  Cc: Rusty Russell, torvalds, linux-kernel, william stinson, trivial

On Sat, 2002-12-28 at 10:30, Alexander Kellett wrote:

> can gcc 3.2's __attribute__((deprecated)) be used?

I just tested it and it seems to work.  If we mark a function as
deprecated, then each use of the function emits a warning like:

	foo.c:12: warning: `baz' is deprecated (declared at bar.c:60)

Which is very informative, giving both the location of each usage and
where the little bastard is declared.

It seems like this was added in gcc 3.0, not 3.2?  It was at least in
3.1...

Attached patch adds support for usage of the attribute as "deprecated"
and is backward-compatible.  Usage is:

	int deprecated foo(void)

etc.. The attached patch is _entirely_ untested.

	Robert Love

 compiler.h |   13 +++++++++++++
 1 files changed, 13 insertions(+)


diff -urN linux-2.5.53/include/linux/compiler.h linux/include/linux/compiler.h
--- linux-2.5.53/include/linux/compiler.h	2002-12-28 12:38:56.000000000 -0500
+++ linux/include/linux/compiler.h	2002-12-28 12:45:03.000000000 -0500
@@ -13,6 +13,19 @@
 #define likely(x)	__builtin_expect((x),1)
 #define unlikely(x)	__builtin_expect((x),0)
 
+/*
+ * Allow us to mark functions as 'deprecated' and have gcc emit a nice
+ * warning for each use, in hopes of speeding the functions removal.
+ * Usage is:
+ * 		int deprecated foo(void)
+ * and then gcc will emit a warning for each usage of the function.
+ */
+#if __GNUC__ == 3
+#define deprecated	__attribute__((deprecated))
+#else
+#define deprecated
+#endif
+
 /* This macro obfuscates arithmetic on a variable address so that gcc
    shouldn't recognize the original var, and make assumptions about it */
 #define RELOC_HIDE(ptr, off)					\




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-12-28 23:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-28 23:32 [PATCH] deprecated function attribute william stinson
  -- strict thread matches above, loose matches on Subject: below --
2002-12-28  0:57 [PATCH] Mark deprecated functions so they give a warning on use Rusty Russell
2002-12-28 15:30 ` Alexander Kellett
2002-12-28 17:51   ` [PATCH] deprecated function attribute Robert Love
2002-12-28 18:03     ` Robert Love
2002-12-28 18:53       ` Daniel Jacobowitz
2002-12-28 20:50         ` Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®