tst-tlsmod9.c 1.3 KB

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