[PATCH v3] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'

Noah Goldstein goldstein.w.n@gmail.com
Wed Feb 9 20:48:19 GMT 2022


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


More information about the Libc-alpha mailing list