Jiwen Cai / Mbed 2 deprecated HW2-3
Committer:
goodcjw
Date:
Tue Nov 30 23:52:57 2010 +0000
Revision:
0:ca4c2177a6b5

        

Who changed what in which revision?

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