osplatformutil.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @file osplatformutil.h
  3. * @author itas109 (itas109@qq.com) \n\n
  4. * Blog : https://blog.csdn.net/itas109 \n
  5. * Github : https://github.com/itas109 \n
  6. * QQ Group : 12951803
  7. * @brief os platform util 操作系统平台工具
  8. * @copyright The CSerialPort is Copyright (C) 2021 itas109. \n
  9. * Contact: itas109@qq.com \n\n
  10. * You may use, distribute and copy the CSerialPort under the terms of \n
  11. * GNU Lesser General Public License version 3, which is displayed below.
  12. */
  13. #ifndef OSPLATFORMUTIL_H
  14. #define OSPLATFORMUTIL_H
  15. /*
  16. The operating system, must be one of: (I_OS_x)
  17. WIN - Win (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
  18. LINUX - Linux
  19. MAC - macOS, iOS, watchOS, tvOS
  20. ANDROID - Android
  21. FREEBSD - FreeBSD
  22. OPENBSD - OpenBSD
  23. SOLARIS - Sun Solaris
  24. AIX - AIX
  25. UNIX - Any UNIX BSD/SYSV system
  26. */
  27. #define OS_PLATFORM_UTIL_VERSION 1.0.1.200418
  28. // os platform
  29. // Windows
  30. #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || \
  31. defined(__WIN64__) || defined(__NT__))
  32. #define I_OS_WIN
  33. // LINUX
  34. #elif defined(__linux__) || defined(__linux)
  35. #define I_OS_LINUX
  36. // MAC
  37. #elif defined(__APPLE__)
  38. #define I_OS_MAC
  39. // ANDROID
  40. #elif defined(__ANDROID__) || defined(ANDROID)
  41. #define I_OS_ANDROID
  42. #define I_OS_LINUX
  43. // sun os
  44. #elif defined(__sun) || defined(sun)
  45. #define I_OS_SOLARIS
  46. // FREEBSD
  47. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
  48. #ifndef __FreeBSD_kernel__
  49. #define I_OS_FREEBSD
  50. #endif
  51. #define I_OS_FREEBSD_KERNEL
  52. // OPENBSD
  53. #elif defined(__OpenBSD__)
  54. #define I_OS_OPENBSD
  55. // IBM AIX
  56. #elif defined(_AIX)
  57. #define I_OS_AIX
  58. #else
  59. #error "not support this OS"
  60. #endif
  61. #define int64 int64_t
  62. #if defined(I_OS_WIN)
  63. #undef I_OS_UNIX
  64. #elif !defined(I_OS_UNIX)
  65. #define I_OS_UNIX
  66. #endif
  67. #endif // OSPLATFORMUTIL_H