Re: [PATCH] kernel.h: kill labs(), allow more types in abs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Nicolas Kaiser <nikai@xxxxxxxxx>:
> Looking through include/linux/kernel.h, it appears to me that
> labs() isn't used at all, and abs() returns only int.

Take for example this one:

arch/x86_64/kernel/time.c:
  abs(xtime.tv_nsec - 500000000) <= tick_nsec / 2) {

I would expect abs() to fail after tv_nsec accumulates more
than about 2.65 seconds. Right?

Cheers, n.

> --- a/include/linux/kernel.h	2005-11-20 11:48:57.000000000 +0100
> +++ b/include/linux/kernel.h	2005-11-24 19:44:09.000000000 +0100
> @@ -76,12 +76,7 @@ extern int cond_resched(void);
>  #define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
>  
>  #define abs(x) ({				\
> -		int __x = (x);			\
> -		(__x < 0) ? -__x : __x;		\
> -	})
> -
> -#define labs(x) ({				\
> -		long __x = (x);			\
> +		typeof(x) __x = (x);		\
>  		(__x < 0) ? -__x : __x;		\
>  	})

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux