lc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the Institute nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * This file is part of the protothreads library.
  30. *
  31. * Author: Adam Dunkels <adam@sics.se>
  32. *
  33. * $Id: lc.h,v 1.2 2005/02/24 10:36:59 adam Exp $
  34. */
  35. /**
  36. * \addtogroup pt
  37. * @{
  38. */
  39. /**
  40. * \defgroup lc Local continuations
  41. * @{
  42. *
  43. * Local continuations form the basis for implementing protothreads. A
  44. * local continuation can be <i>set</i> in a specific function to
  45. * capture the state of the function. After a local continuation has
  46. * been set can be <i>resumed</i> in order to restore the state of the
  47. * function at the point where the local continuation was set.
  48. *
  49. *
  50. */
  51. /**
  52. * \file lc.h
  53. * Local continuations
  54. * \author
  55. * Adam Dunkels <adam@sics.se>
  56. *
  57. */
  58. #ifdef DOXYGEN
  59. /**
  60. * Initialize a local continuation.
  61. *
  62. * This operation initializes the local continuation, thereby
  63. * unsetting any previously set continuation state.
  64. *
  65. * \hideinitializer
  66. */
  67. #define LC_INIT(lc)
  68. /**
  69. * Set a local continuation.
  70. *
  71. * The set operation saves the state of the function at the point
  72. * where the operation is executed. As far as the set operation is
  73. * concerned, the state of the function does <b>not</b> include the
  74. * call-stack or local (automatic) variables, but only the program
  75. * counter and such CPU registers that needs to be saved.
  76. *
  77. * \hideinitializer
  78. */
  79. #define LC_SET(lc)
  80. /**
  81. * Resume a local continuation.
  82. *
  83. * The resume operation resumes a previously set local continuation, thus
  84. * restoring the state in which the function was when the local
  85. * continuation was set. If the local continuation has not been
  86. * previously set, the resume operation does nothing.
  87. *
  88. * \hideinitializer
  89. */
  90. #define LC_RESUME(lc)
  91. /**
  92. * Mark the end of local continuation usage.
  93. *
  94. * The end operation signifies that local continuations should not be
  95. * used any more in the function. This operation is not needed for
  96. * most implementations of local continuation, but is required by a
  97. * few implementations.
  98. *
  99. * \hideinitializer
  100. */
  101. #define LC_END(lc)
  102. /**
  103. * \var typedef lc_t;
  104. *
  105. * The local continuation type.
  106. *
  107. * \hideinitializer
  108. */
  109. #endif /* DOXYGEN */
  110. #ifndef __LC_H__
  111. #define __LC_H__
  112. #ifdef LC_INCLUDE
  113. #include LC_INCLUDE
  114. #else
  115. #include "lc-switch.h"
  116. #endif /* LC_INCLUDE */
  117. #endif /* __LC_H__ */
  118. /** @} */
  119. /** @} */