[v3] stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabs
Checks
Commit Message
C2Y adds unsigned versions of the abs functions (see C2Y draft N3467 and
proposal N3349).
Tested for x86_64.
Signed-off-by: Lenard Mollenkopf <glibc@lenardmollenkopf.de>
---
NEWS | 3 +
manual/arith.texi | 12 +++-
stdlib/Makefile | 10 ++++
stdlib/Versions | 6 ++
stdlib/inttypes.h | 5 ++
stdlib/stdlib.h | 6 ++
stdlib/tst-uabs.c | 45 +++++++++++++++
stdlib/tst-ulabs.c | 52 ++++++++++++++++++
stdlib/tst-ullabs.c | 55 +++++++++++++++++++
stdlib/uabs.c | 27 +++++++++
stdlib/ulabs.c | 27 +++++++++
stdlib/ullabs.c | 27 +++++++++
sysdeps/mach/hurd/i386/libc.abilist | 4 ++
sysdeps/mach/hurd/x86_64/libc.abilist | 3 +
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/alpha/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/arc/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/arm/be/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/arm/le/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/csky/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/hppa/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/i386/libc.abilist | 4 ++
.../sysv/linux/loongarch/lp64/libc.abilist | 4 ++
.../sysv/linux/m68k/coldfire/libc.abilist | 4 ++
.../unix/sysv/linux/m68k/m680x0/libc.abilist | 4 ++
.../sysv/linux/microblaze/be/libc.abilist | 4 ++
.../sysv/linux/microblaze/le/libc.abilist | 4 ++
.../sysv/linux/mips/mips32/fpu/libc.abilist | 4 ++
.../sysv/linux/mips/mips32/nofpu/libc.abilist | 4 ++
.../sysv/linux/mips/mips64/n32/libc.abilist | 4 ++
.../sysv/linux/mips/mips64/n64/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/or1k/libc.abilist | 4 ++
.../linux/powerpc/powerpc32/fpu/libc.abilist | 4 ++
.../powerpc/powerpc32/nofpu/libc.abilist | 4 ++
.../linux/powerpc/powerpc64/be/libc.abilist | 4 ++
.../linux/powerpc/powerpc64/le/libc.abilist | 4 ++
.../unix/sysv/linux/riscv/rv32/libc.abilist | 4 ++
.../unix/sysv/linux/riscv/rv64/libc.abilist | 4 ++
.../unix/sysv/linux/s390/s390-32/libc.abilist | 4 ++
.../unix/sysv/linux/s390/s390-64/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/sh/be/libc.abilist | 4 ++
sysdeps/unix/sysv/linux/sh/le/libc.abilist | 4 ++
.../sysv/linux/sparc/sparc32/libc.abilist | 4 ++
.../sysv/linux/sparc/sparc64/libc.abilist | 4 ++
.../unix/sysv/linux/x86_64/64/libc.abilist | 4 ++
.../unix/sysv/linux/x86_64/x32/libc.abilist | 4 ++
sysdeps/wordsize-32/ullabs.c | 22 ++++++++
sysdeps/wordsize-64/ulabs.c | 22 ++++++++
48 files changed, 452 insertions(+), 2 deletions(-)
create mode 100644 stdlib/tst-uabs.c
create mode 100644 stdlib/tst-ulabs.c
create mode 100644 stdlib/tst-ullabs.c
create mode 100644 stdlib/uabs.c
create mode 100644 stdlib/ulabs.c
create mode 100644 stdlib/ullabs.c
create mode 100644 sysdeps/wordsize-32/ullabs.c
create mode 100644 sysdeps/wordsize-64/ulabs.c
Comments
On 2025-03-09 14:42, Lenard Mollenkopf wrote:
> + return i < 0 ? -(unsigned int)i : i;
It's better to avoid casts, for reasons mentioned earlier in this
thread. Like this:
unsigned int u = i;
return i < 0 ? -u : u;
On 09/03/25 18:42, Lenard Mollenkopf wrote:
> C2Y adds unsigned versions of the abs functions (see C2Y draft N3467 and
> proposal N3349).
>
> Tested for x86_64.
>
> Signed-off-by: Lenard Mollenkopf <glibc@lenardmollenkopf.de>
> ---
> NEWS | 3 +
> manual/arith.texi | 12 +++-
> stdlib/Makefile | 10 ++++
> stdlib/Versions | 6 ++
> stdlib/inttypes.h | 5 ++
> stdlib/stdlib.h | 6 ++
> stdlib/tst-uabs.c | 45 +++++++++++++++
> stdlib/tst-ulabs.c | 52 ++++++++++++++++++
> stdlib/tst-ullabs.c | 55 +++++++++++++++++++
> stdlib/uabs.c | 27 +++++++++
> stdlib/ulabs.c | 27 +++++++++
> stdlib/ullabs.c | 27 +++++++++
> sysdeps/mach/hurd/i386/libc.abilist | 4 ++
> sysdeps/mach/hurd/x86_64/libc.abilist | 3 +
> sysdeps/unix/sysv/linux/aarch64/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/alpha/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/arc/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/arm/be/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/arm/le/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/csky/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/hppa/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/i386/libc.abilist | 4 ++
> .../sysv/linux/loongarch/lp64/libc.abilist | 4 ++
> .../sysv/linux/m68k/coldfire/libc.abilist | 4 ++
> .../unix/sysv/linux/m68k/m680x0/libc.abilist | 4 ++
> .../sysv/linux/microblaze/be/libc.abilist | 4 ++
> .../sysv/linux/microblaze/le/libc.abilist | 4 ++
> .../sysv/linux/mips/mips32/fpu/libc.abilist | 4 ++
> .../sysv/linux/mips/mips32/nofpu/libc.abilist | 4 ++
> .../sysv/linux/mips/mips64/n32/libc.abilist | 4 ++
> .../sysv/linux/mips/mips64/n64/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/or1k/libc.abilist | 4 ++
> .../linux/powerpc/powerpc32/fpu/libc.abilist | 4 ++
> .../powerpc/powerpc32/nofpu/libc.abilist | 4 ++
> .../linux/powerpc/powerpc64/be/libc.abilist | 4 ++
> .../linux/powerpc/powerpc64/le/libc.abilist | 4 ++
> .../unix/sysv/linux/riscv/rv32/libc.abilist | 4 ++
> .../unix/sysv/linux/riscv/rv64/libc.abilist | 4 ++
> .../unix/sysv/linux/s390/s390-32/libc.abilist | 4 ++
> .../unix/sysv/linux/s390/s390-64/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/sh/be/libc.abilist | 4 ++
> sysdeps/unix/sysv/linux/sh/le/libc.abilist | 4 ++
> .../sysv/linux/sparc/sparc32/libc.abilist | 4 ++
> .../sysv/linux/sparc/sparc64/libc.abilist | 4 ++
> .../unix/sysv/linux/x86_64/64/libc.abilist | 4 ++
> .../unix/sysv/linux/x86_64/x32/libc.abilist | 4 ++
> sysdeps/wordsize-32/ullabs.c | 22 ++++++++
> sysdeps/wordsize-64/ulabs.c | 22 ++++++++
> 48 files changed, 452 insertions(+), 2 deletions(-)
> create mode 100644 stdlib/tst-uabs.c
> create mode 100644 stdlib/tst-ulabs.c
> create mode 100644 stdlib/tst-ullabs.c
> create mode 100644 stdlib/uabs.c
> create mode 100644 stdlib/ulabs.c
> create mode 100644 stdlib/ullabs.c
> create mode 100644 sysdeps/wordsize-32/ullabs.c
> create mode 100644 sysdeps/wordsize-64/ulabs.c
>
> diff --git a/NEWS b/NEWS
> index 29d3d47b64..1ede65e91a 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -16,6 +16,9 @@ Major new features:
>
> - Power and absolute-value functions: rsqrt.
>
> +* The ISO C2Y family of unsigned abs functions, i.e.
> + uabs, ulab, ullabs and uimaxabs, are now supported.
> +
> Deprecated and removed features, and other changes affecting compatibility:
>
> [Add deprecations, removals and changes affecting compatibility here]
> diff --git a/manual/arith.texi b/manual/arith.texi
> index 034d9d2ba5..c8636f8c5a 100644
> --- a/manual/arith.texi
> +++ b/manual/arith.texi
> @@ -1233,25 +1233,33 @@ whose imaginary part is @var{y}, the absolute value is @w{@code{sqrt
>
> @pindex math.h
> @pindex stdlib.h
> -Prototypes for @code{abs}, @code{labs} and @code{llabs} are in @file{stdlib.h};
> -@code{imaxabs} is declared in @file{inttypes.h};
> +Prototypes for @code{abs}, @code{labs}, @code{llabs},
> +@code{uabs}, @code{ulabs} @code{ullabs} are in @file{stdlib.h};
> +@code{imaxabs} and @code{uimaxabs} are declared in @file{inttypes.h};
> the @code{fabs} functions are declared in @file{math.h};
> the @code{cabs} functions are declared in @file{complex.h}.
>
> @deftypefun int abs (int @var{number})
> @deftypefunx {long int} labs (long int @var{number})
> @deftypefunx {long long int} llabs (long long int @var{number})
> +@deftypefunx unsigned int uabs (int @var{number})
> +@deftypefunx {unsigned long int} ulabs (long int @var{number})
> +@deftypefunx {unsigned long long int} ullabs (long long int @var{number})
> @deftypefunx intmax_t imaxabs (intmax_t @var{number})
> +@deftypefunx uintmax_t uimaxabs (intmax_t @var{number})
> @standards{ISO, stdlib.h}
> @standardsx{imaxabs, ISO, inttypes.h}
> +@standardsx{uimaxabs, ISO, inttypes.h}
> @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> These functions return the absolute value of @var{number}.
>
> Most computers use a two's complement integer representation, in which
> the absolute value of @code{INT_MIN} (the smallest possible @code{int})
> cannot be represented; thus, @w{@code{abs (INT_MIN)}} is not defined.
> +Using @code{uabs} avoids this.
>
> @code{llabs} and @code{imaxdiv} are new to @w{ISO C99}.
> +@code{uabs}, @code{ulabs}, @code{ullabs} and @code{uimaxabs} are new to @w{ISO C2Y}.
>
> See @ref{Integers} for a description of the @code{intmax_t} type.
>
> diff --git a/stdlib/Makefile b/stdlib/Makefile
> index c9c8f702a2..1fb5fbc9b5 100644
> --- a/stdlib/Makefile
> +++ b/stdlib/Makefile
> @@ -211,6 +211,9 @@ routines := \
> strtoull_l \
> swapcontext \
> system \
> + uabs \
> + ulabs \
> + ullabs \
> wcstombs \
> wctomb \
> xpg_basename \
> @@ -361,6 +364,9 @@ tests := \
> tst-swapcontext2 \
> tst-thread-quick_exit \
> tst-tininess \
> + tst-uabs \
> + tst-ulabs \
> + tst-ullabs \
> tst-unsetenv1 \
> tst-width \
> tst-width-stdint \
> @@ -410,6 +416,10 @@ CFLAGS-tst-abs.c += -fno-builtin
> CFLAGS-tst-labs.c += -fno-builtin
> CFLAGS-tst-llabs.c += -fno-builtin
>
> +CFLAGS-tst-uabs.c += -fno-builtin
> +CFLAGS-tst-ulabs.c += -fno-builtin
> +CFLAGS-tst-ullabs.c += -fno-builtin
> +
> CFLAGS-tst-stdbit-Wconversion.c += -Wconversion -Werror
> CFLAGS-tst-stdc_trailing_zeros.c += -fno-builtin
> CFLAGS-tst-stdc_trailing_ones.c += -fno-builtin
Add a uimaxabs test as well to check that aliases are done correctly.
> diff --git a/stdlib/Versions b/stdlib/Versions
> index ea2265bbd4..6d024000f8 100644
> --- a/stdlib/Versions
> +++ b/stdlib/Versions
> @@ -223,6 +223,12 @@ libc {
> stdc_bit_ceil_ul;
> stdc_bit_ceil_ull;
> }
> + GLIBC_2.42 {
> + uabs;
> + uimaxabs;
> + ulabs;
> + ullabs;
> + }
> GLIBC_PRIVATE {
> # functions which have an additional interface since they are
> # are cancelable.
> diff --git a/stdlib/inttypes.h b/stdlib/inttypes.h
> index 95324f0784..9726abf5b1 100644
> --- a/stdlib/inttypes.h
> +++ b/stdlib/inttypes.h
> @@ -350,6 +350,11 @@ typedef struct
> /* Compute absolute value of N. */
> extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
>
> +
> +#if __GLIBC_USE (ISOC2Y)
> +extern uintmax_t uimaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
> +#endif
> +
> /* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
> extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
> __THROW __attribute__ ((__const__));
> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
> index 975f5aeb0b..cd4503c761 100644
> --- a/stdlib/stdlib.h
> +++ b/stdlib/stdlib.h
> @@ -985,6 +985,12 @@ __extension__ extern long long int llabs (long long int __x)
> __THROW __attribute__ ((__const__)) __wur;
> #endif
>
> +#if __GLIBC_USE (ISOC2Y)
> +extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur;
> +extern unsigned long int ulabs (long int __x) __THROW __attribute__ ((__const__)) __wur;
> +__extension__ extern unsigned long long int ullabs (long long int __x)
> + __THROW __attribute__ ((__const__)) __wur;
> +#endif
>
> /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
> of the value of NUMER over DENOM. */
> diff --git a/stdlib/tst-uabs.c b/stdlib/tst-uabs.c
> new file mode 100644
> index 0000000000..13c9f58dc0
> --- /dev/null
> +++ b/stdlib/tst-uabs.c
> @@ -0,0 +1,45 @@
> +/* Basic tests for uabs.
> + Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <limits.h>
> +#include <stdlib.h>
> +
> +#include <support/check.h>
> +
> +#define LARGE_PRIME 49999
> +
> +static int do_test (void)
> +{
> + int i;
> +
> + TEST_COMPARE (uabs (INT_MAX), INT_MAX);
> + TEST_COMPARE (uabs (INT_MIN), (unsigned int)INT_MAX + 1);
> + TEST_COMPARE (uabs (-1), 1);
> + TEST_COMPARE (uabs (0), 0);
> + TEST_COMPARE (uabs (1), 1);
> +
> + for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
> + TEST_COMPARE (uabs (i), -i);
> +
> + for (i = 0; i < INT_MAX - LARGE_PRIME; i += LARGE_PRIME)
> + TEST_COMPARE (uabs (i), i);
> +
> + return EXIT_SUCCESS;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/stdlib/tst-ulabs.c b/stdlib/tst-ulabs.c
> new file mode 100644
> index 0000000000..e73f77d01d
> --- /dev/null
> +++ b/stdlib/tst-ulabs.c
> @@ -0,0 +1,52 @@
> +/* Basic tests for ulabs.
> + Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <limits.h>
> +#include <stdlib.h>
> +
> +#include <support/check.h>
> +
> +#define LARGE_PRIME 49999
> +
> +static int do_test (void)
> +{
> + long int i;
> +
> + TEST_COMPARE (ulabs (LONG_MAX), LONG_MAX);
> + TEST_COMPARE (ulabs (LONG_MIN), (unsigned long int)LONG_MAX + 1);
> + TEST_COMPARE (ulabs (-1), 1);
> + TEST_COMPARE (ulabs (0), 0);
> + TEST_COMPARE (ulabs (1), 1);
> +
> + for (i = LONG_MIN + 1; i < LONG_MIN + INT_MAX; i += LARGE_PRIME)
> + TEST_COMPARE (labs (i), -i);
> +
> + for (i = LONG_MAX - INT_MAX; i < LONG_MAX - LARGE_PRIME;
> + i += LARGE_PRIME)
> + TEST_COMPARE (labs (i), i);
> +
> + for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
> + TEST_COMPARE (labs (i), -i);
> +
> + for (i = 0; i <= INT_MAX - LARGE_PRIME; i += LARGE_PRIME)
> + TEST_COMPARE (labs (i), i);
> +
> + return EXIT_SUCCESS;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/stdlib/tst-ullabs.c b/stdlib/tst-ullabs.c
> new file mode 100644
> index 0000000000..e25b22c048
> --- /dev/null
> +++ b/stdlib/tst-ullabs.c
> @@ -0,0 +1,55 @@
> +/* Basic tests for ullabs.
> + Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <limits.h>
> +#include <stdlib.h>
> +
> +#include <support/check.h>
> +
> +#define LARGE_PRIME 49999
> +
> +static int do_test (void)
> +{
> + long long int i;
> +
> + TEST_COMPARE (ullabs (LONG_MAX), LONG_MAX);
> + TEST_COMPARE (ullabs (LONG_MIN), (unsigned long long int)LONG_MAX + 1);
Shouldn't be LLONG_MAX and LLONG_MIN here, as well on the test of test?
> + TEST_COMPARE (ullabs (0x00000000ffffffffL), 0x00000000ffffffffL);
> + TEST_COMPARE (ullabs (0x0000000100000000L), 0x0000000100000000L);
> + TEST_COMPARE (ullabs (0x80000000ffffffffL), 0x7fffffff00000001L);
> + TEST_COMPARE (ullabs (0x8000000100000000L), 0x7fffffff00000000L);
> + TEST_COMPARE (ullabs (-1), 1);
> + TEST_COMPARE (ullabs (0), 0);
> + TEST_COMPARE (ullabs (1), 1);
> +
> + for (i = LLONG_MIN + 1; i < LLONG_MIN + INT_MAX; i += LARGE_PRIME)
> + TEST_COMPARE (llabs (i), -i);
> +
> + for (i = LLONG_MAX - INT_MAX; i < LLONG_MAX - LARGE_PRIME; i += LARGE_PRIME)
> + TEST_COMPARE (llabs (i), i);
> +
> + for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
> + TEST_COMPARE (llabs (i), -i);
> +
> + for (i = 0; i < INT_MAX; i += LARGE_PRIME)
> + TEST_COMPARE (llabs (i), i);
> +
> + return EXIT_SUCCESS;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/stdlib/uabs.c b/stdlib/uabs.c
> new file mode 100644
> index 0000000000..3426a5e95b
> --- /dev/null
> +++ b/stdlib/uabs.c
> @@ -0,0 +1,27 @@
> +/* Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <stdlib.h>
> +
> +#undef uabs
> +
> +/* Return the absolute value of I. */
> +unsigned int
> +uabs (int i)
> +{
> + return i < 0 ? -(unsigned int)i : i;
> +}
> diff --git a/stdlib/ulabs.c b/stdlib/ulabs.c
> new file mode 100644
> index 0000000000..4b5ad69662
> --- /dev/null
> +++ b/stdlib/ulabs.c
> @@ -0,0 +1,27 @@
> +/* Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <stdlib.h>
> +
> +#undef ulabs
> +
> +/* Return the absolute value of I. */
> +unsigned long int
> +ulabs (long int i)
> +{
> + return i < 0 ? -(unsigned long int)i : i;
> +}
Add
#if ULONG_MAX != UINT_MAX
weak_alias (ulabs, uimaxabs)
#endif
and remove sysdeps/wordsize-64/ulabs.c.
> diff --git a/stdlib/ullabs.c b/stdlib/ullabs.c
> new file mode 100644
> index 0000000000..216cf7e6dd
> --- /dev/null
> +++ b/stdlib/ullabs.c
> @@ -0,0 +1,27 @@
> +/* Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <stdlib.h>
> +
> +#undef ullabs
> +
> +/* Return the absolute value of I. */
> +unsigned long long int
> +ullabs (long long int i)
> +{
> + return i < 0 ? -(unsigned long long int)i : i;
> +}
Add
#if ULONG_MAX == UINT_MAX
weak_alias (ullabs, uimaxabs)
#endif
and remove sysdeps/wordsize-32/ullabs.c.
> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
> index 461df01ffb..7f8e546f22 100644
> --- a/sysdeps/mach/hurd/i386/libc.abilist
> +++ b/sysdeps/mach/hurd/i386/libc.abilist
> @@ -2491,6 +2491,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
> GLIBC_2.39 stdc_trailing_zeros_ul F
> GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist
> index 6f235d20ba..f036aacd5a 100644
> --- a/sysdeps/mach/hurd/x86_64/libc.abilist
> +++ b/sysdeps/mach/hurd/x86_64/libc.abilist
> @@ -2295,6 +2295,9 @@ GLIBC_2.42 pthread_rwlockattr_destroy F
> GLIBC_2.42 pthread_rwlockattr_getpshared F
> GLIBC_2.42 pthread_rwlockattr_init F
> GLIBC_2.42 pthread_rwlockattr_setpshared F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> HURD_CTHREADS_0.3 __cthread_getspecific F
> HURD_CTHREADS_0.3 __cthread_keycreate F
> HURD_CTHREADS_0.3 __cthread_setspecific F
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 38db77e4f7..b9accaa139 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2750,3 +2750,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index 637bfce9fb..ceeb5e27a3 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2857,6 +2857,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
> GLIBC_2.39 stdc_trailing_zeros_ul F
> GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.4 _IO_fprintf F
> GLIBC_2.4 _IO_printf F
> GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
> index 4a305cf730..d04d9965bd 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -2511,3 +2511,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 1d54f71b14..97966e0ea5 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -2803,6 +2803,10 @@ GLIBC_2.4 xprt_register F
> GLIBC_2.4 xprt_unregister F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index ff7e8bc40b..76061c8eca 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -2800,6 +2800,10 @@ GLIBC_2.4 xprt_register F
> GLIBC_2.4 xprt_unregister F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index c3ed65467d..b2f2fe5d33 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2787,3 +2787,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index 991475380c..702852d0d4 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2824,6 +2824,10 @@ GLIBC_2.4 unshare F
> GLIBC_2.41 cacheflush F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index 4fedf775d4..b8309355e1 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2918,6 +2918,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
> GLIBC_2.39 stdc_trailing_zeros_ul F
> GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.4 __confstr_chk F
> GLIBC_2.4 __fgets_chk F
> GLIBC_2.4 __fgets_unlocked_chk F
The abi inclusion is still off:
$ make check-abi
[...]
--- ../sysdeps/unix/sysv/linux/i386/libc.abilist 2025-03-10 09:38:06.178016460 -0300
+++ /home/azanella/Projects/glibc/build/i686-linux-gnu-review/libc.symlist 2025-03-10 09:54:32.276664949 -0300
@@ -2921,4 +2920,0 @@ GLIBC_2.39 stdc_trailing_zeros_us F
-GLIBC_2.42 uabs F
-GLIBC_2.42 uimaxabs F
-GLIBC_2.42 ulabs F
-GLIBC_2.42 ullabs F
@@ -3013,0 +3010,4 @@ GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
0x071c: Rev: 1 Flags: none Index: 52 Cnt: 2 Name: GLIBC_ABI_DT_RELR
with 'make update-abi' it updates to:
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index b8309355e1..9697160689 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2918,10 +2918,6 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
GLIBC_2.39 stdc_trailing_zeros_ul F
GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
-GLIBC_2.42 uabs F
-GLIBC_2.42 uimaxabs F
-GLIBC_2.42 ulabs F
-GLIBC_2.42 ullabs F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -3011,6 +3007,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
so please also check if other ABIs have the same issue. You can use
scripts/build-many-glibcs.py to build cross toolchain for the ABIs
and check with a build.
> diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
> index 0024282289..285cd519c5 100644
> --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
> @@ -2271,3 +2271,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index 142595eb3e..5028b57204 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -2783,6 +2783,10 @@ GLIBC_2.4 xprt_register F
> GLIBC_2.4 xprt_unregister F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 85e7746c10..7b8a526709 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2950,6 +2950,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 91dc1b8378..3b7f122b91 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2836,3 +2836,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index 3440e90f6f..953b1f23b1 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2833,3 +2833,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index 5ee7b8c52f..ba24b56c17 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2911,6 +2911,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 6cb6328e7c..6564bf7653 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2909,6 +2909,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index ae7474c0f0..c58d84f5bc 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2917,6 +2917,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index cdf040dec2..d5eff0f93c 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2819,6 +2819,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
> index c356a11b1c..cc96ab1399 100644
> --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
> @@ -2261,3 +2261,7 @@ GLIBC_2.40 setcontext F
> GLIBC_2.40 swapcontext F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 7937f94cf0..20f866220d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -3140,6 +3140,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index d6e35f31d2..b0b06b356d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -3185,6 +3185,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index 2268d6890d..f671baa292 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2894,6 +2894,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index 7f61b14bc8..e7cb2fb76f 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2970,3 +2970,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> index 4187241f50..d93771ac97 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -2514,3 +2514,7 @@ GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.40 __riscv_hwprobe F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index 8935beccac..2447259edb 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2714,3 +2714,7 @@ GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.40 __riscv_hwprobe F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index e69dc7ccf6..79fa1c247c 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -3138,6 +3138,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index 7d860001d8..67789c8bf8 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2931,6 +2931,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index fcb8161841..71afc5943f 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2830,6 +2830,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index 3fd078d125..8597b710bd 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2827,6 +2827,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index 1ce1fe9da7..130ed66c9d 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -3159,6 +3159,10 @@ GLIBC_2.4 wprintf F
> GLIBC_2.4 wscanf F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index 07507b86f6..593a24b254 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2795,6 +2795,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index 5acf49dbe8..2be9d774da 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2746,6 +2746,10 @@ GLIBC_2.4 unlinkat F
> GLIBC_2.4 unshare F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> GLIBC_2.5 __readlinkat_chk F
> GLIBC_2.5 inet6_opt_append F
> GLIBC_2.5 inet6_opt_find F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index 02d1bb97dc..babd24b63c 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2765,3 +2765,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
> GLIBC_2.39 stdc_trailing_zeros_us F
> GLIBC_2.41 sched_getattr F
> GLIBC_2.41 sched_setattr F
> +GLIBC_2.42 uabs F
> +GLIBC_2.42 uimaxabs F
> +GLIBC_2.42 ulabs F
> +GLIBC_2.42 ullabs F
> diff --git a/sysdeps/wordsize-32/ullabs.c b/sysdeps/wordsize-32/ullabs.c
> new file mode 100644
> index 0000000000..aad0df7d1b
> --- /dev/null
> +++ b/sysdeps/wordsize-32/ullabs.c
> @@ -0,0 +1,22 @@
> +/* Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <inttypes.h>
> +
> +#include <stdlib/ullabs.c>
> +
> +weak_alias (ullabs, uimaxabs)
> diff --git a/sysdeps/wordsize-64/ulabs.c b/sysdeps/wordsize-64/ulabs.c
> new file mode 100644
> index 0000000000..c27c83c3f1
> --- /dev/null
> +++ b/sysdeps/wordsize-64/ulabs.c
> @@ -0,0 +1,22 @@
> +/* Copyright (C) 2025 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <inttypes.h>
> +
> +#include <stdlib/ulabs.c>
> +
> +weak_alias (ulabs, uimaxabs)
On Sun, 9 Mar 2025, Lenard Mollenkopf wrote:
> +* The ISO C2Y family of unsigned abs functions, i.e.
> + uabs, ulab, ullabs and uimaxabs, are now supported.
ulabs, not ulab.
> @pindex math.h
> @pindex stdlib.h
> -Prototypes for @code{abs}, @code{labs} and @code{llabs} are in @file{stdlib.h};
> -@code{imaxabs} is declared in @file{inttypes.h};
> +Prototypes for @code{abs}, @code{labs}, @code{llabs},
> +@code{uabs}, @code{ulabs} @code{ullabs} are in @file{stdlib.h};
Missing "and" between ulabs and ullabs.
@@ -16,6 +16,9 @@ Major new features:
- Power and absolute-value functions: rsqrt.
+* The ISO C2Y family of unsigned abs functions, i.e.
+ uabs, ulab, ullabs and uimaxabs, are now supported.
+
Deprecated and removed features, and other changes affecting compatibility:
[Add deprecations, removals and changes affecting compatibility here]
@@ -1233,25 +1233,33 @@ whose imaginary part is @var{y}, the absolute value is @w{@code{sqrt
@pindex math.h
@pindex stdlib.h
-Prototypes for @code{abs}, @code{labs} and @code{llabs} are in @file{stdlib.h};
-@code{imaxabs} is declared in @file{inttypes.h};
+Prototypes for @code{abs}, @code{labs}, @code{llabs},
+@code{uabs}, @code{ulabs} @code{ullabs} are in @file{stdlib.h};
+@code{imaxabs} and @code{uimaxabs} are declared in @file{inttypes.h};
the @code{fabs} functions are declared in @file{math.h};
the @code{cabs} functions are declared in @file{complex.h}.
@deftypefun int abs (int @var{number})
@deftypefunx {long int} labs (long int @var{number})
@deftypefunx {long long int} llabs (long long int @var{number})
+@deftypefunx unsigned int uabs (int @var{number})
+@deftypefunx {unsigned long int} ulabs (long int @var{number})
+@deftypefunx {unsigned long long int} ullabs (long long int @var{number})
@deftypefunx intmax_t imaxabs (intmax_t @var{number})
+@deftypefunx uintmax_t uimaxabs (intmax_t @var{number})
@standards{ISO, stdlib.h}
@standardsx{imaxabs, ISO, inttypes.h}
+@standardsx{uimaxabs, ISO, inttypes.h}
@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
These functions return the absolute value of @var{number}.
Most computers use a two's complement integer representation, in which
the absolute value of @code{INT_MIN} (the smallest possible @code{int})
cannot be represented; thus, @w{@code{abs (INT_MIN)}} is not defined.
+Using @code{uabs} avoids this.
@code{llabs} and @code{imaxdiv} are new to @w{ISO C99}.
+@code{uabs}, @code{ulabs}, @code{ullabs} and @code{uimaxabs} are new to @w{ISO C2Y}.
See @ref{Integers} for a description of the @code{intmax_t} type.
@@ -211,6 +211,9 @@ routines := \
strtoull_l \
swapcontext \
system \
+ uabs \
+ ulabs \
+ ullabs \
wcstombs \
wctomb \
xpg_basename \
@@ -361,6 +364,9 @@ tests := \
tst-swapcontext2 \
tst-thread-quick_exit \
tst-tininess \
+ tst-uabs \
+ tst-ulabs \
+ tst-ullabs \
tst-unsetenv1 \
tst-width \
tst-width-stdint \
@@ -410,6 +416,10 @@ CFLAGS-tst-abs.c += -fno-builtin
CFLAGS-tst-labs.c += -fno-builtin
CFLAGS-tst-llabs.c += -fno-builtin
+CFLAGS-tst-uabs.c += -fno-builtin
+CFLAGS-tst-ulabs.c += -fno-builtin
+CFLAGS-tst-ullabs.c += -fno-builtin
+
CFLAGS-tst-stdbit-Wconversion.c += -Wconversion -Werror
CFLAGS-tst-stdc_trailing_zeros.c += -fno-builtin
CFLAGS-tst-stdc_trailing_ones.c += -fno-builtin
@@ -223,6 +223,12 @@ libc {
stdc_bit_ceil_ul;
stdc_bit_ceil_ull;
}
+ GLIBC_2.42 {
+ uabs;
+ uimaxabs;
+ ulabs;
+ ullabs;
+ }
GLIBC_PRIVATE {
# functions which have an additional interface since they are
# are cancelable.
@@ -350,6 +350,11 @@ typedef struct
/* Compute absolute value of N. */
extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
+
+#if __GLIBC_USE (ISOC2Y)
+extern uintmax_t uimaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
+#endif
+
/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
__THROW __attribute__ ((__const__));
@@ -985,6 +985,12 @@ __extension__ extern long long int llabs (long long int __x)
__THROW __attribute__ ((__const__)) __wur;
#endif
+#if __GLIBC_USE (ISOC2Y)
+extern unsigned int uabs (int __x) __THROW __attribute__ ((__const__)) __wur;
+extern unsigned long int ulabs (long int __x) __THROW __attribute__ ((__const__)) __wur;
+__extension__ extern unsigned long long int ullabs (long long int __x)
+ __THROW __attribute__ ((__const__)) __wur;
+#endif
/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
of the value of NUMER over DENOM. */
new file mode 100644
@@ -0,0 +1,45 @@
+/* Basic tests for uabs.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include <support/check.h>
+
+#define LARGE_PRIME 49999
+
+static int do_test (void)
+{
+ int i;
+
+ TEST_COMPARE (uabs (INT_MAX), INT_MAX);
+ TEST_COMPARE (uabs (INT_MIN), (unsigned int)INT_MAX + 1);
+ TEST_COMPARE (uabs (-1), 1);
+ TEST_COMPARE (uabs (0), 0);
+ TEST_COMPARE (uabs (1), 1);
+
+ for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
+ TEST_COMPARE (uabs (i), -i);
+
+ for (i = 0; i < INT_MAX - LARGE_PRIME; i += LARGE_PRIME)
+ TEST_COMPARE (uabs (i), i);
+
+ return EXIT_SUCCESS;
+}
+
+#include <support/test-driver.c>
new file mode 100644
@@ -0,0 +1,52 @@
+/* Basic tests for ulabs.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include <support/check.h>
+
+#define LARGE_PRIME 49999
+
+static int do_test (void)
+{
+ long int i;
+
+ TEST_COMPARE (ulabs (LONG_MAX), LONG_MAX);
+ TEST_COMPARE (ulabs (LONG_MIN), (unsigned long int)LONG_MAX + 1);
+ TEST_COMPARE (ulabs (-1), 1);
+ TEST_COMPARE (ulabs (0), 0);
+ TEST_COMPARE (ulabs (1), 1);
+
+ for (i = LONG_MIN + 1; i < LONG_MIN + INT_MAX; i += LARGE_PRIME)
+ TEST_COMPARE (labs (i), -i);
+
+ for (i = LONG_MAX - INT_MAX; i < LONG_MAX - LARGE_PRIME;
+ i += LARGE_PRIME)
+ TEST_COMPARE (labs (i), i);
+
+ for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
+ TEST_COMPARE (labs (i), -i);
+
+ for (i = 0; i <= INT_MAX - LARGE_PRIME; i += LARGE_PRIME)
+ TEST_COMPARE (labs (i), i);
+
+ return EXIT_SUCCESS;
+}
+
+#include <support/test-driver.c>
new file mode 100644
@@ -0,0 +1,55 @@
+/* Basic tests for ullabs.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include <support/check.h>
+
+#define LARGE_PRIME 49999
+
+static int do_test (void)
+{
+ long long int i;
+
+ TEST_COMPARE (ullabs (LONG_MAX), LONG_MAX);
+ TEST_COMPARE (ullabs (LONG_MIN), (unsigned long long int)LONG_MAX + 1);
+ TEST_COMPARE (ullabs (0x00000000ffffffffL), 0x00000000ffffffffL);
+ TEST_COMPARE (ullabs (0x0000000100000000L), 0x0000000100000000L);
+ TEST_COMPARE (ullabs (0x80000000ffffffffL), 0x7fffffff00000001L);
+ TEST_COMPARE (ullabs (0x8000000100000000L), 0x7fffffff00000000L);
+ TEST_COMPARE (ullabs (-1), 1);
+ TEST_COMPARE (ullabs (0), 0);
+ TEST_COMPARE (ullabs (1), 1);
+
+ for (i = LLONG_MIN + 1; i < LLONG_MIN + INT_MAX; i += LARGE_PRIME)
+ TEST_COMPARE (llabs (i), -i);
+
+ for (i = LLONG_MAX - INT_MAX; i < LLONG_MAX - LARGE_PRIME; i += LARGE_PRIME)
+ TEST_COMPARE (llabs (i), i);
+
+ for (i = INT_MIN + 1; i < 0; i += LARGE_PRIME)
+ TEST_COMPARE (llabs (i), -i);
+
+ for (i = 0; i < INT_MAX; i += LARGE_PRIME)
+ TEST_COMPARE (llabs (i), i);
+
+ return EXIT_SUCCESS;
+}
+
+#include <support/test-driver.c>
new file mode 100644
@@ -0,0 +1,27 @@
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+#undef uabs
+
+/* Return the absolute value of I. */
+unsigned int
+uabs (int i)
+{
+ return i < 0 ? -(unsigned int)i : i;
+}
new file mode 100644
@@ -0,0 +1,27 @@
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+#undef ulabs
+
+/* Return the absolute value of I. */
+unsigned long int
+ulabs (long int i)
+{
+ return i < 0 ? -(unsigned long int)i : i;
+}
new file mode 100644
@@ -0,0 +1,27 @@
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+#undef ullabs
+
+/* Return the absolute value of I. */
+unsigned long long int
+ullabs (long long int i)
+{
+ return i < 0 ? -(unsigned long long int)i : i;
+}
@@ -2491,6 +2491,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
GLIBC_2.39 stdc_trailing_zeros_ul F
GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2295,6 +2295,9 @@ GLIBC_2.42 pthread_rwlockattr_destroy F
GLIBC_2.42 pthread_rwlockattr_getpshared F
GLIBC_2.42 pthread_rwlockattr_init F
GLIBC_2.42 pthread_rwlockattr_setpshared F
+GLIBC_2.42 uabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
HURD_CTHREADS_0.3 __cthread_getspecific F
HURD_CTHREADS_0.3 __cthread_keycreate F
HURD_CTHREADS_0.3 __cthread_setspecific F
@@ -2750,3 +2750,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2857,6 +2857,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
GLIBC_2.39 stdc_trailing_zeros_ul F
GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2511,3 +2511,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2803,6 +2803,10 @@ GLIBC_2.4 xprt_register F
GLIBC_2.4 xprt_unregister F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2800,6 +2800,10 @@ GLIBC_2.4 xprt_register F
GLIBC_2.4 xprt_unregister F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2787,3 +2787,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2824,6 +2824,10 @@ GLIBC_2.4 unshare F
GLIBC_2.41 cacheflush F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2918,6 +2918,10 @@ GLIBC_2.39 stdc_trailing_zeros_ui F
GLIBC_2.39 stdc_trailing_zeros_ul F
GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2271,3 +2271,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2783,6 +2783,10 @@ GLIBC_2.4 xprt_register F
GLIBC_2.4 xprt_unregister F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2950,6 +2950,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2836,3 +2836,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2833,3 +2833,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2911,6 +2911,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2909,6 +2909,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2917,6 +2917,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2819,6 +2819,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2261,3 +2261,7 @@ GLIBC_2.40 setcontext F
GLIBC_2.40 swapcontext F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -3140,6 +3140,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -3185,6 +3185,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2894,6 +2894,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2970,3 +2970,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2514,3 +2514,7 @@ GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.40 __riscv_hwprobe F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -2714,3 +2714,7 @@ GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.40 __riscv_hwprobe F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
@@ -3138,6 +3138,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2931,6 +2931,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2830,6 +2830,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2827,6 +2827,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -3159,6 +3159,10 @@ GLIBC_2.4 wprintf F
GLIBC_2.4 wscanf F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2795,6 +2795,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2746,6 +2746,10 @@ GLIBC_2.4 unlinkat F
GLIBC_2.4 unshare F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
@@ -2765,3 +2765,7 @@ GLIBC_2.39 stdc_trailing_zeros_ull F
GLIBC_2.39 stdc_trailing_zeros_us F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
+GLIBC_2.42 uabs F
+GLIBC_2.42 uimaxabs F
+GLIBC_2.42 ulabs F
+GLIBC_2.42 ullabs F
new file mode 100644
@@ -0,0 +1,22 @@
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+
+#include <stdlib/ullabs.c>
+
+weak_alias (ullabs, uimaxabs)
new file mode 100644
@@ -0,0 +1,22 @@
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <inttypes.h>
+
+#include <stdlib/ulabs.c>
+
+weak_alias (ulabs, uimaxabs)