tst-audit-threads.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Helper header for test-audit-threads.
  2. Copyright (C) 2018-2019 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. <http://www.gnu.org/licenses/>. */
  15. /* We use this helper to create a large number of functions, all of
  16. which will be resolved lazily and thus have their PLT updated.
  17. This is done to provide enough functions that we can statistically
  18. observe a thread vs. PLT resolution failure if one exists. */
  19. #define CONCAT(a, b) a ## b
  20. #define NUM(x, y) CONCAT (x, y)
  21. #define FUNC10(x) \
  22. FUNC (NUM (x, 0)); \
  23. FUNC (NUM (x, 1)); \
  24. FUNC (NUM (x, 2)); \
  25. FUNC (NUM (x, 3)); \
  26. FUNC (NUM (x, 4)); \
  27. FUNC (NUM (x, 5)); \
  28. FUNC (NUM (x, 6)); \
  29. FUNC (NUM (x, 7)); \
  30. FUNC (NUM (x, 8)); \
  31. FUNC (NUM (x, 9))
  32. #define FUNC100(x) \
  33. FUNC10 (NUM (x, 0)); \
  34. FUNC10 (NUM (x, 1)); \
  35. FUNC10 (NUM (x, 2)); \
  36. FUNC10 (NUM (x, 3)); \
  37. FUNC10 (NUM (x, 4)); \
  38. FUNC10 (NUM (x, 5)); \
  39. FUNC10 (NUM (x, 6)); \
  40. FUNC10 (NUM (x, 7)); \
  41. FUNC10 (NUM (x, 8)); \
  42. FUNC10 (NUM (x, 9))
  43. #define FUNC1000(x) \
  44. FUNC100 (NUM (x, 0)); \
  45. FUNC100 (NUM (x, 1)); \
  46. FUNC100 (NUM (x, 2)); \
  47. FUNC100 (NUM (x, 3)); \
  48. FUNC100 (NUM (x, 4)); \
  49. FUNC100 (NUM (x, 5)); \
  50. FUNC100 (NUM (x, 6)); \
  51. FUNC100 (NUM (x, 7)); \
  52. FUNC100 (NUM (x, 8)); \
  53. FUNC100 (NUM (x, 9))
  54. #define FUNC7000() \
  55. FUNC1000 (1); \
  56. FUNC1000 (2); \
  57. FUNC1000 (3); \
  58. FUNC1000 (4); \
  59. FUNC1000 (5); \
  60. FUNC1000 (6); \
  61. FUNC1000 (7);
  62. #ifdef FUNC
  63. # undef FUNC
  64. #endif
  65. #ifdef externnum
  66. # define FUNC(x) extern int CONCAT (retNum, x) (void)
  67. #endif
  68. #ifdef definenum
  69. # define FUNC(x) int CONCAT (retNum, x) (void) { return x; }
  70. #endif
  71. #ifdef callnum
  72. # define FUNC(x) CONCAT (retNum, x) (); sync_all (x)
  73. #endif
  74. /* A value of 7000 functions is chosen as an arbitrarily large
  75. number of functions that will allow us enough attempts to
  76. verify lazy resolution operation. */
  77. FUNC7000 ();