fdsf

Dependents:   sisk_proj_stat MQTT Hello_FXOS8700Q WireFSHandControl ... more

Committer:
grzemich
Date:
Wed Dec 07 23:47:50 2016 +0000
Revision:
0:d7bd7384a37c
dgd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
grzemich 0:d7bd7384a37c 1 /*
grzemich 0:d7bd7384a37c 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
grzemich 0:d7bd7384a37c 3 * All rights reserved.
grzemich 0:d7bd7384a37c 4 *
grzemich 0:d7bd7384a37c 5 * Redistribution and use in source and binary forms, with or without modification,
grzemich 0:d7bd7384a37c 6 * are permitted provided that the following conditions are met:
grzemich 0:d7bd7384a37c 7 *
grzemich 0:d7bd7384a37c 8 * 1. Redistributions of source code must retain the above copyright notice,
grzemich 0:d7bd7384a37c 9 * this list of conditions and the following disclaimer.
grzemich 0:d7bd7384a37c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
grzemich 0:d7bd7384a37c 11 * this list of conditions and the following disclaimer in the documentation
grzemich 0:d7bd7384a37c 12 * and/or other materials provided with the distribution.
grzemich 0:d7bd7384a37c 13 * 3. The name of the author may not be used to endorse or promote products
grzemich 0:d7bd7384a37c 14 * derived from this software without specific prior written permission.
grzemich 0:d7bd7384a37c 15 *
grzemich 0:d7bd7384a37c 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
grzemich 0:d7bd7384a37c 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
grzemich 0:d7bd7384a37c 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
grzemich 0:d7bd7384a37c 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
grzemich 0:d7bd7384a37c 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
grzemich 0:d7bd7384a37c 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
grzemich 0:d7bd7384a37c 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
grzemich 0:d7bd7384a37c 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
grzemich 0:d7bd7384a37c 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
grzemich 0:d7bd7384a37c 25 * OF SUCH DAMAGE.
grzemich 0:d7bd7384a37c 26 *
grzemich 0:d7bd7384a37c 27 * This file is part of the lwIP TCP/IP stack.
grzemich 0:d7bd7384a37c 28 *
grzemich 0:d7bd7384a37c 29 * Author: Adam Dunkels <adam@sics.se>
grzemich 0:d7bd7384a37c 30 *
grzemich 0:d7bd7384a37c 31 */
grzemich 0:d7bd7384a37c 32 #ifndef __LWIP_DEF_H__
grzemich 0:d7bd7384a37c 33 #define __LWIP_DEF_H__
grzemich 0:d7bd7384a37c 34
grzemich 0:d7bd7384a37c 35 /* arch.h might define NULL already */
grzemich 0:d7bd7384a37c 36 #include "lwip/arch.h"
grzemich 0:d7bd7384a37c 37 #include "lwip/opt.h"
grzemich 0:d7bd7384a37c 38
grzemich 0:d7bd7384a37c 39 #ifdef __cplusplus
grzemich 0:d7bd7384a37c 40 extern "C" {
grzemich 0:d7bd7384a37c 41 #endif
grzemich 0:d7bd7384a37c 42
grzemich 0:d7bd7384a37c 43 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
grzemich 0:d7bd7384a37c 44 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
grzemich 0:d7bd7384a37c 45
grzemich 0:d7bd7384a37c 46 #ifndef NULL
grzemich 0:d7bd7384a37c 47 #define NULL ((void *)0)
grzemich 0:d7bd7384a37c 48 #endif
grzemich 0:d7bd7384a37c 49
grzemich 0:d7bd7384a37c 50 /** Get the absolute difference between 2 u32_t values (correcting overflows)
grzemich 0:d7bd7384a37c 51 * 'a' is expected to be 'higher' (without overflow) than 'b'. */
grzemich 0:d7bd7384a37c 52 #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))
grzemich 0:d7bd7384a37c 53
grzemich 0:d7bd7384a37c 54 /* Endianess-optimized shifting of two u8_t to create one u16_t */
grzemich 0:d7bd7384a37c 55 #if BYTE_ORDER == LITTLE_ENDIAN
grzemich 0:d7bd7384a37c 56 #define LWIP_MAKE_U16(a, b) ((a << 8) | b)
grzemich 0:d7bd7384a37c 57 #else
grzemich 0:d7bd7384a37c 58 #define LWIP_MAKE_U16(a, b) ((b << 8) | a)
grzemich 0:d7bd7384a37c 59 #endif
grzemich 0:d7bd7384a37c 60
grzemich 0:d7bd7384a37c 61 #ifndef LWIP_PLATFORM_BYTESWAP
grzemich 0:d7bd7384a37c 62 #define LWIP_PLATFORM_BYTESWAP 0
grzemich 0:d7bd7384a37c 63 #endif
grzemich 0:d7bd7384a37c 64
grzemich 0:d7bd7384a37c 65 #ifndef LWIP_PREFIX_BYTEORDER_FUNCS
grzemich 0:d7bd7384a37c 66 /* workaround for naming collisions on some platforms */
grzemich 0:d7bd7384a37c 67
grzemich 0:d7bd7384a37c 68 #ifdef htons
grzemich 0:d7bd7384a37c 69 #undef htons
grzemich 0:d7bd7384a37c 70 #endif /* htons */
grzemich 0:d7bd7384a37c 71 #ifdef htonl
grzemich 0:d7bd7384a37c 72 #undef htonl
grzemich 0:d7bd7384a37c 73 #endif /* htonl */
grzemich 0:d7bd7384a37c 74 #ifdef ntohs
grzemich 0:d7bd7384a37c 75 #undef ntohs
grzemich 0:d7bd7384a37c 76 #endif /* ntohs */
grzemich 0:d7bd7384a37c 77 #ifdef ntohl
grzemich 0:d7bd7384a37c 78 #undef ntohl
grzemich 0:d7bd7384a37c 79 #endif /* ntohl */
grzemich 0:d7bd7384a37c 80
grzemich 0:d7bd7384a37c 81 #define htons(x) lwip_htons(x)
grzemich 0:d7bd7384a37c 82 #define ntohs(x) lwip_ntohs(x)
grzemich 0:d7bd7384a37c 83 #define htonl(x) lwip_htonl(x)
grzemich 0:d7bd7384a37c 84 #define ntohl(x) lwip_ntohl(x)
grzemich 0:d7bd7384a37c 85 #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
grzemich 0:d7bd7384a37c 86
grzemich 0:d7bd7384a37c 87 #if BYTE_ORDER == BIG_ENDIAN
grzemich 0:d7bd7384a37c 88 #define lwip_htons(x) (x)
grzemich 0:d7bd7384a37c 89 #define lwip_ntohs(x) (x)
grzemich 0:d7bd7384a37c 90 #define lwip_htonl(x) (x)
grzemich 0:d7bd7384a37c 91 #define lwip_ntohl(x) (x)
grzemich 0:d7bd7384a37c 92 #define PP_HTONS(x) (x)
grzemich 0:d7bd7384a37c 93 #define PP_NTOHS(x) (x)
grzemich 0:d7bd7384a37c 94 #define PP_HTONL(x) (x)
grzemich 0:d7bd7384a37c 95 #define PP_NTOHL(x) (x)
grzemich 0:d7bd7384a37c 96 #else /* BYTE_ORDER != BIG_ENDIAN */
grzemich 0:d7bd7384a37c 97 #if LWIP_PLATFORM_BYTESWAP
grzemich 0:d7bd7384a37c 98 #define lwip_htons(x) LWIP_PLATFORM_HTONS(x)
grzemich 0:d7bd7384a37c 99 #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x)
grzemich 0:d7bd7384a37c 100 #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x)
grzemich 0:d7bd7384a37c 101 #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x)
grzemich 0:d7bd7384a37c 102 #else /* LWIP_PLATFORM_BYTESWAP */
grzemich 0:d7bd7384a37c 103 u16_t lwip_htons(u16_t x);
grzemich 0:d7bd7384a37c 104 u16_t lwip_ntohs(u16_t x);
grzemich 0:d7bd7384a37c 105 u32_t lwip_htonl(u32_t x);
grzemich 0:d7bd7384a37c 106 u32_t lwip_ntohl(u32_t x);
grzemich 0:d7bd7384a37c 107 #endif /* LWIP_PLATFORM_BYTESWAP */
grzemich 0:d7bd7384a37c 108
grzemich 0:d7bd7384a37c 109 /* These macros should be calculated by the preprocessor and are used
grzemich 0:d7bd7384a37c 110 with compile-time constants only (so that there is no little-endian
grzemich 0:d7bd7384a37c 111 overhead at runtime). */
grzemich 0:d7bd7384a37c 112 #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
grzemich 0:d7bd7384a37c 113 #define PP_NTOHS(x) PP_HTONS(x)
grzemich 0:d7bd7384a37c 114 #define PP_HTONL(x) ((((x) & 0xff) << 24) | \
grzemich 0:d7bd7384a37c 115 (((x) & 0xff00) << 8) | \
grzemich 0:d7bd7384a37c 116 (((x) & 0xff0000UL) >> 8) | \
grzemich 0:d7bd7384a37c 117 (((x) & 0xff000000UL) >> 24))
grzemich 0:d7bd7384a37c 118 #define PP_NTOHL(x) PP_HTONL(x)
grzemich 0:d7bd7384a37c 119
grzemich 0:d7bd7384a37c 120 #endif /* BYTE_ORDER == BIG_ENDIAN */
grzemich 0:d7bd7384a37c 121
grzemich 0:d7bd7384a37c 122 #ifdef __cplusplus
grzemich 0:d7bd7384a37c 123 }
grzemich 0:d7bd7384a37c 124 #endif
grzemich 0:d7bd7384a37c 125
grzemich 0:d7bd7384a37c 126 #endif /* __LWIP_DEF_H__ */
grzemich 0:d7bd7384a37c 127