Blame src/vma/lwip/def.h

Packit Service aa3af4
/*
Packit Service aa3af4
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
Packit Service aa3af4
 * All rights reserved. 
Packit Service aa3af4
 * 
Packit Service aa3af4
 * Redistribution and use in source and binary forms, with or without modification, 
Packit Service aa3af4
 * are permitted provided that the following conditions are met:
Packit Service aa3af4
 *
Packit Service aa3af4
 * 1. Redistributions of source code must retain the above copyright notice,
Packit Service aa3af4
 *    this list of conditions and the following disclaimer.
Packit Service aa3af4
 * 2. Redistributions in binary form must reproduce the above copyright notice,
Packit Service aa3af4
 *    this list of conditions and the following disclaimer in the documentation
Packit Service aa3af4
 *    and/or other materials provided with the distribution.
Packit Service aa3af4
 * 3. The name of the author may not be used to endorse or promote products
Packit Service aa3af4
 *    derived from this software without specific prior written permission. 
Packit Service aa3af4
 *
Packit Service aa3af4
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
Packit Service aa3af4
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
Packit Service aa3af4
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
Packit Service aa3af4
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
Packit Service aa3af4
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
Packit Service aa3af4
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
Packit Service aa3af4
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
Packit Service aa3af4
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
Packit Service aa3af4
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
Packit Service aa3af4
 * OF SUCH DAMAGE.
Packit Service aa3af4
 *
Packit Service aa3af4
 * This file is part of the lwIP TCP/IP stack.
Packit Service aa3af4
 * 
Packit Service aa3af4
 * Author: Adam Dunkels <adam@sics.se>
Packit Service aa3af4
 *
Packit Service aa3af4
 */
Packit Service aa3af4
#ifndef __LWIP_DEF_H__
Packit Service aa3af4
#define __LWIP_DEF_H__
Packit Service aa3af4
Packit Service aa3af4
/* arch.h might define NULL already */
Packit Service aa3af4
Packit Service aa3af4
#include "vma/lwip/opt.h"
Packit Service aa3af4
Packit Service aa3af4
#ifdef __cplusplus
Packit Service aa3af4
extern "C" {
Packit Service aa3af4
#endif
Packit Service aa3af4
Packit Service aa3af4
#define LWIP_MAX(x , y)  (((x) > (y)) ? (x) : (y))
Packit Service aa3af4
#define LWIP_MIN(x , y)  (((x) < (y)) ? (x) : (y))
Packit Service aa3af4
Packit Service aa3af4
#ifndef NULL
Packit Service aa3af4
#define NULL ((void *)0)
Packit Service aa3af4
#endif
Packit Service aa3af4
Packit Service aa3af4
/** Get the absolute difference between 2 u32_t values (correcting overflows)
Packit Service aa3af4
 * 'a' is expected to be 'higher' (without overflow) than 'b'. */
Packit Service aa3af4
#define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1))) 
Packit Service aa3af4
Packit Service aa3af4
/* Endianess-optimized shifting of two u8_t to create one u16_t */
Packit Service aa3af4
#if BYTE_ORDER == LITTLE_ENDIAN
Packit Service aa3af4
#define LWIP_MAKE_U16(a, b) ((a << 8) | b)
Packit Service aa3af4
#else
Packit Service aa3af4
#define LWIP_MAKE_U16(a, b) ((b << 8) | a)
Packit Service aa3af4
#endif 
Packit Service aa3af4
Packit Service aa3af4
#ifndef LWIP_PLATFORM_BYTESWAP
Packit Service aa3af4
#define LWIP_PLATFORM_BYTESWAP 0
Packit Service aa3af4
#endif
Packit Service aa3af4
Packit Service aa3af4
#ifndef LWIP_PREFIX_BYTEORDER_FUNCS
Packit Service aa3af4
/* workaround for naming collisions on some platforms */
Packit Service aa3af4
Packit Service aa3af4
#ifdef htons
Packit Service aa3af4
#undef htons
Packit Service aa3af4
#endif /* htons */
Packit Service aa3af4
#ifdef htonl
Packit Service aa3af4
#undef htonl
Packit Service aa3af4
#endif /* htonl */
Packit Service aa3af4
#ifdef ntohs
Packit Service aa3af4
#undef ntohs
Packit Service aa3af4
#endif /* ntohs */
Packit Service aa3af4
#ifdef ntohl
Packit Service aa3af4
#undef ntohl
Packit Service aa3af4
#endif /* ntohl */
Packit Service aa3af4
Packit Service aa3af4
#define htons(x) lwip_htons(x)
Packit Service aa3af4
#define ntohs(x) lwip_ntohs(x)
Packit Service aa3af4
#define htonl(x) lwip_htonl(x)
Packit Service aa3af4
#define ntohl(x) lwip_ntohl(x)
Packit Service aa3af4
#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
Packit Service aa3af4
Packit Service aa3af4
#if BYTE_ORDER == BIG_ENDIAN
Packit Service aa3af4
#define lwip_htons(x) (x)
Packit Service aa3af4
#define lwip_ntohs(x) (x)
Packit Service aa3af4
#define lwip_htonl(x) (x)
Packit Service aa3af4
#define lwip_ntohl(x) (x)
Packit Service aa3af4
#define PP_HTONS(x) (x)
Packit Service aa3af4
#define PP_NTOHS(x) (x)
Packit Service aa3af4
#define PP_HTONL(x) (x)
Packit Service aa3af4
#define PP_NTOHL(x) (x)
Packit Service aa3af4
#else /* BYTE_ORDER != BIG_ENDIAN */
Packit Service aa3af4
#if LWIP_PLATFORM_BYTESWAP
Packit Service aa3af4
#define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
Packit Service aa3af4
#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
Packit Service aa3af4
#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
Packit Service aa3af4
#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
Packit Service aa3af4
#else /* LWIP_PLATFORM_BYTESWAP */
Packit Service aa3af4
u16_t lwip_htons(u16_t x);
Packit Service aa3af4
u16_t lwip_ntohs(u16_t x);
Packit Service aa3af4
u32_t lwip_htonl(u32_t x);
Packit Service aa3af4
u32_t lwip_ntohl(u32_t x);
Packit Service aa3af4
#endif /* LWIP_PLATFORM_BYTESWAP */
Packit Service aa3af4
Packit Service aa3af4
/* These macros should be calculated by the preprocessor and are used
Packit Service aa3af4
   with compile-time constants only (so that there is no little-endian
Packit Service aa3af4
   overhead at runtime). */
Packit Service aa3af4
#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
Packit Service aa3af4
#define PP_NTOHS(x) PP_HTONS(x)
Packit Service aa3af4
#define PP_HTONL(x) ((((x) & 0xff) << 24) | \
Packit Service aa3af4
                     (((x) & 0xff00) << 8) | \
Packit Service aa3af4
                     (((x) & 0xff0000UL) >> 8) | \
Packit Service aa3af4
                     (((x) & 0xff000000UL) >> 24))
Packit Service aa3af4
#define PP_NTOHL(x) PP_HTONL(x)
Packit Service aa3af4
Packit Service aa3af4
#endif /* BYTE_ORDER == BIG_ENDIAN */
Packit Service aa3af4
Packit Service aa3af4
#ifdef __cplusplus
Packit Service aa3af4
}
Packit Service aa3af4
#endif
Packit Service aa3af4
Packit Service aa3af4
#endif /* __LWIP_DEF_H__ */
Packit Service aa3af4