HostInfo.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //===-- HostInfo.h ----------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLDB_HOST_HOSTINFO_H
  9. #define LLDB_HOST_HOSTINFO_H
  10. /// \class HostInfo HostInfo.h "lldb/Host/HostInfo.h"
  11. /// A class that provides host computer information.
  12. ///
  13. /// HostInfo is a class that answers information about the host operating
  14. /// system. Note that HostInfo is NOT intended to be used to manipulate or
  15. /// control the operating system.
  16. ///
  17. /// HostInfo is implemented in an OS-specific class (for example
  18. /// HostInfoWindows) in a separate file, and then typedefed to HostInfo here.
  19. /// Users of the class reference it as HostInfo::method().
  20. ///
  21. /// Not all hosts provide the same functionality. It is important that
  22. /// methods only be implemented at the lowest level at which they make sense.
  23. /// It should be up to the clients of the class to ensure that they not
  24. /// attempt to call a method which doesn't make sense for a particular
  25. /// platform. For example, when implementing a method that only makes sense
  26. /// on a posix-compliant system, implement it on HostInfoPosix, and not on
  27. /// HostInfoBase with a default implementation. This way, users of HostInfo
  28. /// are required to think about the implications of calling a particular
  29. /// method and if used in a context where the method doesn't make sense, will
  30. /// generate a compiler error.
  31. ///
  32. #if defined(_WIN32)
  33. #include "lldb/Host/windows/HostInfoWindows.h"
  34. #define HOST_INFO_TYPE HostInfoWindows
  35. #elif defined(__linux__) || defined(__EMSCRIPTEN__)
  36. #if defined(__ANDROID__)
  37. #include "lldb/Host/android/HostInfoAndroid.h"
  38. #define HOST_INFO_TYPE HostInfoAndroid
  39. #else
  40. #include "lldb/Host/linux/HostInfoLinux.h"
  41. #define HOST_INFO_TYPE HostInfoLinux
  42. #endif
  43. #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  44. #include "lldb/Host/freebsd/HostInfoFreeBSD.h"
  45. #define HOST_INFO_TYPE HostInfoFreeBSD
  46. #elif defined(__NetBSD__)
  47. #include "lldb/Host/netbsd/HostInfoNetBSD.h"
  48. #define HOST_INFO_TYPE HostInfoNetBSD
  49. #elif defined(__OpenBSD__)
  50. #include "lldb/Host/openbsd/HostInfoOpenBSD.h"
  51. #define HOST_INFO_TYPE HostInfoOpenBSD
  52. #elif defined(__APPLE__)
  53. #include "lldb/Host/macosx/HostInfoMacOSX.h"
  54. #define HOST_INFO_TYPE HostInfoMacOSX
  55. #else
  56. #include "lldb/Host/posix/HostInfoPosix.h"
  57. #define HOST_INFO_TYPE HostInfoPosix
  58. #endif
  59. namespace lldb_private {
  60. typedef HOST_INFO_TYPE HostInfo;
  61. }
  62. #undef HOST_INFO_TYPE
  63. #endif