Platform.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. htop - unsupported/Platform.c
  3. (C) 2014 Hisham H. Muhammad
  4. (C) 2015 David C. Hunt
  5. Released under the GNU GPLv2+, see the COPYING file
  6. in the source distribution for its full text.
  7. */
  8. #include "config.h" // IWYU pragma: keep
  9. #include "unsupported/Platform.h"
  10. #include <math.h>
  11. #include "CPUMeter.h"
  12. #include "ClockMeter.h"
  13. #include "DateMeter.h"
  14. #include "DateTimeMeter.h"
  15. #include "FileDescriptorMeter.h"
  16. #include "HostnameMeter.h"
  17. #include "LoadAverageMeter.h"
  18. #include "Macros.h"
  19. #include "MemoryMeter.h"
  20. #include "MemorySwapMeter.h"
  21. #include "SwapMeter.h"
  22. #include "SysArchMeter.h"
  23. #include "TasksMeter.h"
  24. #include "UptimeMeter.h"
  25. const ScreenDefaults Platform_defaultScreens[] = {
  26. {
  27. .name = "Main",
  28. .columns = "PID USER PRIORITY NICE M_VIRT M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
  29. .sortKey = "PERCENT_CPU",
  30. },
  31. };
  32. const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens);
  33. const SignalItem Platform_signals[] = {
  34. { .name = " 0 Cancel", .number = 0 },
  35. };
  36. const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
  37. const MeterClass* const Platform_meterTypes[] = {
  38. &CPUMeter_class,
  39. &ClockMeter_class,
  40. &DateMeter_class,
  41. &DateTimeMeter_class,
  42. &LoadAverageMeter_class,
  43. &LoadMeter_class,
  44. &MemoryMeter_class,
  45. &SwapMeter_class,
  46. &MemorySwapMeter_class,
  47. &TasksMeter_class,
  48. &BatteryMeter_class,
  49. &HostnameMeter_class,
  50. &SysArchMeter_class,
  51. &UptimeMeter_class,
  52. &AllCPUsMeter_class,
  53. &AllCPUs2Meter_class,
  54. &AllCPUs4Meter_class,
  55. &AllCPUs8Meter_class,
  56. &LeftCPUsMeter_class,
  57. &RightCPUsMeter_class,
  58. &LeftCPUs2Meter_class,
  59. &RightCPUs2Meter_class,
  60. &LeftCPUs4Meter_class,
  61. &RightCPUs4Meter_class,
  62. &LeftCPUs8Meter_class,
  63. &RightCPUs8Meter_class,
  64. &FileDescriptorMeter_class,
  65. &BlankMeter_class,
  66. NULL
  67. };
  68. static const char Platform_unsupported[] = "unsupported";
  69. bool Platform_init(void) {
  70. /* no platform-specific setup needed */
  71. return true;
  72. }
  73. void Platform_done(void) {
  74. /* no platform-specific cleanup needed */
  75. }
  76. void Platform_setBindings(Htop_Action* keys) {
  77. /* no platform-specific key bindings */
  78. (void) keys;
  79. }
  80. int Platform_getUptime(void) {
  81. return 0;
  82. }
  83. void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
  84. *one = 0;
  85. *five = 0;
  86. *fifteen = 0;
  87. }
  88. pid_t Platform_getMaxPid(void) {
  89. return INT_MAX;
  90. }
  91. double Platform_setCPUValues(Meter* this, unsigned int cpu) {
  92. (void) cpu;
  93. double* v = this->values;
  94. v[CPU_METER_FREQUENCY] = NAN;
  95. v[CPU_METER_TEMPERATURE] = NAN;
  96. this->curItems = 1;
  97. return 0.0;
  98. }
  99. void Platform_setMemoryValues(Meter* this) {
  100. (void) this;
  101. }
  102. void Platform_setSwapValues(Meter* this) {
  103. (void) this;
  104. }
  105. char* Platform_getProcessEnv(pid_t pid) {
  106. (void) pid;
  107. return NULL;
  108. }
  109. FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) {
  110. (void)pid;
  111. return NULL;
  112. }
  113. void Platform_getFileDescriptors(double* used, double* max) {
  114. *used = 1337;
  115. *max = 4711;
  116. }
  117. bool Platform_getDiskIO(DiskIOData* data) {
  118. (void)data;
  119. return false;
  120. }
  121. bool Platform_getNetworkIO(NetworkIOData* data) {
  122. (void)data;
  123. return false;
  124. }
  125. void Platform_getBattery(double* percent, ACPresence* isOnAC) {
  126. *percent = NAN;
  127. *isOnAC = AC_ERROR;
  128. }
  129. void Platform_getHostname(char* buffer, size_t size) {
  130. String_safeStrncpy(buffer, Platform_unsupported, size);
  131. }
  132. void Platform_getRelease(char** string) {
  133. *string = xStrdup(Platform_unsupported);
  134. }