Platform.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef HEADER_Platform
  2. #define HEADER_Platform
  3. /*
  4. htop - darwin/Platform.h
  5. (C) 2014 Hisham H. Muhammad
  6. (C) 2015 David C. Hunt
  7. Released under the GNU GPLv2+, see the COPYING file
  8. in the source distribution for its full text.
  9. */
  10. #include <stdbool.h>
  11. #include <sys/types.h>
  12. #include "Action.h"
  13. #include "BatteryMeter.h"
  14. #include "CPUMeter.h"
  15. #include "DiskIOMeter.h"
  16. #include "Hashtable.h"
  17. #include "NetworkIOMeter.h"
  18. #include "ProcessLocksScreen.h"
  19. #include "SignalsPanel.h"
  20. #include "CommandLine.h"
  21. #include "darwin/DarwinProcess.h"
  22. #include "generic/gettime.h"
  23. #include "generic/hostname.h"
  24. #include "generic/uname.h"
  25. extern const ScreenDefaults Platform_defaultScreens[];
  26. extern const unsigned int Platform_numberOfDefaultScreens;
  27. extern const SignalItem Platform_signals[];
  28. extern const unsigned int Platform_numberOfSignals;
  29. extern const MeterClass* const Platform_meterTypes[];
  30. bool Platform_init(void);
  31. // Converts ticks in the Mach "timebase" to nanoseconds.
  32. // See `mach_timebase_info`, as used to define the `Platform_nanosecondsPerMachTick` constant.
  33. uint64_t Platform_machTicksToNanoseconds(uint64_t mach_ticks);
  34. // Converts "scheduler ticks" to nanoseconds.
  35. // See `sysconf(_SC_CLK_TCK)`, as used to define the `Platform_nanosecondsPerSchedulerTick` constant.
  36. double Platform_schedulerTicksToNanoseconds(const double scheduler_ticks);
  37. void Platform_done(void);
  38. void Platform_setBindings(Htop_Action* keys);
  39. int Platform_getUptime(void);
  40. void Platform_getLoadAverage(double* one, double* five, double* fifteen);
  41. pid_t Platform_getMaxPid(void);
  42. double Platform_setCPUValues(Meter* mtr, unsigned int cpu);
  43. void Platform_setMemoryValues(Meter* mtr);
  44. void Platform_setSwapValues(Meter* mtr);
  45. void Platform_setZfsArcValues(Meter* this);
  46. void Platform_setZfsCompressedArcValues(Meter* this);
  47. char* Platform_getProcessEnv(pid_t pid);
  48. FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid);
  49. void Platform_getFileDescriptors(double* used, double* max);
  50. bool Platform_getDiskIO(DiskIOData* data);
  51. bool Platform_getNetworkIO(NetworkIOData* data);
  52. void Platform_getBattery(double* percent, ACPresence* isOnAC);
  53. static inline void Platform_getHostname(char* buffer, size_t size) {
  54. Generic_hostname(buffer, size);
  55. }
  56. static inline void Platform_getRelease(char** string) {
  57. *string = Generic_uname();
  58. }
  59. #define PLATFORM_LONG_OPTIONS
  60. static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
  61. static inline CommandLineStatus Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
  62. return STATUS_ERROR_EXIT;
  63. }
  64. static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) {
  65. Generic_gettime_realtime(tv, msec);
  66. }
  67. void Platform_gettime_monotonic(uint64_t* msec);
  68. static inline Hashtable* Platform_dynamicMeters(void) {
  69. return NULL;
  70. }
  71. static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { }
  72. static inline void Platform_dynamicMeterInit(ATTR_UNUSED Meter* meter) { }
  73. static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { }
  74. static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { }
  75. static inline Hashtable* Platform_dynamicColumns(void) {
  76. return NULL;
  77. }
  78. static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { }
  79. static inline const char* Platform_dynamicColumnName(ATTR_UNUSED unsigned int key) {
  80. return NULL;
  81. }
  82. static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) {
  83. return false;
  84. }
  85. static inline Hashtable* Platform_dynamicScreens(void) {
  86. return NULL;
  87. }
  88. static inline void Platform_defaultDynamicScreens(ATTR_UNUSED Settings* settings) { }
  89. static inline void Platform_addDynamicScreen(ATTR_UNUSED ScreenSettings* ss) { }
  90. static inline void Platform_addDynamicScreenAvailableColumns(ATTR_UNUSED Panel* availableColumns, ATTR_UNUSED const char* screen) { }
  91. static inline void Platform_dynamicScreensDone(ATTR_UNUSED Hashtable* screens) { }
  92. #endif