You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
5.8 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: platformstl/synch/semaphore.hpp
  3. *
  4. * Purpose: Platform header for directory manipulation functions.
  5. *
  6. * Created: 30th May 2006
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2006-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file platformstl/synch/semaphore.hpp
  40. *
  41. * \brief [C++ only] Definition of the platformstl::semaphore type
  42. * (\ref group__library__synch "Synchronisation" Library).
  43. */
  44. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SEMAPHORE
  45. #define PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SEMAPHORE
  46. /* File version */
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SEMAPHORE_MAJOR 1
  49. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SEMAPHORE_MINOR 1
  50. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SEMAPHORE_REVISION 1
  51. # define PLATFORMSTL_VER_PLATFORMSTL_SYNCH_HPP_SEMAPHORE_EDIT 10
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Compatibility
  55. */
  56. /*
  57. [Incompatibilies-start]
  58. STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1200
  59. [Incompatibilies-end]
  60. */
  61. /* /////////////////////////////////////////////////////////////////////////
  62. * Includes
  63. */
  64. #ifndef PLATFORMSTL_INCL_PLATFORMSTL_H_PLATFORMSTL
  65. # include <platformstl/platformstl.h>
  66. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_H_PLATFORMSTL */
  67. #if defined(PLATFORMSTL_OS_IS_UNIX)
  68. # ifndef UNIXSTL_INCL_UNIXSTL_SYNCH_HPP_SEMAPHORE
  69. # include <unixstl/synch/semaphore.hpp>
  70. # endif /* !UNIXSTL_INCL_UNIXSTL_SYNCH_HPP_SEMAPHORE */
  71. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  72. # ifndef WINSTL_INCL_WINSTL_SYNCH_HPP_SEMAPHORE
  73. # include <winstl/synch/semaphore.hpp>
  74. # endif /* !WINSTL_INCL_WINSTL_SYNCH_HPP_SEMAPHORE */
  75. #else /* ? operating system */
  76. # error Operating system not discriminated
  77. #endif /* operating system */
  78. /* /////////////////////////////////////////////////////////////////////////
  79. * Namespace
  80. */
  81. #if !defined(__cplusplus)
  82. /* Nothing defined in C */
  83. #elif defined(_STLSOFT_NO_NAMESPACE) || \
  84. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  85. /* There is no stlsoft namespace, so must define ::platformstl */
  86. namespace platformstl
  87. {
  88. #else
  89. /* Define stlsoft::platformstl_project */
  90. namespace stlsoft
  91. {
  92. namespace platformstl_project
  93. {
  94. #endif /* _STLSOFT_NO_NAMESPACE */
  95. /* ////////////////////////////////////////////////////////////////////// */
  96. #if defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  97. /** \brief A semaphore class
  98. *
  99. * The class is not actually defined in the
  100. * \link ::platformstl platformstl\endlink namespace. Rather, it
  101. * resolves to the appropriate type for the given platform, relying on
  102. * \ref section__principle__conformance__intersecting_conformance "Intersecting Conformance"
  103. * of the resolved platform-specific types.
  104. *
  105. * When compiling on UNIX platforms, the platformstl::semaphore
  106. * type resolves to the unixstl::semaphore class. On Windows platforms
  107. * it resolves to the winstl::semaphore class. It is not defined
  108. * for other platforms.
  109. */
  110. class semaphore
  111. {};
  112. #elif defined(PLATFORMSTL_OS_IS_UNIX)
  113. # ifdef _UNIXSTL_NO_NAMESPACE
  114. using ::semaphore;
  115. # else /* ? _UNIXSTL_NO_NAMESPACE */
  116. using ::unixstl::semaphore;
  117. # endif /* _UNIXSTL_NO_NAMESPACE */
  118. #elif defined(PLATFORMSTL_OS_IS_WINDOWS)
  119. # ifdef _WINSTL_NO_NAMESPACE
  120. using ::semaphore;
  121. # else /* ? _WINSTL_NO_NAMESPACE */
  122. using ::winstl::semaphore;
  123. # endif /* _WINSTL_NO_NAMESPACE */
  124. #else /* ? operating system */
  125. # error Operating system not discriminated
  126. #endif /* operating system */
  127. /* ////////////////////////////////////////////////////////////////////// */
  128. #if !defined(__cplusplus)
  129. /* Nothing defined in C */
  130. #elif defined(_STLSOFT_NO_NAMESPACE) || \
  131. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  132. } // namespace platformstl
  133. #else
  134. } // namespace platformstl_project
  135. } // namespace stlsoft
  136. #endif /* _STLSOFT_NO_NAMESPACE */
  137. /* ////////////////////////////////////////////////////////////////////// */
  138. #endif /* !PLATFORMSTL_INCL_PLATFORMSTL_SYNCH_HPP_SEMAPHORE */
  139. /* ///////////////////////////// end of file //////////////////////////// */