Tianji Wu
/
hw2_pt
HW2 implemented using protothread
lc-addrlabels.h@0:e2cc8ae74a24, 2010-12-01 (annotated)
- Committer:
- the729
- Date:
- Wed Dec 01 02:53:56 2010 +0000
- Revision:
- 0:e2cc8ae74a24
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
the729 | 0:e2cc8ae74a24 | 1 | /* |
the729 | 0:e2cc8ae74a24 | 2 | * Copyright (c) 2004-2005, Swedish Institute of Computer Science. |
the729 | 0:e2cc8ae74a24 | 3 | * All rights reserved. |
the729 | 0:e2cc8ae74a24 | 4 | * |
the729 | 0:e2cc8ae74a24 | 5 | * Redistribution and use in source and binary forms, with or without |
the729 | 0:e2cc8ae74a24 | 6 | * modification, are permitted provided that the following conditions |
the729 | 0:e2cc8ae74a24 | 7 | * are met: |
the729 | 0:e2cc8ae74a24 | 8 | * 1. Redistributions of source code must retain the above copyright |
the729 | 0:e2cc8ae74a24 | 9 | * notice, this list of conditions and the following disclaimer. |
the729 | 0:e2cc8ae74a24 | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
the729 | 0:e2cc8ae74a24 | 11 | * notice, this list of conditions and the following disclaimer in the |
the729 | 0:e2cc8ae74a24 | 12 | * documentation and/or other materials provided with the distribution. |
the729 | 0:e2cc8ae74a24 | 13 | * 3. Neither the name of the Institute nor the names of its contributors |
the729 | 0:e2cc8ae74a24 | 14 | * may be used to endorse or promote products derived from this software |
the729 | 0:e2cc8ae74a24 | 15 | * without specific prior written permission. |
the729 | 0:e2cc8ae74a24 | 16 | * |
the729 | 0:e2cc8ae74a24 | 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND |
the729 | 0:e2cc8ae74a24 | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
the729 | 0:e2cc8ae74a24 | 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
the729 | 0:e2cc8ae74a24 | 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE |
the729 | 0:e2cc8ae74a24 | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
the729 | 0:e2cc8ae74a24 | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
the729 | 0:e2cc8ae74a24 | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
the729 | 0:e2cc8ae74a24 | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
the729 | 0:e2cc8ae74a24 | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
the729 | 0:e2cc8ae74a24 | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
the729 | 0:e2cc8ae74a24 | 27 | * SUCH DAMAGE. |
the729 | 0:e2cc8ae74a24 | 28 | * |
the729 | 0:e2cc8ae74a24 | 29 | * This file is part of the Contiki operating system. |
the729 | 0:e2cc8ae74a24 | 30 | * |
the729 | 0:e2cc8ae74a24 | 31 | * Author: Adam Dunkels <adam@sics.se> |
the729 | 0:e2cc8ae74a24 | 32 | * |
the729 | 0:e2cc8ae74a24 | 33 | * $Id: lc-addrlabels.h,v 1.4 2006/06/03 11:29:43 adam Exp $ |
the729 | 0:e2cc8ae74a24 | 34 | */ |
the729 | 0:e2cc8ae74a24 | 35 | |
the729 | 0:e2cc8ae74a24 | 36 | /** |
the729 | 0:e2cc8ae74a24 | 37 | * \addtogroup lc |
the729 | 0:e2cc8ae74a24 | 38 | * @{ |
the729 | 0:e2cc8ae74a24 | 39 | */ |
the729 | 0:e2cc8ae74a24 | 40 | |
the729 | 0:e2cc8ae74a24 | 41 | /** |
the729 | 0:e2cc8ae74a24 | 42 | * \file |
the729 | 0:e2cc8ae74a24 | 43 | * Implementation of local continuations based on the "Labels as |
the729 | 0:e2cc8ae74a24 | 44 | * values" feature of gcc |
the729 | 0:e2cc8ae74a24 | 45 | * \author |
the729 | 0:e2cc8ae74a24 | 46 | * Adam Dunkels <adam@sics.se> |
the729 | 0:e2cc8ae74a24 | 47 | * |
the729 | 0:e2cc8ae74a24 | 48 | * This implementation of local continuations is based on a special |
the729 | 0:e2cc8ae74a24 | 49 | * feature of the GCC C compiler called "labels as values". This |
the729 | 0:e2cc8ae74a24 | 50 | * feature allows assigning pointers with the address of the code |
the729 | 0:e2cc8ae74a24 | 51 | * corresponding to a particular C label. |
the729 | 0:e2cc8ae74a24 | 52 | * |
the729 | 0:e2cc8ae74a24 | 53 | * For more information, see the GCC documentation: |
the729 | 0:e2cc8ae74a24 | 54 | * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html |
the729 | 0:e2cc8ae74a24 | 55 | * |
the729 | 0:e2cc8ae74a24 | 56 | */ |
the729 | 0:e2cc8ae74a24 | 57 | |
the729 | 0:e2cc8ae74a24 | 58 | #ifndef __LC_ADDRLABELS_H__ |
the729 | 0:e2cc8ae74a24 | 59 | #define __LC_ADDRLABELS_H__ |
the729 | 0:e2cc8ae74a24 | 60 | |
the729 | 0:e2cc8ae74a24 | 61 | /** \hideinitializer */ |
the729 | 0:e2cc8ae74a24 | 62 | typedef void * lc_t; |
the729 | 0:e2cc8ae74a24 | 63 | |
the729 | 0:e2cc8ae74a24 | 64 | #define LC_INIT(s) s = NULL |
the729 | 0:e2cc8ae74a24 | 65 | |
the729 | 0:e2cc8ae74a24 | 66 | #define LC_RESUME(s) \ |
the729 | 0:e2cc8ae74a24 | 67 | do { \ |
the729 | 0:e2cc8ae74a24 | 68 | if(s != NULL) { \ |
the729 | 0:e2cc8ae74a24 | 69 | goto *s; \ |
the729 | 0:e2cc8ae74a24 | 70 | } \ |
the729 | 0:e2cc8ae74a24 | 71 | } while(0) |
the729 | 0:e2cc8ae74a24 | 72 | |
the729 | 0:e2cc8ae74a24 | 73 | #define LC_CONCAT2(s1, s2) s1##s2 |
the729 | 0:e2cc8ae74a24 | 74 | #define LC_CONCAT(s1, s2) LC_CONCAT2(s1, s2) |
the729 | 0:e2cc8ae74a24 | 75 | |
the729 | 0:e2cc8ae74a24 | 76 | #define LC_SET(s) \ |
the729 | 0:e2cc8ae74a24 | 77 | do { \ |
the729 | 0:e2cc8ae74a24 | 78 | LC_CONCAT(LC_LABEL, __LINE__): \ |
the729 | 0:e2cc8ae74a24 | 79 | (s) = &&LC_CONCAT(LC_LABEL, __LINE__); \ |
the729 | 0:e2cc8ae74a24 | 80 | } while(0) |
the729 | 0:e2cc8ae74a24 | 81 | |
the729 | 0:e2cc8ae74a24 | 82 | #define LC_END(s) |
the729 | 0:e2cc8ae74a24 | 83 | |
the729 | 0:e2cc8ae74a24 | 84 | #endif /* __LC_ADDRLABELS_H__ */ |
the729 | 0:e2cc8ae74a24 | 85 | /** @} */ |