cc.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @file cc.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef LWIP_CUSTOM_CC_H
  23. #define LWIP_CUSTOM_CC_H
  24. #include <inttypes.h>
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <errno.h>
  28. #include <misc/debug.h>
  29. #include <misc/byteorder.h>
  30. #include <base/BLog.h>
  31. #define u8_t uint8_t
  32. #define s8_t int8_t
  33. #define u16_t uint16_t
  34. #define s16_t int16_t
  35. #define u32_t uint32_t
  36. #define s32_t int32_t
  37. #define mem_ptr_t uintptr_t
  38. #define PACK_STRUCT_STRUCT __attribute__((packed))
  39. #define LWIP_PLATFORM_DIAG(x) { BLog_Append x; BLog_Finish(BLOG_CHANNEL_lwip, BLOG_INFO); }
  40. #define LWIP_PLATFORM_ASSERT(x) { fprintf(stderr, "%s: lwip assertion failure: %s\n", __FUNCTION__, (x)); abort(); }
  41. #define U16_F PRIu16
  42. #define S16_F PRId16
  43. #define X16_F PRIx16
  44. #define U32_F PRIu32
  45. #define S32_F PRId32
  46. #define X32_F PRIx32
  47. #define SZT_F "zu"
  48. #define LWIP_PLATFORM_BYTESWAP 1
  49. #define LWIP_PLATFORM_HTONS(x) hton16(x)
  50. #define LWIP_PLATFORM_HTONL(x) hton32(x)
  51. // for BYTE_ORDER
  52. #ifdef BADVPN_USE_WINAPI
  53. #include <sys/param.h>
  54. #endif
  55. #ifdef BADVPN_LINUX
  56. #include <endian.h>
  57. #endif
  58. #ifdef BADVPN_FREEBSD
  59. #include <machine/endian.h>
  60. #endif
  61. #endif