public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize'
@ 2022-02-07 20:16 Noah Goldstein
  2022-02-07 21:10 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-02-07 20:16 UTC (permalink / raw)
  To: libc-alpha

When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
not be a factor of system page size if it was > 4096.
---
 string/test-strcmp.c  | 14 +++++++-------
 string/test-strncmp.c | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index eacbdc8857..0abce769d0 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -393,7 +393,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
   check();
   check2 ();
@@ -435,7 +435,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test (getpagesize () - j - 1, 0, i, 127, 0);
           do_test (getpagesize () - j - 1, 0, i, 127, 1);
@@ -461,17 +461,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index 1a3cee1792..1966bde3fe 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -430,7 +430,7 @@ check_overflow (void)
   const size_t of_masks[]
       = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
           ((size_t)LONG_MAX) >> 1 };
-
+  const size_t test_len = MIN(test_len, 3 * 4096);
   for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
     {
       of_mask = of_masks[of_idx];
@@ -484,7 +484,7 @@ check_overflow (void)
                          of_mask - j * 2, 0, 127, -1);
             }
 
-          for (i = 1; i < TEST_LEN; i += i)
+          for (i = 1; i < test_len; i += i)
             {
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
@@ -540,7 +540,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(test_len, 3 * 4096);
   test_init ();
 
   check1 ();
@@ -608,7 +608,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
@@ -677,17 +677,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize'
  2022-02-07 20:16 [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize' Noah Goldstein
@ 2022-02-07 21:10 ` Andreas Schwab
  2022-02-07 21:42   ` Noah Goldstein
  2022-02-07 21:41 ` [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple " Noah Goldstein
  2022-02-08 21:24 ` [PATCH v3] " Noah Goldstein
  2 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2022-02-07 21:10 UTC (permalink / raw)
  To: Noah Goldstein via Libc-alpha

On Feb 07 2022, Noah Goldstein via Libc-alpha wrote:

> When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> not be a factor of system page size if it was > 4096.

s/factor/multiple/

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-07 20:16 [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize' Noah Goldstein
  2022-02-07 21:10 ` Andreas Schwab
@ 2022-02-07 21:41 ` Noah Goldstein
  2022-02-08 13:14   ` Matheus Castanho
  2022-02-08 21:24 ` [PATCH v3] " Noah Goldstein
  2 siblings, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-02-07 21:41 UTC (permalink / raw)
  To: libc-alpha

When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
not be a multiple of system page size if system page size > 4096.
---
 string/test-strcmp.c  | 14 +++++++-------
 string/test-strncmp.c | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index eacbdc8857..0abce769d0 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -393,7 +393,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
   check();
   check2 ();
@@ -435,7 +435,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test (getpagesize () - j - 1, 0, i, 127, 0);
           do_test (getpagesize () - j - 1, 0, i, 127, 1);
@@ -461,17 +461,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index 1a3cee1792..1966bde3fe 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -430,7 +430,7 @@ check_overflow (void)
   const size_t of_masks[]
       = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
           ((size_t)LONG_MAX) >> 1 };
-
+  const size_t test_len = MIN(test_len, 3 * 4096);
   for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
     {
       of_mask = of_masks[of_idx];
@@ -484,7 +484,7 @@ check_overflow (void)
                          of_mask - j * 2, 0, 127, -1);
             }
 
-          for (i = 1; i < TEST_LEN; i += i)
+          for (i = 1; i < test_len; i += i)
             {
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
@@ -540,7 +540,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(test_len, 3 * 4096);
   test_init ();
 
   check1 ();
@@ -608,7 +608,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
@@ -677,17 +677,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize'
  2022-02-07 21:10 ` Andreas Schwab
@ 2022-02-07 21:42   ` Noah Goldstein
  0 siblings, 0 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-02-07 21:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Noah Goldstein via Libc-alpha

On Mon, Feb 7, 2022 at 3:10 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Feb 07 2022, Noah Goldstein via Libc-alpha wrote:
>
> > When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> > not be a factor of system page size if it was > 4096.
>
> s/factor/multiple/

Fixed :)
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-07 21:41 ` [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple " Noah Goldstein
@ 2022-02-08 13:14   ` Matheus Castanho
  2022-02-08 21:25     ` Noah Goldstein
  0 siblings, 1 reply; 11+ messages in thread
From: Matheus Castanho @ 2022-02-08 13:14 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: libc-alpha


string/test-strcmp and wcsmbs/test-wcscmp are passing with this new
patch, but string/test-strncmp and wcsmbs/test-wcsncmp are failing to
compile. With the fix below all tests pass.

Tested on powerpc, powerpc64 and powerpc64le.

Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> writes:

> When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> not be a multiple of system page size if system page size > 4096.
> ---
>  string/test-strcmp.c  | 14 +++++++-------
>  string/test-strncmp.c | 18 +++++++++---------
>  2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> index eacbdc8857..0abce769d0 100644
> --- a/string/test-strcmp.c
> +++ b/string/test-strcmp.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> -#define TEST_LEN (4096 * 3)
> +#define TEST_LEN (getpagesize () * 3)
>  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
>
>  #define TEST_MAIN
> @@ -393,7 +393,7 @@ int
>  test_main (void)
>  {
>    size_t i, j;
> -
> +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>    test_init ();
>    check();
>    check2 ();
> @@ -435,7 +435,7 @@ test_main (void)
>
>    for (j = 0; j < 160; ++j)
>      {
> -      for (i = 0; i < TEST_LEN;)
> +      for (i = 0; i < test_len;)
>          {
>            do_test (getpagesize () - j - 1, 0, i, 127, 0);
>            do_test (getpagesize () - j - 1, 0, i, 127, 1);
> @@ -461,17 +461,17 @@ test_main (void)
>              {
>                i += 7;
>              }
> -          else if (i + 161 < TEST_LEN)
> +          else if (i + 161 < test_len)
>              {
>                i += 31;
>                i *= 17;
>                i /= 16;
> -              if (i + 161 > TEST_LEN)
> +              if (i + 161 > test_len)
>                  {
> -                  i = TEST_LEN - 160;
> +                  i = test_len - 160;
>                  }
>              }
> -          else if (i + 32 < TEST_LEN)
> +          else if (i + 32 < test_len)
>              {
>                i += 7;
>              }
> diff --git a/string/test-strncmp.c b/string/test-strncmp.c
> index 1a3cee1792..1966bde3fe 100644
> --- a/string/test-strncmp.c
> +++ b/string/test-strncmp.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> -#define TEST_LEN (4096 * 3)
> +#define TEST_LEN (getpagesize () * 3)
>  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
>
>  #define TEST_MAIN
> @@ -430,7 +430,7 @@ check_overflow (void)
>    const size_t of_masks[]
>        = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
>            ((size_t)LONG_MAX) >> 1 };
> -
> +  const size_t test_len = MIN(test_len, 3 * 4096);

Should be MIN(TEST_LEN, 3 * 4096)

>    for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
>      {
>        of_mask = of_masks[of_idx];
> @@ -484,7 +484,7 @@ check_overflow (void)
>                           of_mask - j * 2, 0, 127, -1);
>              }
>
> -          for (i = 1; i < TEST_LEN; i += i)
> +          for (i = 1; i < test_len; i += i)
>              {
>                do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
>                do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
> @@ -540,7 +540,7 @@ int
>  test_main (void)
>  {
>    size_t i, j;
> -
> +  const size_t test_len = MIN(test_len, 3 * 4096);

Should be MIN(TEST_LEN, 3 * 4096)

>    test_init ();
>
>    check1 ();
> @@ -608,7 +608,7 @@ test_main (void)
>
>    for (j = 0; j < 160; ++j)
>      {
> -      for (i = 0; i < TEST_LEN;)
> +      for (i = 0; i < test_len;)
>          {
>            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
>            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
> @@ -677,17 +677,17 @@ test_main (void)
>              {
>                i += 7;
>              }
> -          else if (i + 161 < TEST_LEN)
> +          else if (i + 161 < test_len)
>              {
>                i += 31;
>                i *= 17;
>                i /= 16;
> -              if (i + 161 > TEST_LEN)
> +              if (i + 161 > test_len)
>                  {
> -                  i = TEST_LEN - 160;
> +                  i = test_len - 160;
>                  }
>              }
> -          else if (i + 32 < TEST_LEN)
> +          else if (i + 32 < test_len)
>              {
>                i += 7;
>              }


--
Matheus Castanho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-07 20:16 [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize' Noah Goldstein
  2022-02-07 21:10 ` Andreas Schwab
  2022-02-07 21:41 ` [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple " Noah Goldstein
@ 2022-02-08 21:24 ` Noah Goldstein
  2022-02-09 13:57   ` Tulio Magno Quites Machado Filho
  2022-02-10 14:01   ` Matheus Castanho
  2 siblings, 2 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-02-08 21:24 UTC (permalink / raw)
  To: libc-alpha

When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
not be a multiple of system page size if system page size > 4096.
---
 string/test-strcmp.c  | 14 +++++++-------
 string/test-strncmp.c | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index eacbdc8857..0abce769d0 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -393,7 +393,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
   check();
   check2 ();
@@ -435,7 +435,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test (getpagesize () - j - 1, 0, i, 127, 0);
           do_test (getpagesize () - j - 1, 0, i, 127, 1);
@@ -461,17 +461,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index 1a3cee1792..831cb77893 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -430,7 +430,7 @@ check_overflow (void)
   const size_t of_masks[]
       = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
           ((size_t)LONG_MAX) >> 1 };
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
     {
       of_mask = of_masks[of_idx];
@@ -484,7 +484,7 @@ check_overflow (void)
                          of_mask - j * 2, 0, 127, -1);
             }
 
