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.
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 #ifndef LWIP_HDR_DEF_H 00038 #define LWIP_HDR_DEF_H 00039 00040 /* arch.h might define NULL already */ 00041 #include "lwip/arch.h" 00042 #include "lwip/opt.h" 00043 #if LWIP_PERF 00044 #include "arch/perf.h" 00045 #else /* LWIP_PERF */ 00046 #define PERF_START /* null definition */ 00047 #define PERF_STOP(x) /* null definition */ 00048 #endif /* LWIP_PERF */ 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 00055 #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 00056 00057 /* Get the number of entries in an array ('x' must NOT be a pointer!) */ 00058 #define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) 00059 00060 /** Create u32_t value from bytes */ 00061 #define LWIP_MAKEU32(a,b,c,d) (((u32_t)((a) & 0xff) << 24) | \ 00062 ((u32_t)((b) & 0xff) << 16) | \ 00063 ((u32_t)((c) & 0xff) << 8) | \ 00064 (u32_t)((d) & 0xff)) 00065 00066 #ifndef NULL 00067 #ifdef __cplusplus 00068 #define NULL 0 00069 #else 00070 #define NULL ((void *)0) 00071 #endif 00072 #endif 00073 00074 #if BYTE_ORDER == BIG_ENDIAN 00075 #define lwip_htons(x) (x) 00076 #define lwip_ntohs(x) (x) 00077 #define lwip_htonl(x) (x) 00078 #define lwip_ntohl(x) (x) 00079 #define PP_HTONS(x) (x) 00080 #define PP_NTOHS(x) (x) 00081 #define PP_HTONL(x) (x) 00082 #define PP_NTOHL(x) (x) 00083 #else /* BYTE_ORDER != BIG_ENDIAN */ 00084 #ifndef lwip_htons 00085 u16_t lwip_htons(u16_t x); 00086 #endif 00087 #define lwip_ntohs(x) lwip_htons(x) 00088 00089 #ifndef lwip_htonl 00090 u32_t lwip_htonl(u32_t x); 00091 #endif 00092 #define lwip_ntohl(x) lwip_htonl(x) 00093 00094 /* Provide usual function names as macros for users, but this can be turned off */ 00095 #ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 00096 #define htons(x) lwip_htons(x) 00097 #define ntohs(x) lwip_ntohs(x) 00098 #define htonl(x) lwip_htonl(x) 00099 #define ntohl(x) lwip_ntohl(x) 00100 #endif 00101 00102 /* These macros should be calculated by the preprocessor and are used 00103 with compile-time constants only (so that there is no little-endian 00104 overhead at runtime). */ 00105 #define PP_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8)) 00106 #define PP_NTOHS(x) PP_HTONS(x) 00107 #define PP_HTONL(x) ((((x) & 0x000000ffUL) << 24) | \ 00108 (((x) & 0x0000ff00UL) << 8) | \ 00109 (((x) & 0x00ff0000UL) >> 8) | \ 00110 (((x) & 0xff000000UL) >> 24)) 00111 #define PP_NTOHL(x) PP_HTONL(x) 00112 00113 #endif /* BYTE_ORDER == BIG_ENDIAN */ 00114 00115 /* Functions that are not available as standard implementations. 00116 * In cc.h, you can #define these to implementations available on 00117 * your platform to save some code bytes if you use these functions 00118 * in your application, too. 00119 */ 00120 00121 #ifndef lwip_itoa 00122 /* This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform */ 00123 void lwip_itoa(char* result, size_t bufsize, int number); 00124 #endif 00125 #ifndef lwip_strnicmp 00126 /* This can be #defined to strnicmp() or strncasecmp() depending on your platform */ 00127 int lwip_strnicmp(const char* str1, const char* str2, size_t len); 00128 #endif 00129 #ifndef lwip_stricmp 00130 /* This can be #defined to stricmp() or strcasecmp() depending on your platform */ 00131 int lwip_stricmp(const char* str1, const char* str2); 00132 #endif 00133 #ifndef lwip_strnstr 00134 /* This can be #defined to strnstr() depending on your platform */ 00135 char* lwip_strnstr(const char* buffer, const char* token, size_t n); 00136 #endif 00137 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 00142 #endif /* LWIP_HDR_DEF_H */
Generated on Tue Jul 12 2022 12:43:48 by
