Re: [PATCH] stdlib: merge some tests from gnulib

Adhemerval Zanella Netto <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Organization Linaro
Message-ID <[email protected]>

On 28/08/26 00:35, Collin Funk wrote:
> This makes the tests the same in both places. The changes in Gnulib
> brought in by this patch also silence -Woverflow when using gcc 16.1.1
> on i686.


LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <[email protected]>

> ---
>  SHARED-FILES                   |  1 +
>  stdlib/tst-stdc_rotate_left.c  | 40 ++++++++++++++++++++++++++--------
>  stdlib/tst-stdc_rotate_right.c | 40 ++++++++++++++++++++++++++--------
>  3 files changed, 63 insertions(+), 18 deletions(-)
> 
> diff --git a/SHARED-FILES b/SHARED-FILES
> index b630b41209..f17a76dbf7 100644
> --- a/SHARED-FILES
> +++ b/SHARED-FILES
> @@ -113,6 +113,7 @@ gnulib:
>    stdlib/setenv.c
>    stdlib/strtoll.c
>    stdlib/strtoul.c
> +  # Merged from gnulib 2026-08-27, (gnulib commit ec224ee81b)
>    stdlib/tst-stdc_rotate_left.c
>    stdlib/tst-stdc_rotate_right.c
>    # Merged from gnulib 2014-6-26, needs merge back
> diff --git a/stdlib/tst-stdc_rotate_left.c b/stdlib/tst-stdc_rotate_left.c
> index e4b8052969..ec89f4ae52 100644
> --- a/stdlib/tst-stdc_rotate_left.c
> +++ b/stdlib/tst-stdc_rotate_left.c
> @@ -15,8 +15,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> +#ifdef GNULIB_TEST_STDBIT
> +# include <config.h>
> +#endif
> +
> +/* Specification.  */
>  #include <stdbit.h>
> -#include <support/check.h>
> +
> +#include <limits.h>
> +
> +#ifdef GNULIB_TEST_STDBIT
> +# include "macros.h"
> +# define MAIN_STATIC
> +# define MAIN main
> +# define TEST_COMPARE(a, b) ASSERT ((a) == (b))
> +# define TEST_EXIT_STATUS test_exit_status
> +#else
> +# include <support/check.h>
> +# define MAIN_STATIC static
> +# define MAIN do_test
> +# define TEST_EXIT_STATUS 0
> +#endif
>  
>  #define TEST_CASE(type, function, value, shift, expect)         \
>    do                                                            \
> @@ -431,10 +450,11 @@ test_stdc_rotate_left_ui (void)
>  static void
>  test_stdc_rotate_left_ul (void)
>  {
> -  if (sizeof 0ul < sizeof 0ull)
> -    TEST_CASES_32 (unsigned long int, stdc_rotate_left_ul);
> -  else
> -    TEST_CASES_64 (unsigned long long int, stdc_rotate_left_ul);
> +#if ULONG_MAX >> 31 == 1
> +  TEST_CASES_32 (unsigned long int, stdc_rotate_left_ul);
> +#else
> +  TEST_CASES_64 (unsigned long int, stdc_rotate_left_ul);
> +#endif
>  }
>  
>  static void
> @@ -443,15 +463,17 @@ test_stdc_rotate_left_ull (void)
>    TEST_CASES_64 (unsigned long long int, stdc_rotate_left_ull);
>  }
>  
> -static int
> -do_test (void)
> +MAIN_STATIC int
> +MAIN (void)
>  {
>    test_stdc_rotate_left_uc ();
>    test_stdc_rotate_left_us ();
>    test_stdc_rotate_left_ui ();
>    test_stdc_rotate_left_ul ();
>    test_stdc_rotate_left_ull ();
> -  return 0;
> +  return TEST_EXIT_STATUS;
>  }
>  
> -#include <support/test-driver.c>
> +#ifndef GNULIB_TEST_STDBIT
> +# include <support/test-driver.c>
> +#endif
> diff --git a/stdlib/tst-stdc_rotate_right.c b/stdlib/tst-stdc_rotate_right.c
> index d9543b8b55..01b28cd957 100644
> --- a/stdlib/tst-stdc_rotate_right.c
> +++ b/stdlib/tst-stdc_rotate_right.c
> @@ -15,8 +15,27 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> +#ifdef GNULIB_TEST_STDBIT
> +# include <config.h>
> +#endif
> +
> +/* Specification.  */
>  #include <stdbit.h>
> -#include <support/check.h>
> +
> +#include <limits.h>
> +
> +#ifdef GNULIB_TEST_STDBIT
> +# include "macros.h"
> +# define MAIN_STATIC
> +# define MAIN main
> +# define TEST_COMPARE(a, b) ASSERT ((a) == (b))
> +# define TEST_EXIT_STATUS test_exit_status
> +#else
> +# include <support/check.h>
> +# define MAIN_STATIC static
> +# define MAIN do_test
> +# define TEST_EXIT_STATUS 0
> +#endif
>  
>  #define TEST_CASE(type, function, value, shift, expect)         \
>    do                                                            \
> @@ -431,10 +450,11 @@ test_stdc_rotate_right_ui (void)
>  static void
>  test_stdc_rotate_right_ul (void)
>  {
> -  if (sizeof 0ul < sizeof 0ull)
> -    TEST_CASES_32 (unsigned long int, stdc_rotate_right_ul);
> -  else
> -    TEST_CASES_64 (unsigned long long int, stdc_rotate_right_ul);
> +#if ULONG_MAX >> 31 == 1
> +  TEST_CASES_32 (unsigned long int, stdc_rotate_right_ul);
> +#else
> +  TEST_CASES_64 (unsigned long int, stdc_rotate_right_ul);
> +#endif
>  }
>  
>  static void
> @@ -443,15 +463,17 @@ test_stdc_rotate_right_ull (void)
>    TEST_CASES_64 (unsigned long long int, stdc_rotate_right_ull);
>  }
>  
> -static int
> -do_test (void)
> +MAIN_STATIC int
> +MAIN (void)
>  {
>    test_stdc_rotate_right_uc ();
>    test_stdc_rotate_right_us ();
>    test_stdc_rotate_right_ui ();
>    test_stdc_rotate_right_ul ();
>    test_stdc_rotate_right_ull ();
> -  return 0;
> +  return TEST_EXIT_STATUS;
>  }
>  
> -#include <support/test-driver.c>
> +#ifndef GNULIB_TEST_STDBIT
> +# include <support/test-driver.c>
> +#endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.