Commit 8dac3248 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] abs() fixes

OK, the pending abs() disaster has hit:

drivers/usb/class/audio.c:404: warning: static declaration of 'abs' follows non-static declaration

This is due to the declaration in kernel.h.  AFAIK there's not even a matching
definition for that.

The patch implements abs() as a macro in kernel.h and kills off various
private implementations.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f875aa02
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
extern int do_signal(sigset_t *, struct pt_regs *); extern int do_signal(sigset_t *, struct pt_regs *);
int abs(int);
EXPORT_SYMBOL(do_signal); EXPORT_SYMBOL(do_signal);
EXPORT_SYMBOL(isa_io_base); EXPORT_SYMBOL(isa_io_base);
...@@ -157,8 +155,6 @@ EXPORT_SYMBOL_NOVERS(memscan); ...@@ -157,8 +155,6 @@ EXPORT_SYMBOL_NOVERS(memscan);
EXPORT_SYMBOL_NOVERS(memcmp); EXPORT_SYMBOL_NOVERS(memcmp);
EXPORT_SYMBOL_NOVERS(memchr); EXPORT_SYMBOL_NOVERS(memchr);
EXPORT_SYMBOL(abs);
EXPORT_SYMBOL(timer_interrupt); EXPORT_SYMBOL(timer_interrupt);
EXPORT_SYMBOL(irq_desc); EXPORT_SYMBOL(irq_desc);
EXPORT_SYMBOL(get_wchan); EXPORT_SYMBOL(get_wchan);
......
...@@ -212,9 +212,6 @@ ...@@ -212,9 +212,6 @@
#define dprintk(x) #define dprintk(x)
#undef abs
extern int abs(int __x) __attribute_const__; /* Shut up warning */
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* /*
...@@ -398,17 +395,6 @@ struct usb_audio_state { ...@@ -398,17 +395,6 @@ struct usb_audio_state {
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* prevent picking up a bogus abs macro */
#undef abs
static inline int abs(int x)
{
if (x < 0)
return -x;
return x;
}
/* --------------------------------------------------------------------- */
static inline unsigned ld2(unsigned int x) static inline unsigned ld2(unsigned int x)
{ {
unsigned r = 0; unsigned r = 0;
......
...@@ -128,8 +128,6 @@ static inline void flush_altivec_to_thread(struct task_struct *t) ...@@ -128,8 +128,6 @@ static inline void flush_altivec_to_thread(struct task_struct *t)
} }
#endif #endif
extern int abs(int);
extern struct task_struct *__switch_to(struct task_struct *, extern struct task_struct *__switch_to(struct task_struct *,
struct task_struct *); struct task_struct *);
#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next))) #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
......
...@@ -54,6 +54,16 @@ void __might_sleep(char *file, int line); ...@@ -54,6 +54,16 @@ void __might_sleep(char *file, int line);
#define might_sleep_if(cond) do {} while (0) #define might_sleep_if(cond) do {} while (0)
#endif #endif
#define abs(x) ({ \
int __x = (x); \
(__x < 0) ? -__x : __x; \
})
#define labs(x) ({ \
long __x = (x); \
(__x < 0) ? -__x : __x; \
})
extern struct notifier_block *panic_notifier_list; extern struct notifier_block *panic_notifier_list;
NORET_TYPE void panic(const char * fmt, ...) NORET_TYPE void panic(const char * fmt, ...)
__attribute__ ((NORET_AND format (printf, 1, 2))); __attribute__ ((NORET_AND format (printf, 1, 2)));
...@@ -61,7 +71,6 @@ asmlinkage NORET_TYPE void do_exit(long error_code) ...@@ -61,7 +71,6 @@ asmlinkage NORET_TYPE void do_exit(long error_code)
ATTRIB_NORET; ATTRIB_NORET;
NORET_TYPE void complete_and_exit(struct completion *, long) NORET_TYPE void complete_and_exit(struct completion *, long)
ATTRIB_NORET; ATTRIB_NORET;
extern int abs(int);
extern unsigned long simple_strtoul(const char *,char **,unsigned int); extern unsigned long simple_strtoul(const char *,char **,unsigned int);
extern long simple_strtol(const char *,char **,unsigned int); extern long simple_strtol(const char *,char **,unsigned int);
extern unsigned long long simple_strtoull(const char *,char **,unsigned int); extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment