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