alt_sem.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __ALT_SEM_H__
  2. #define __ALT_SEM_H__
  3. /******************************************************************************
  4. * *
  5. * License Agreement *
  6. * *
  7. * Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
  8. * All rights reserved. *
  9. * *
  10. * Permission is hereby granted, free of charge, to any person obtaining a *
  11. * copy of this software and associated documentation files (the "Software"), *
  12. * to deal in the Software without restriction, including without limitation *
  13. * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
  14. * and/or sell copies of the Software, and to permit persons to whom the *
  15. * Software is furnished to do so, subject to the following conditions: *
  16. * *
  17. * The above copyright notice and this permission notice shall be included in *
  18. * all copies or substantial portions of the Software. *
  19. * *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
  23. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
  24. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
  26. * DEALINGS IN THE SOFTWARE. *
  27. * *
  28. * This agreement shall be governed in all respects by the laws of the State *
  29. * of California and by the laws of the United States of America. *
  30. * *
  31. * Altera does not recommend, suggest or require that this reference design *
  32. * file be used in conjunction or combination with any other product. *
  33. ******************************************************************************/
  34. /******************************************************************************
  35. * *
  36. * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT. *
  37. * *
  38. ******************************************************************************/
  39. /*
  40. * This header provides macro definitions that can be used to create and use
  41. * semaphores. These macros can be used in both a uC/OS-II based environment,
  42. * and a single threaded HAL based environment.
  43. *
  44. * The motivation for these macros is to allow code to be developed which is
  45. * thread safe under uC/OS-II, but incurs no additional overhead when used in a
  46. * single threaded HAL environment.
  47. *
  48. * In the case of a single threaded HAL environment, they compile to
  49. * "do nothing" directives, which ensures they do not contribute to the final
  50. * executable.
  51. *
  52. * The following macros are available:
  53. *
  54. * ALT_SEM - Create a semaphore instance.
  55. * ALT_EXTERN_SEM - Create a reference to an external semaphore instance.
  56. * ALT_STATIC_SEM - Create a static semaphore instance.
  57. * ALT_SEM_CREATE - Initialise a semaphore.
  58. * ALT_SEM_PEND - Pend on a semaphore.
  59. * ALT_SEM_POST - Increment a semaphore.
  60. *
  61. * Input arguments and return codes are all consistant with the equivalent
  62. * uC/OS-II function.
  63. *
  64. * It's important to be careful in the use of the macros: ALT_SEM,
  65. * ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is
  66. * included in the macro definition; so, for example, you should use:
  67. *
  68. * ALT_SEM(mysem)
  69. *
  70. * not:
  71. *
  72. * ALT_SEM(mysem);
  73. *
  74. * The inclusion of the semi-colon has been necessary to ensure the macros can
  75. * compile with no warnings when used in a single threaded HAL environment.
  76. *
  77. */
  78. #include "priv/alt_no_error.h"
  79. #define ALT_SEM(sem)
  80. #define ALT_EXTERN_SEM(sem)
  81. #define ALT_STATIC_SEM(sem)
  82. #define ALT_SEM_CREATE(sem, value) alt_no_error ()
  83. #define ALT_SEM_PEND(sem, timeout) alt_no_error ()
  84. #define ALT_SEM_POST(sem) alt_no_error ()
  85. #ifndef ALT_SINGLE_THREADED
  86. #define ALT_SINGLE_THREADED
  87. #endif
  88. #endif /* __ALT_SEM_H__ */