host-config.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (C) 2012-2015 Free Software Foundation, Inc.
  2. Contributed by Richard Henderson <rth@redhat.com>.
  3. This file is part of the GNU Atomic Library (libatomic).
  4. Libatomic is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #if HAVE_IFUNC
  20. #include <cpuid.h>
  21. extern unsigned int libat_feat1_ecx HIDDEN;
  22. extern unsigned int libat_feat1_edx HIDDEN;
  23. #ifdef __x86_64__
  24. # define IFUNC_COND_1 (libat_feat1_ecx & bit_CMPXCHG16B)
  25. #else
  26. # define IFUNC_COND_1 (libat_feat1_edx & bit_CMPXCHG8B)
  27. #endif
  28. #ifdef __x86_64__
  29. # define IFUNC_NCOND(N) (N == 16)
  30. #else
  31. # define IFUNC_NCOND(N) (N == 8)
  32. #endif
  33. #ifdef __x86_64__
  34. # undef MAYBE_HAVE_ATOMIC_CAS_16
  35. # define MAYBE_HAVE_ATOMIC_CAS_16 IFUNC_COND_1
  36. # undef MAYBE_HAVE_ATOMIC_EXCHANGE_16
  37. # define MAYBE_HAVE_ATOMIC_EXCHANGE_16 IFUNC_COND_1
  38. # undef MAYBE_HAVE_ATOMIC_LDST_16
  39. # define MAYBE_HAVE_ATOMIC_LDST_16 IFUNC_COND_1
  40. # if IFUNC_ALT == 1
  41. # undef HAVE_ATOMIC_CAS_16
  42. # define HAVE_ATOMIC_CAS_16 1
  43. # endif
  44. #else
  45. # undef MAYBE_HAVE_ATOMIC_CAS_8
  46. # define MAYBE_HAVE_ATOMIC_CAS_8 IFUNC_COND_1
  47. # undef MAYBE_HAVE_ATOMIC_EXCHANGE_8
  48. # define MAYBE_HAVE_ATOMIC_EXCHANGE_8 IFUNC_COND_1
  49. # undef MAYBE_HAVE_ATOMIC_LDST_8
  50. # define MAYBE_HAVE_ATOMIC_LDST_8 IFUNC_COND_1
  51. # if IFUNC_ALT == 1
  52. # undef HAVE_ATOMIC_CAS_8
  53. # define HAVE_ATOMIC_CAS_8 1
  54. # endif
  55. #endif
  56. #endif /* HAVE_IFUNC */
  57. #include_next <host-config.h>