tst-tlsmod7.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include "tst-tls10.h"
  2. #ifdef USE_TLS__THREAD
  3. __thread int dummy __attribute__((visibility ("hidden"))) = 12;
  4. __thread struct A a1 = { 4, 5, 6 };
  5. __thread struct A a2 = { 7, 8, 9 };
  6. __thread struct A a3 __attribute__((tls_model("initial-exec")))
  7. = { 10, 11, 12 };
  8. __thread struct A a4 __attribute__((tls_model("initial-exec")))
  9. = { 13, 14, 15 };
  10. static __thread struct A local1 = { 16, 17, 18 };
  11. static __thread struct A local2 __attribute__((tls_model("initial-exec")))
  12. = { 19, 20, 21 };
  13. void
  14. check1 (void)
  15. {
  16. if (a1.a != 4 || a1.b != 5 || a1.c != 6)
  17. abort ();
  18. if (a2.a != 22 || a2.b != 23 || a2.c != 24)
  19. abort ();
  20. if (a3.a != 10 || a3.b != 11 || a3.c != 12)
  21. abort ();
  22. if (a4.a != 25 || a4.b != 26 || a4.c != 27)
  23. abort ();
  24. if (local1.a != 16 || local1.b != 17 || local1.c != 18)
  25. abort ();
  26. if (local2.a != 19 || local2.b != 20 || local2.c != 21)
  27. abort ();
  28. }
  29. struct A *
  30. f1a (void)
  31. {
  32. return &a1;
  33. }
  34. struct A *
  35. f2a (void)
  36. {
  37. return &a2;
  38. }
  39. struct A *
  40. f3a (void)
  41. {
  42. return &a3;
  43. }
  44. struct A *
  45. f4a (void)
  46. {
  47. return &a4;
  48. }
  49. struct A *
  50. f5a (void)
  51. {
  52. return &local1;
  53. }
  54. struct A *
  55. f6a (void)
  56. {
  57. return &local2;
  58. }
  59. int
  60. f1b (void)
  61. {
  62. return a1.a;
  63. }
  64. int
  65. f2b (void)
  66. {
  67. return a2.b;
  68. }
  69. int
  70. f3b (void)
  71. {
  72. return a3.c;
  73. }
  74. int
  75. f4b (void)
  76. {
  77. return a4.a;
  78. }
  79. int
  80. f5b (void)
  81. {
  82. return local1.b;
  83. }
  84. int
  85. f6b (void)
  86. {
  87. return local2.c;
  88. }
  89. #endif