test-memcpy-large.c 2.7 KB

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