(root)/
glibc-2.38/
string/
test-memcpy-large.c
       1  /* Test and measure memcpy functions.
       2     Copyright (C) 1999-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library; if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  /* test-memcpy-support.h contains all test functions.  */
      20  #include "test-memcpy-support.h"
      21  
      22  static void
      23  do_random_large_tests (void)
      24  {
      25    size_t i, align1, align2, size;
      26    for (i = 0; i < 32; ++i)
      27      {
      28        align1 = random ();
      29        align2 = random ();
      30        size = (random () % 0x1000000) + 0x200000;
      31        do_test1 (align1, align2, size);
      32      }
      33  
      34    for (i = 0; i < 128; ++i)
      35      {
      36        align1 = random ();
      37        align2 = random ();
      38        size = (random () % 32768) + 4096;
      39        do_test1 (align1, align2, size);
      40      }
      41  }
      42  
      43  int
      44  test_main (void)
      45  {
      46    size_t i, j;
      47  
      48    test_init ();
      49  
      50    printf ("%23s", "");
      51    FOR_EACH_IMPL (impl, 0)
      52    printf ("\t%s", impl->name);
      53    putchar ('\n');
      54  
      55    do_test (0, 0, getpagesize () - 1);
      56  
      57    for (i = 0x200000; i <= 0x2000000; i += i)
      58      {
      59        for (j = 64; j <= 1024; j <<= 1)
      60          {
      61            do_test1 (0, j, i);
      62            do_test1 (4095, j, i);
      63            do_test1 (4096 - j, 0, i);
      64  
      65            do_test1 (0, j - 1, i);
      66            do_test1 (4095, j - 1, i);
      67            do_test1 (4096 - j - 1, 0, i);
      68  
      69            do_test1 (0, j + 1, i);
      70            do_test1 (4095, j + 1, i);
      71            do_test1 (4096 - j, 1, i);
      72  
      73            do_test1 (0, j, i + 1);
      74            do_test1 (4095, j, i + 1);
      75            do_test1 (4096 - j, 0, i + 1);
      76  
      77            do_test1 (0, j - 1, i + 1);
      78            do_test1 (4095, j - 1, i + 1);
      79            do_test1 (4096 - j - 1, 0, i + 1);
      80  
      81            do_test1 (0, j + 1, i + 1);
      82            do_test1 (4095, j + 1, i + 1);
      83            do_test1 (4096 - j, 1, i + 1);
      84  
      85            do_test1 (0, j, i - 1);
      86            do_test1 (4095, j, i - 1);
      87            do_test1 (4096 - j, 0, i - 1);
      88  
      89            do_test1 (0, j - 1, i - 1);
      90            do_test1 (4095, j - 1, i - 1);
      91            do_test1 (4096 - j - 1, 0, i - 1);
      92  
      93            do_test1 (0, j + 1, i - 1);
      94            do_test1 (4095, j + 1, i - 1);
      95            do_test1 (4096 - j, 1, i - 1);
      96          }
      97      }
      98  
      99    do_random_large_tests ();
     100    return ret;
     101  }
     102  
     103  #include <support/test-driver.c>