Blame iscsiuio/src/uip/lc-addrlabels.h

Packit eace71
/*
Packit eace71
 * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
Packit eace71
 * All rights reserved.
Packit eace71
 *
Packit eace71
 * Redistribution and use in source and binary forms, with or without
Packit eace71
 * modification, are permitted provided that the following conditions
Packit eace71
 * are met:
Packit eace71
 * 1. Redistributions of source code must retain the above copyright
Packit eace71
 *    notice, this list of conditions and the following disclaimer.
Packit eace71
 * 2. Redistributions in binary form must reproduce the above copyright
Packit eace71
 *    notice, this list of conditions and the following disclaimer in the
Packit eace71
 *    documentation and/or other materials provided with the distribution.
Packit eace71
 * 3. Neither the name of the Institute nor the names of its contributors
Packit eace71
 *    may be used to endorse or promote products derived from this software
Packit eace71
 *    without specific prior written permission.
Packit eace71
 *
Packit eace71
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
Packit eace71
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit eace71
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit eace71
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
Packit eace71
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit eace71
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit eace71
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit eace71
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit eace71
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit eace71
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit eace71
 * SUCH DAMAGE.
Packit eace71
 *
Packit eace71
 * This file is part of the uIP TCP/IP stack
Packit eace71
 *
Packit eace71
 * Author: Adam Dunkels <adam@sics.se>
Packit eace71
 *
Packit eace71
 */
Packit eace71
Packit eace71
/**
Packit eace71
 * \addtogroup lc
Packit eace71
 * @{
Packit eace71
 */
Packit eace71
Packit eace71
/**
Packit eace71
 * \file
Packit eace71
 * Implementation of local continuations based on the "Labels as
Packit eace71
 * values" feature of gcc
Packit eace71
 * \author
Packit eace71
 * Adam Dunkels <adam@sics.se>
Packit eace71
 *
Packit eace71
 * This implementation of local continuations is based on a special
Packit eace71
 * feature of the GCC C compiler called "labels as values". This
Packit eace71
 * feature allows assigning pointers with the address of the code
Packit eace71
 * corresponding to a particular C label.
Packit eace71
 *
Packit eace71
 * For more information, see the GCC documentation:
Packit eace71
 * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
Packit eace71
 *
Packit eace71
 * Thanks to dividuum for finding the nice local scope label
Packit eace71
 * implementation.
Packit eace71
 */
Packit eace71
Packit eace71
#ifndef __LC_ADDRLABELS_H__
Packit eace71
#define __LC_ADDRLABELS_H__
Packit eace71
Packit eace71
/** \hideinitializer */
Packit eace71
Packit eace71
#define LC_INIT(s)	(s = NULL)
Packit eace71
Packit eace71
#define LC_RESUME(s)			\
Packit eace71
	do {				\
Packit eace71
		if (s != NULL) {	\
Packit eace71
			goto *s;	\
Packit eace71
		}			\
Packit eace71
	} while (0)
Packit eace71
Packit eace71
#define LC_SET(s)                               \
Packit eace71
	do { ({ __label__ resume; resume: (s) = &&resume; }); } while (0)
Packit eace71
Packit eace71
#define LC_END(s)
Packit eace71
Packit eace71
#endif /* __LC_ADDRLABELS_H__ */
Packit eace71
Packit eace71
/**  @} */