-          for (i = 1; i < TEST_LEN; i += i)
+          for (i = 1; i < test_len; i += i)
             {
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
               do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
@@ -540,7 +540,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
 
   check1 ();
@@ -608,7 +608,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
           do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
@@ -677,17 +677,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-08 13:14   ` Matheus Castanho
@ 2022-02-08 21:25     ` Noah Goldstein
  0 siblings, 0 replies; 11+ messages in thread
From: Noah Goldstein @ 2022-02-08 21:25 UTC (permalink / raw)
  To: Matheus Castanho; +Cc: GNU C Library

On Tue, Feb 8, 2022 at 7:59 AM Matheus Castanho <msc@linux.ibm.com> wrote:
>
>
> string/test-strcmp and wcsmbs/test-wcscmp are passing with this new
> patch, but string/test-strncmp and wcsmbs/test-wcsncmp are failing to
> compile. With the fix below all tests pass.
>
> Tested on powerpc, powerpc64 and powerpc64le.
>
> Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> writes:
>
> > When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> > not be a multiple of system page size if system page size > 4096.
> > ---
> >  string/test-strcmp.c  | 14 +++++++-------
> >  string/test-strncmp.c | 18 +++++++++---------
> >  2 files changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> > index eacbdc8857..0abce769d0 100644
> > --- a/string/test-strcmp.c
> > +++ b/string/test-strcmp.c
> > @@ -16,7 +16,7 @@
> >     License along with the GNU C Library; if not, see
> >     <https://www.gnu.org/licenses/>.  */
> >
> > -#define TEST_LEN (4096 * 3)
> > +#define TEST_LEN (getpagesize () * 3)
> >  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
> >
> >  #define TEST_MAIN
> > @@ -393,7 +393,7 @@ int
> >  test_main (void)
> >  {
> >    size_t i, j;
> > -
> > +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
> >    test_init ();
> >    check();
> >    check2 ();
> > @@ -435,7 +435,7 @@ test_main (void)
> >
> >    for (j = 0; j < 160; ++j)
> >      {
> > -      for (i = 0; i < TEST_LEN;)
> > +      for (i = 0; i < test_len;)
> >          {
> >            do_test (getpagesize () - j - 1, 0, i, 127, 0);
> >            do_test (getpagesize () - j - 1, 0, i, 127, 1);
> > @@ -461,17 +461,17 @@ test_main (void)
> >              {
> >                i += 7;
> >              }
> > -          else if (i + 161 < TEST_LEN)
> > +          else if (i + 161 < test_len)
> >              {
> >                i += 31;
> >                i *= 17;
> >                i /= 16;
> > -              if (i + 161 > TEST_LEN)
> > +              if (i + 161 > test_len)
> >                  {
> > -                  i = TEST_LEN - 160;
> > +                  i = test_len - 160;
> >                  }
> >              }
> > -          else if (i + 32 < TEST_LEN)
> > +          else if (i + 32 < test_len)
> >              {
> >                i += 7;
> >              }
> > diff --git a/string/test-strncmp.c b/string/test-strncmp.c
> > index 1a3cee1792..1966bde3fe 100644
> > --- a/string/test-strncmp.c
> > +++ b/string/test-strncmp.c
> > @@ -16,7 +16,7 @@
> >     License along with the GNU C Library; if not, see
> >     <https://www.gnu.org/licenses/>.  */
> >
> > -#define TEST_LEN (4096 * 3)
> > +#define TEST_LEN (getpagesize () * 3)
> >  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
> >
> >  #define TEST_MAIN
> > @@ -430,7 +430,7 @@ check_overflow (void)
> >    const size_t of_masks[]
> >        = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
> >            ((size_t)LONG_MAX) >> 1 };
> > -
> > +  const size_t test_len = MIN(test_len, 3 * 4096);
>
> Should be MIN(TEST_LEN, 3 * 4096)
>
> >    for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
> >      {
> >        of_mask = of_masks[of_idx];
> > @@ -484,7 +484,7 @@ check_overflow (void)
> >                           of_mask - j * 2, 0, 127, -1);
> >              }
> >
> > -          for (i = 1; i < TEST_LEN; i += i)
> > +          for (i = 1; i < test_len; i += i)
> >              {
> >                do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
> >                do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
> > @@ -540,7 +540,7 @@ int
> >  test_main (void)
> >  {
> >    size_t i, j;
> > -
> > +  const size_t test_len = MIN(test_len, 3 * 4096);
>
> Should be MIN(TEST_LEN, 3 * 4096)

Fixed in V3. Sorry about that.
>
> >    test_init ();
> >
> >    check1 ();
> > @@ -608,7 +608,7 @@ test_main (void)
> >
> >    for (j = 0; j < 160; ++j)
> >      {
> > -      for (i = 0; i < TEST_LEN;)
> > +      for (i = 0; i < test_len;)
> >          {
> >            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
> >            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
> > @@ -677,17 +677,17 @@ test_main (void)
> >              {
> >                i += 7;
> >              }
> > -          else if (i + 161 < TEST_LEN)
> > +          else if (i + 161 < test_len)
> >              {
> >                i += 31;
> >                i *= 17;
> >                i /= 16;
> > -              if (i + 161 > TEST_LEN)
> > +              if (i + 161 > test_len)
> >                  {
> > -                  i = TEST_LEN - 160;
> > +                  i = test_len - 160;
> >                  }
> >              }
> > -          else if (i + 32 < TEST_LEN)
> > +          else if (i + 32 < test_len)
> >              {
> >                i += 7;
> >              }
>
>
> --
> Matheus Castanho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-08 21:24 ` [PATCH v3] " Noah Goldstein
@ 2022-02-09 13:57   ` Tulio Magno Quites Machado Filho
  2022-02-09 20:48     ` Noah Goldstein
  2022-02-10 14:01   ` Matheus Castanho
  1 sibling, 1 reply; 11+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2022-02-09 13:57 UTC (permalink / raw)
  To: Noah Goldstein, libc-alpha

Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> writes:

> When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> not be a multiple of system page size if system page size > 4096.
> ---
>  string/test-strcmp.c  | 14 +++++++-------
>  string/test-strncmp.c | 18 +++++++++---------
>  2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> index eacbdc8857..0abce769d0 100644
> --- a/string/test-strcmp.c
> +++ b/string/test-strcmp.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#define TEST_LEN (4096 * 3)
> +#define TEST_LEN (getpagesize () * 3)
>  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
>  
>  #define TEST_MAIN
> @@ -393,7 +393,7 @@ int
>  test_main (void)
>  {
>    size_t i, j;
> -
> +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);

I didn't understand this part.
Is the intention here to protect against platforms with a page size less than
4096?

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-09 13:57   ` Tulio Magno Quites Machado Filho
@ 2022-02-09 20:48     ` Noah Goldstein
  2022-02-10 14:05       ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 11+ messages in thread
From: Noah Goldstein @ 2022-02-09 20:48 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho; +Cc: GNU C Library

On Wed, Feb 9, 2022 at 7:57 AM Tulio Magno Quites Machado Filho
<tuliom@ascii.art.br> wrote:
>
> Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> writes:
>
> > When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> > not be a multiple of system page size if system page size > 4096.
> > ---
> >  string/test-strcmp.c  | 14 +++++++-------
> >  string/test-strncmp.c | 18 +++++++++---------
> >  2 files changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> > index eacbdc8857..0abce769d0 100644
> > --- a/string/test-strcmp.c
> > +++ b/string/test-strcmp.c
> > @@ -16,7 +16,7 @@
> >     License along with the GNU C Library; if not, see
> >     <https://www.gnu.org/licenses/>.  */
> >
> > -#define TEST_LEN (4096 * 3)
> > +#define TEST_LEN (getpagesize () * 3)
> >  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
> >
> >  #define TEST_MAIN
> > @@ -393,7 +393,7 @@ int
> >  test_main (void)
> >  {
> >    size_t i, j;
> > -
> > +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>
> I didn't understand this part.
> Is the intention here to protect against platforms with a page size less than
> 4096?

Both to protect against platforms with smaller page size and keep
test duration manageable for systems with larger page size.


>
> --
> Tulio Magno

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-08 21:24 ` [PATCH v3] " Noah Goldstein
  2022-02-09 13:57   ` Tulio Magno Quites Machado Filho
@ 2022-02-10 14:01   ` Matheus Castanho
  1 sibling, 0 replies; 11+ messages in thread
From: Matheus Castanho @ 2022-02-10 14:01 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: libc-alpha


Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org> writes:

> When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
> not be a multiple of system page size if system page size > 4096.
> ---
>  string/test-strcmp.c  | 14 +++++++-------
>  string/test-strncmp.c | 18 +++++++++---------
>  2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/string/test-strcmp.c b/string/test-strcmp.c
> index eacbdc8857..0abce769d0 100644
> --- a/string/test-strcmp.c
> +++ b/string/test-strcmp.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> -#define TEST_LEN (4096 * 3)
> +#define TEST_LEN (getpagesize () * 3)
>  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
>
>  #define TEST_MAIN
> @@ -393,7 +393,7 @@ int
>  test_main (void)
>  {
>    size_t i, j;
> -
> +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>    test_init ();
>    check();
>    check2 ();
> @@ -435,7 +435,7 @@ test_main (void)
>
>    for (j = 0; j < 160; ++j)
>      {
> -      for (i = 0; i < TEST_LEN;)
> +      for (i = 0; i < test_len;)
>          {
>            do_test (getpagesize () - j - 1, 0, i, 127, 0);
>            do_test (getpagesize () - j - 1, 0, i, 127, 1);
> @@ -461,17 +461,17 @@ test_main (void)
>              {
>                i += 7;
>              }
> -          else if (i + 161 < TEST_LEN)
> +          else if (i + 161 < test_len)
>              {
>                i += 31;
>                i *= 17;
>                i /= 16;
> -              if (i + 161 > TEST_LEN)
> +              if (i + 161 > test_len)
>                  {
> -                  i = TEST_LEN - 160;
> +                  i = test_len - 160;
>                  }
>              }
> -          else if (i + 32 < TEST_LEN)
> +          else if (i + 32 < test_len)
>              {
>                i += 7;
>              }
> diff --git a/string/test-strncmp.c b/string/test-strncmp.c
> index 1a3cee1792..831cb77893 100644
> --- a/string/test-strncmp.c
> +++ b/string/test-strncmp.c
> @@ -16,7 +16,7 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>
> -#define TEST_LEN (4096 * 3)
> +#define TEST_LEN (getpagesize () * 3)
>  #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
>
>  #define TEST_MAIN
> @@ -430,7 +430,7 @@ check_overflow (void)
>    const size_t of_masks[]
>        = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2),
>            ((size_t)LONG_MAX) >> 1 };
> -
> +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>    for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx)
>      {
>        of_mask = of_masks[of_idx];
> @@ -484,7 +484,7 @@ check_overflow (void)
>                           of_mask - j * 2, 0, 127, -1);
>              }
>
> -          for (i = 1; i < TEST_LEN; i += i)
> +          for (i = 1; i < test_len; i += i)
>              {
>                do_test_n (j, 0, i - 1, of_mask, 0, 127, 0);
>                do_test_n (j, 0, i - 1, of_mask, 0, 127, 1);
> @@ -540,7 +540,7 @@ int
>  test_main (void)
>  {
>    size_t i, j;
> -
> +  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
>    test_init ();
>
>    check1 ();
> @@ -608,7 +608,7 @@ test_main (void)
>
>    for (j = 0; j < 160; ++j)
>      {
> -      for (i = 0; i < TEST_LEN;)
> +      for (i = 0; i < test_len;)
>          {
>            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0);
>            do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1);
> @@ -677,17 +677,17 @@ test_main (void)
>              {
>                i += 7;
>              }
> -          else if (i + 161 < TEST_LEN)
> +          else if (i + 161 < test_len)
>              {
>                i += 31;
>                i *= 17;
>                i /= 16;
> -              if (i + 161 > TEST_LEN)
> +              if (i + 161 > test_len)
>                  {
> -                  i = TEST_LEN - 160;
> +                  i = test_len - 160;
>                  }
>              }
> -          else if (i + 32 < TEST_LEN)
> +          else if (i + 32 < test_len)
>              {
>                i += 7;
>              }

This version builds fine and passes all tests.
Tested on powerpc, powerpc64, and powerpc64le.

Thanks,
Matheus Castanho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
  2022-02-09 20:48     ` Noah Goldstein
@ 2022-02-10 14:05       ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 11+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2022-02-10 14:05 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library

Noah Goldstein <goldstein.w.n@gmail.com> writes:

> Both to protect against platforms with smaller page size and keep
> test duration manageable for systems with larger page size.

I see.

Thanks!

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-02-10 14:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 20:16 [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize' Noah Goldstein
2022-02-07 21:10 ` Andreas Schwab
2022-02-07 21:42   ` Noah Goldstein
2022-02-07 21:41 ` [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple " Noah Goldstein
2022-02-08 13:14   ` Matheus Castanho
2022-02-08 21:25     ` Noah Goldstein
2022-02-08 21:24 ` [PATCH v3] " Noah Goldstein
2022-02-09 13:57   ` Tulio Magno Quites Machado Filho
2022-02-09 20:48     ` Noah Goldstein
2022-02-10 14:05       ` Tulio Magno Quites Machado Filho
2022-02-10 14:01   ` Matheus Castanho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).