[Skiboot] [PATCH V2 1/3] libc: Add abs() to stdlib

Balbir Singh bsingharora at gmail.com
Fri Sep 30 01:31:25 AEST 2016



On 28/09/16 22:17, Shilpasri G Bhat wrote:
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
> ---
> No changes.
>  libc/include/stdlib.h    |  1 +
>  libc/stdlib/Makefile.inc |  2 +-
>  libc/stdlib/abs.c        | 25 +++++++++++++++++++++++++
>  3 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 libc/stdlib/abs.c
> 
> diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
> index b4f1c38..d420687 100644
> --- a/libc/include/stdlib.h
> +++ b/libc/include/stdlib.h
> @@ -25,6 +25,7 @@ unsigned long int strtoul(const char *nptr, char **endptr, int base);
>  long int strtol(const char *nptr, char **endptr, int base);
>  
>  int rand(void);
> +int __attribute__((const)) abs(int n);

Why do we need an int based abs() implementation -- aren't we better of
implementing labs() and using it?

Balbir Singh.


More information about the Skiboot mailing list