lock_types.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*************************************************************************/ /*!
  2. @File lock_types.h
  3. @Title Locking types
  4. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  5. @Description Locking specific enums, defines and structures
  6. @License Dual MIT/GPLv2
  7. The contents of this file are subject to the MIT license as set out below.
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16. Alternatively, the contents of this file may be used under the terms of
  17. the GNU General Public License Version 2 ("GPL") in which case the provisions
  18. of GPL are applicable instead of those above.
  19. If you wish to allow use of your version of this file only under the terms of
  20. GPL, and not to allow others to use your version of this file under the terms
  21. of the MIT license, indicate your decision by deleting the provisions above
  22. and replace them with the notice and other provisions required by GPL as set
  23. out in the file called "GPL-COPYING" included in this distribution. If you do
  24. not delete the provisions above, a recipient may use your version of this file
  25. under the terms of either the MIT license or GPL.
  26. This License is also included in this distribution in the file called
  27. "MIT-COPYING".
  28. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  29. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  30. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  31. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  32. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  33. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  34. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  35. */ /**************************************************************************/
  36. #ifndef LOCK_TYPES_H
  37. #define LOCK_TYPES_H
  38. /* In Linux kernel mode we are using the kernel mutex implementation directly
  39. * with macros. This allows us to use the kernel lockdep feature for lock
  40. * debugging. */
  41. #if defined(__linux__) && defined(__KERNEL__)
  42. #include <linux/types.h>
  43. #include <linux/mutex.h>
  44. /* The mutex is defined as a pointer to be compatible with the other code. This
  45. * isn't ideal and usually you wouldn't do that in kernel code. */
  46. typedef struct mutex *POS_LOCK;
  47. typedef struct rw_semaphore *POSWR_LOCK;
  48. typedef spinlock_t *POS_SPINLOCK;
  49. typedef atomic_t ATOMIC_T;
  50. #else /* defined(__linux__) && defined(__KERNEL__) */
  51. #include "img_types.h" /* needed for IMG_INT */
  52. typedef struct _OS_LOCK_ *POS_LOCK;
  53. #if defined(__linux__) || defined(__QNXNTO__) || defined(INTEGRITY_OS)
  54. typedef struct _OSWR_LOCK_ *POSWR_LOCK;
  55. #else /* defined(__linux__) || defined(__QNXNTO__) || defined(INTEGRITY_OS) */
  56. typedef struct _OSWR_LOCK_ {
  57. IMG_UINT32 ui32Dummy;
  58. } *POSWR_LOCK;
  59. #endif /* defined(__linux__) || defined(__QNXNTO__) || defined(INTEGRITY_OS) */
  60. #if defined(__linux__)
  61. typedef struct _OS_ATOMIC {IMG_INT32 counter;} ATOMIC_T;
  62. #elif defined(__QNXNTO__)
  63. typedef struct _OS_ATOMIC {IMG_INT32 counter;} ATOMIC_T;
  64. #elif defined(_WIN32)
  65. /*
  66. * Dummy definition. WDDM doesn't use Services, but some headers
  67. * still have to be shared. This is one such case.
  68. */
  69. typedef struct _OS_ATOMIC {IMG_INT32 counter;} ATOMIC_T;
  70. #elif defined(INTEGRITY_OS)
  71. /* Only lower 32bits are used in OS ATOMIC APIs to have consistent behaviour across all OS */
  72. typedef struct _OS_ATOMIC {IMG_INT64 counter;} ATOMIC_T;
  73. #else
  74. #error "Please type-define an atomic lock for this environment"
  75. #endif
  76. #endif /* defined(__linux__) && defined(__KERNEL__) */
  77. #endif /* LOCK_TYPES_H */