ibm_aix51.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  3. This file is part of Threading Building Blocks.
  4. Threading Building Blocks is free software; you can redistribute it
  5. and/or modify it under the terms of the GNU General Public License
  6. version 2 as published by the Free Software Foundation.
  7. Threading Building Blocks is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with Threading Building Blocks; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. As a special exception, you may use this file as part of a free software
  15. library without restriction. Specifically, if other files instantiate
  16. templates or use macros or inline functions from this file, or you compile
  17. this file and link it with other files to produce an executable, this
  18. file does not by itself cause the resulting executable to be covered by
  19. the GNU General Public License. This exception does not however
  20. invalidate any other reasons why the executable file might be covered by
  21. the GNU General Public License.
  22. */
  23. // TODO: revise by comparing with mac_ppc.h
  24. #if !defined(__TBB_machine_H) || defined(__TBB_machine_ibm_aix51_H)
  25. #error Do not #include this internal file directly; use public TBB headers instead.
  26. #endif
  27. #define __TBB_machine_ibm_aix51_H
  28. #define __TBB_WORDSIZE 8
  29. #define __TBB_BIG_ENDIAN 1 // assumption based on operating system
  30. #include <stdint.h>
  31. #include <unistd.h>
  32. #include <sched.h>
  33. extern "C" {
  34. int32_t __TBB_machine_cas_32 (volatile void* ptr, int32_t value, int32_t comparand);
  35. int64_t __TBB_machine_cas_64 (volatile void* ptr, int64_t value, int64_t comparand);
  36. void __TBB_machine_flush ();
  37. void __TBB_machine_lwsync ();
  38. void __TBB_machine_isync ();
  39. }
  40. // Mapping of old entry point names retained for the sake of backward binary compatibility
  41. #define __TBB_machine_cmpswp4 __TBB_machine_cas_32
  42. #define __TBB_machine_cmpswp8 __TBB_machine_cas_64
  43. #define __TBB_Yield() sched_yield()
  44. #define __TBB_USE_GENERIC_PART_WORD_CAS 1
  45. #define __TBB_USE_GENERIC_FETCH_ADD 1
  46. #define __TBB_USE_GENERIC_FETCH_STORE 1
  47. #define __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE 1
  48. #define __TBB_USE_GENERIC_RELAXED_LOAD_STORE 1
  49. #define __TBB_USE_GENERIC_SEQUENTIAL_CONSISTENCY_LOAD_STORE 1
  50. #if __GNUC__
  51. #define __TBB_control_consistency_helper() __asm__ __volatile__( "isync": : :"memory")
  52. #define __TBB_acquire_consistency_helper() __asm__ __volatile__("lwsync": : :"memory")
  53. #define __TBB_release_consistency_helper() __asm__ __volatile__("lwsync": : :"memory")
  54. #define __TBB_full_memory_fence() __asm__ __volatile__( "sync": : :"memory")
  55. #else
  56. // IBM C++ Compiler does not support inline assembly
  57. // TODO: Since XL 9.0 or earlier GCC syntax is supported. Replace with more
  58. // lightweight implementation (like in mac_ppc.h)
  59. #define __TBB_control_consistency_helper() __TBB_machine_isync ()
  60. #define __TBB_acquire_consistency_helper() __TBB_machine_lwsync ()
  61. #define __TBB_release_consistency_helper() __TBB_machine_lwsync ()
  62. #define __TBB_full_memory_fence() __TBB_machine_flush ()
  63. #endif