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

Packit Service 646995
/*
Packit Service 646995
 * Copyright (c) 2004-2005, Swedish Institute of Computer Science.
Packit Service 646995
 * All rights reserved.
Packit Service 646995
 *
Packit Service 646995
 * Redistribution and use in source and binary forms, with or without
Packit Service 646995
 * modification, are permitted provided that the following conditions
Packit Service 646995
 * are met:
Packit Service 646995
 * 1. Redistributions of source code must retain the above copyright
Packit Service 646995
 *    notice, this list of conditions and the following disclaimer.
Packit Service 646995
 * 2. Redistributions in binary form must reproduce the above copyright
Packit Service 646995
 *    notice, this list of conditions and the following disclaimer in the
Packit Service 646995
 *    documentation and/or other materials provided with the distribution.
Packit Service 646995
 * 3. Neither the name of the Institute nor the names of its contributors
Packit Service 646995
 *    may be used to endorse or promote products derived from this software
Packit Service 646995
 *    without specific prior written permission.
Packit Service 646995
 *
Packit Service 646995
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
Packit Service 646995
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 646995
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit Service 646995
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
Packit Service 646995
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 646995
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit Service 646995
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit Service 646995
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit Service 646995
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit Service 646995
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit Service 646995
 * SUCH DAMAGE.
Packit Service 646995
 *
Packit Service 646995
 * This file is part of the uIP TCP/IP stack
Packit Service 646995
 *
Packit Service 646995
 * Author: Adam Dunkels <adam@sics.se>
Packit Service 646995
 *
Packit Service 646995
 */
Packit Service 646995
Packit Service 646995
/**
Packit Service 646995
 * \addtogroup lc
Packit Service 646995
 * @{
Packit Service 646995
 */
Packit Service 646995
Packit Service 646995
/**
Packit Service 646995
 * \file
Packit Service 646995
 * Implementation of local continuations based on switch() statment
Packit Service 646995
 * \author Adam Dunkels <adam@sics.se>
Packit Service 646995
 *
Packit Service 646995
 * This implementation of local continuations uses the C switch()
Packit Service 646995
 * statement to resume execution of a function somewhere inside the
Packit Service 646995
 * function's body. The implementation is based on the fact that
Packit Service 646995
 * switch() statements are able to jump directly into the bodies of
Packit Service 646995
 * control structures such as if() or while() statmenets.
Packit Service 646995
 *
Packit Service 646995
 * This implementation borrows heavily from Simon Tatham's coroutines
Packit Service 646995
 * implementation in C:
Packit Service 646995
 * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Packit Service 646995
 */
Packit Service 646995
Packit Service 646995
#ifndef __LC_SWITCH_H__
Packit Service 646995
#define __LC_SWTICH_H__
Packit Service 646995
Packit Service 646995
/* WARNING! lc implementation using switch() does not work if an
Packit Service 646995
   LC_SET() is done within another switch() statement! */
Packit Service 646995
Packit Service 646995
/** \hideinitializer */
Packit Service 646995
#define LC_INIT(s) s = 0;
Packit Service 646995
Packit Service 646995
#define LC_RESUME(s) switch (s) { case 0:
Packit Service 646995
Packit Service 646995
#define LC_SET(s) s = __LINE__; case __LINE__:
Packit Service 646995
Packit Service 646995
#define LC_END(s) }
Packit Service 646995
Packit Service 646995
#endif /* __LC_SWITCH_H__ */
Packit Service 646995
Packit Service 646995
/** @} */