Jingyuan Dong / Mbed 2 deprecated protoThread

Dependencies:   mbed

Committer:
guruimage
Date:
Wed Dec 01 02:46:33 2010 +0000
Revision:
0:9b9c31c57895
protoThread problem for hw2

Who changed what in which revision?

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