2
0

Misc.hx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package lua.lib.luv;
  23. @:luaRequire("luv")
  24. extern class Misc {
  25. static function chdir(path:String):Bool;
  26. static function cpu_info():Table<Int, CpuInfo>;
  27. static function cwd():String;
  28. static function exepath():String;
  29. static function get_process_title():String;
  30. static function get_total_memory():Int;
  31. static function get_free_memory():Int;
  32. static function getpid():Int;
  33. static function getrusage():ResourceUsage;
  34. static function guess_handle(handle:Int):String;
  35. static function hrtime():Float;
  36. static function gettimeofday() : TimeOfDay;
  37. // TODO: implement this
  38. static function interface_addresses() : Dynamic;
  39. static function loadavg():Float;
  40. static function resident_set_memory():Int;
  41. static function set_process_title(title:String):Bool;
  42. static function uptime():Int;
  43. static function version():Int;
  44. static function version_string():String;
  45. // Windows only
  46. static function getuid():Int;
  47. static function setuid(from:Int, to:Int):String;
  48. static function getgid():Int;
  49. static function setgid(from:Int, to:Int):Void;
  50. // Windows only
  51. static function print_all_handles():Table<Int, String>;
  52. static function print_active_handles():Table<Int, String>;
  53. }
  54. typedef CpuInfo = {
  55. model:String,
  56. times:CpuTimes,
  57. speed:Int
  58. }
  59. typedef CpuTimes = {
  60. sys:Int,
  61. idle:Int,
  62. irq:Int,
  63. user:Int
  64. }
  65. typedef ResourceUsage = {
  66. nivcsw:Int,
  67. maxrss:Int,
  68. msgrcv:Int,
  69. isrss:Int,
  70. inblock:Int,
  71. ixrss:Int,
  72. nvcsw:Int,
  73. nsignals:Int,
  74. minflt:Int,
  75. nswap:Int,
  76. msgsnd:Int,
  77. oublock:Int,
  78. majflt:Int,
  79. stime:MicroTimeStamp,
  80. idrss:Int,
  81. utime:MicroTimeStamp
  82. }
  83. typedef MicroTimeStamp = {
  84. usec:Int,
  85. sec:Int
  86. }
  87. @:multiReturn
  88. extern class TimeOfDay {
  89. var seconds : Int;
  90. var microseconds : Int;
  91. }