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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
def.h
00001 /** 00002 * @file 00003 * various utility macros 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 00038 /** 00039 * @defgroup perf Performance measurement 00040 * @ingroup sys_layer 00041 * All defines related to this section must not be placed in lwipopts.h, 00042 * but in arch/perf.h! 00043 * Measurement calls made throughout lwip, these can be defined to nothing. 00044 * - PERF_START: start measuring something. 00045 * - PERF_STOP(x): stop measuring something, and record the result. 00046 */ 00047 00048 #ifndef LWIP_HDR_DEF_H 00049 #define LWIP_HDR_DEF_H 00050 00051 /* arch.h might define NULL already */ 00052 #include "lwip/arch.h" 00053 #include "lwip/opt.h" 00054 #if LWIP_PERF 00055 #include "arch/perf.h" 00056 #else /* LWIP_PERF */ 00057 #define PERF_START /* null definition */ 00058 #define PERF_STOP(x) /* null definition */ 00059 #endif /* LWIP_PERF */ 00060 00061 #ifdef __cplusplus 00062 extern "C" { 00063 #endif 00064 00065 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 00066 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 00067 00068 /* Get the number of entries in an array ('x' must NOT be a pointer!) */ 00069 #define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) 00070 00071 /** Create u32_t value from bytes */ 00072 #define LWIP_MAKEU32(a,b,c,d) (((u32_t)((a) & 0xff) << 24) | \ 00073 ((u32_t)((b) & 0xff) << 16) | \ 00074 ((u32_t)((c) & 0xff) << 8) | \ 00075 (u32_t)((d) & 0xff)) 00076 00077 #ifndef NULL 00078 #ifdef __cplusplus 00079 #define NULL 0 00080 #else 00081 #define NULL ((void *)0) 00082 #endif 00083 #endif 00084 00085 #if BYTE_ORDER == BIG_ENDIAN 00086 #define lwip_htons(x) ((u16_t)(x)) 00087 #define lwip_ntohs(x) ((u16_t)(x)) 00088 #define lwip_htonl(x) ((u32_t)(x)) 00089 #define lwip_ntohl(x) ((u32_t)(x)) 00090 #define PP_HTONS(x) ((u16_t)(x)) 00091 #define PP_NTOHS(x) ((u16_t)(x)) 00092 #define PP_HTONL(x) ((u32_t)(x)) 00093 #define PP_NTOHL(x) ((u32_t)(x)) 00094 #else /* BYTE_ORDER != BIG_ENDIAN */ 00095 #ifndef lwip_htons 00096 u16_t lwip_htons(u16_t x); 00097 #endif 00098 #define lwip_ntohs(x) lwip_htons(x) 00099 00100 #ifndef lwip_htonl 00101 u32_t lwip_htonl(u32_t x); 00102 #endif 00103 #define lwip_ntohl(x) lwip_htonl(x) 00104 00105 /* These macros should be calculated by the preprocessor and are used 00106 with compile-time constants only (so that there is no little-endian 00107 overhead at runtime). */ 00108 #define PP_HTONS(x) ((u16_t)((((x) & (u16_t)0x00ffU) << 8) | (((x) & (u16_t)0xff00U) >> 8))) 00109 #define PP_NTOHS(x) PP_HTONS(x) 00110 #define PP_HTONL(x) ((((x) & (u32_t)0x000000ffUL) << 24) | \ 00111 (((x) & (u32_t)0x0000ff00UL) << 8) | \ 00112 (((x) & (u32_t)0x00ff0000UL) >> 8) | \ 00113 (((x) & (u32_t)0xff000000UL) >> 24)) 00114 #define PP_NTOHL(x) PP_HTONL(x) 00115 #endif /* BYTE_ORDER == BIG_ENDIAN */ 00116 00117 /* Provide usual function names as macros for users, but this can be turned off */ 00118 #ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 00119 #define htons(x) lwip_htons(x) 00120 #define ntohs(x) lwip_ntohs(x) 00121 #define htonl(x) lwip_htonl(x) 00122 #define ntohl(x) lwip_ntohl(x) 00123 #endif 00124 00125 /* Functions that are not available as standard implementations. 00126 * In cc.h, you can #define these to implementations available on 00127 * your platform to save some code bytes if you use these functions 00128 * in your application, too. 00129 */ 00130 00131 #ifndef lwip_itoa 00132 /* This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform */ 00133 void lwip_itoa(char* result, size_t bufsize, int number); 00134 #endif 00135 #ifndef lwip_strnicmp 00136 /* This can be #defined to strnicmp() or strncasecmp() depending on your platform */ 00137 int lwip_strnicmp(const char* str1, const char* str2, size_t len); 00138 #endif 00139 #ifndef lwip_stricmp 00140 /* This can be #defined to stricmp() or strcasecmp() depending on your platform */ 00141 int lwip_stricmp(const char* str1, const char* str2); 00142 #endif 00143 #ifndef lwip_strnstr 00144 /* This can be #defined to strnstr() depending on your platform */ 00145 char* lwip_strnstr(const char* buffer, const char* token, size_t n); 00146 #endif 00147 00148 #ifdef __cplusplus 00149 } 00150 #endif 00151 00152 #endif /* LWIP_HDR_DEF_H */
Generated on Tue Jul 12 2022 13:54:16 by
1.7.2