atomic.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Linux 2.6.32 and later Kernel module for VMware MVP Hypervisor Support
  3. *
  4. * Copyright (C) 2010-2013 VMware, Inc. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published by
  8. * the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; see the file COPYING. If not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #line 5
  20. /**
  21. * @file
  22. *
  23. * @brief bus-atomic operators.
  24. *
  25. * The 'atm' argument is the atomic memory cell being operated on and the
  26. * remainder of the arguments are the values being applied to the atomic cell
  27. * which is assumed to be located in shared normal memory. The operation is
  28. * both atomic and visible to the default share-ability domain upon completion.
  29. *
  30. * The design of each macro is such that the compiler should check types
  31. * correctly. For those macros that return a value, the return type should be
  32. * the same as the 'atm' argument (with the exception of ATOMIC_SETIF which
  33. * returns an int value of 0 or 1).
  34. *
  35. * Those names ending in 'M' return the modified value of 'atm'.
  36. * Those names ending in 'O' return the original value of 'atm'.
  37. * Those names ending in 'V' return void (ie, nothing).
  38. */
  39. #ifndef _ATOMIC_H
  40. #define _ATOMIC_H
  41. #define INCLUDE_ALLOW_MVPD
  42. #define INCLUDE_ALLOW_VMX
  43. #define INCLUDE_ALLOW_MODULE
  44. #define INCLUDE_ALLOW_MONITOR
  45. #define INCLUDE_ALLOW_PV
  46. #define INCLUDE_ALLOW_GPL
  47. #define INCLUDE_ALLOW_HOSTUSER
  48. #define INCLUDE_ALLOW_GUESTUSER
  49. #include "include_check.h"
  50. /*
  51. * Wrap type 't' in an atomic struct.
  52. * Eg, 'static ATOMIC(uint8) counter;'.
  53. *
  54. * The function macros use the atm_Normal member to clone the atom's type
  55. * when the volatile semantic is not required. They use the atm_Volatl member
  56. * when the volatile semantic is required.
  57. */
  58. #define ATOMIC(t) union { t atm_Normal; t volatile atm_Volatl; }
  59. /*
  60. * Static atomic variable initialization.
  61. * Eg, 'static ATOMIC(uint8) counter = ATOMIC_INI(35);'.
  62. */
  63. #define ATOMIC_INI(v) { .atm_Normal = v }
  64. /*
  65. * Some commonly used atomic types.
  66. */
  67. typedef ATOMIC(int32) AtmSInt32 __attribute__((aligned(4)));
  68. typedef ATOMIC(uint32) AtmUInt32 __attribute__((aligned(4)));
  69. typedef ATOMIC(uint64) AtmUInt64 __attribute__((aligned(8)));
  70. /*
  71. * Architecture-dependent implementations.
  72. */
  73. #if defined(__COVERITY__)
  74. #include "atomic_coverity.h"
  75. #elif defined(__arm__)
  76. #include "atomic_arm.h"
  77. #elif defined(__i386) || defined(__x86_64)
  78. #include "atomic_x86.h"
  79. #endif
  80. #endif