tls_test_c.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* tls_test_c.c -- test TLS common symbol
  2. Copyright (C) 2008-2015 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor <iant@google.com>
  4. This file is part of gold.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. /* The only way I know to get gcc to generate a TLS common symbol is
  18. to use a C file and an OpenMP directive. */
  19. #include "config.h"
  20. #include <stdio.h>
  21. #define CHECK_EQ_OR_RETURN(var, expected) \
  22. do \
  23. { \
  24. if ((var) != (expected)) \
  25. { \
  26. printf(#var ": expected %d, found %d\n", expected, var); \
  27. return 0; \
  28. } \
  29. } \
  30. while (0)
  31. #ifdef HAVE_OMP_SUPPORT
  32. int v7;
  33. #pragma omp threadprivate (v7)
  34. #endif
  35. int t11(void);
  36. int t11_last(void);
  37. int
  38. t11(void)
  39. {
  40. #ifdef HAVE_OMP_SUPPORT
  41. CHECK_EQ_OR_RETURN(v7, 0);
  42. v7 = 70;
  43. #endif
  44. return 1;
  45. }
  46. int
  47. t11_last(void)
  48. {
  49. #ifdef HAVE_OMP_SUPPORT
  50. CHECK_EQ_OR_RETURN(v7, 70);
  51. #endif
  52. return 1;
  53. }