Yan Wang / Mbed 2 deprecated ProtoThread

Dependencies:   mbed

Committer:
phyllis
Date:
Tue Nov 30 22:14:29 2010 +0000
Revision:
0:1690a672d017

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phyllis 0:1690a672d017 1 /*
phyllis 0:1690a672d017 2 * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
phyllis 0:1690a672d017 3 * All rights reserved.
phyllis 0:1690a672d017 4 *
phyllis 0:1690a672d017 5 * Redistribution and use in source and binary forms, with or without
phyllis 0:1690a672d017 6 * modification, are permitted provided that the following conditions
phyllis 0:1690a672d017 7 * are met:
phyllis 0:1690a672d017 8 * 1. Redistributions of source code must retain the above copyright
phyllis 0:1690a672d017 9 * notice, this list of conditions and the following disclaimer.
phyllis 0:1690a672d017 10 * 2. Redistributions in binary form must reproduce the above copyright
phyllis 0:1690a672d017 11 * notice, this list of conditions and the following disclaimer in the
phyllis 0:1690a672d017 12 * documentation and/or other materials provided with the distribution.
phyllis 0:1690a672d017 13 * 3. Neither the name of the Institute nor the names of its contributors
phyllis 0:1690a672d017 14 * may be used to endorse or promote products derived from this software
phyllis 0:1690a672d017 15 * without specific prior written permission.
phyllis 0:1690a672d017 16 *
phyllis 0:1690a672d017 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
phyllis 0:1690a672d017 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
phyllis 0:1690a672d017 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
phyllis 0:1690a672d017 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
phyllis 0:1690a672d017 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
phyllis 0:1690a672d017 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
phyllis 0:1690a672d017 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
phyllis 0:1690a672d017 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
phyllis 0:1690a672d017 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
phyllis 0:1690a672d017 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
phyllis 0:1690a672d017 27 * SUCH DAMAGE.
phyllis 0:1690a672d017 28 *
phyllis 0:1690a672d017 29 * This file is part of the Contiki operating system.
phyllis 0:1690a672d017 30 *
phyllis 0:1690a672d017 31 * Author: Adam Dunkels <adam@sics.se>
phyllis 0:1690a672d017 32 *
phyllis 0:1690a672d017 33 * $Id: lc-switch.h,v 1.4 2006/06/03 11:29:43 adam Exp $
phyllis 0:1690a672d017 34 */
phyllis 0:1690a672d017 35
phyllis 0:1690a672d017 36 /**
phyllis 0:1690a672d017 37 * \addtogroup lc
phyllis 0:1690a672d017 38 * @{
phyllis 0:1690a672d017 39 */
phyllis 0:1690a672d017 40
phyllis 0:1690a672d017 41 /**
phyllis 0:1690a672d017 42 * \file
phyllis 0:1690a672d017 43 * Implementation of local continuations based on switch() statment
phyllis 0:1690a672d017 44 * \author Adam Dunkels <adam@sics.se>
phyllis 0:1690a672d017 45 *
phyllis 0:1690a672d017 46 * This implementation of local continuations uses the C switch()
phyllis 0:1690a672d017 47 * statement to resume execution of a function somewhere inside the
phyllis 0:1690a672d017 48 * function's body. The implementation is based on the fact that
phyllis 0:1690a672d017 49 * switch() statements are able to jump directly into the bodies of
phyllis 0:1690a672d017 50 * control structures such as if() or while() statmenets.
phyllis 0:1690a672d017 51 *
phyllis 0:1690a672d017 52 * This implementation borrows heavily from Simon Tatham's coroutines
phyllis 0:1690a672d017 53 * implementation in C:
phyllis 0:1690a672d017 54 * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
phyllis 0:1690a672d017 55 */
phyllis 0:1690a672d017 56
phyllis 0:1690a672d017 57 #ifndef __LC_SWITCH_H__
phyllis 0:1690a672d017 58 #define __LC_SWITCH_H__
phyllis 0:1690a672d017 59
phyllis 0:1690a672d017 60 /* WARNING! lc implementation using switch() does not work if an
phyllis 0:1690a672d017 61 LC_SET() is done within another switch() statement! */
phyllis 0:1690a672d017 62
phyllis 0:1690a672d017 63 /** \hideinitializer */
phyllis 0:1690a672d017 64 typedef unsigned short lc_t;
phyllis 0:1690a672d017 65
phyllis 0:1690a672d017 66 #define LC_INIT(s) s = 0;
phyllis 0:1690a672d017 67
phyllis 0:1690a672d017 68 #define LC_RESUME(s) switch(s) { case 0:
phyllis 0:1690a672d017 69
phyllis 0:1690a672d017 70 #define LC_SET(s) s = __LINE__; case __LINE__:
phyllis 0:1690a672d017 71
phyllis 0:1690a672d017 72 #define LC_END(s) }
phyllis 0:1690a672d017 73
phyllis 0:1690a672d017 74 #endif /* __LC_SWITCH_H__ */
phyllis 0:1690a672d017 75
phyllis 0:1690a672d017 76 /** @} */