Misc.hx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C)2005-2018 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. public static function chdir(path : String) : Bool;
  26. public static function os_homedir() : String;
  27. public static function os_tmpdir() : String;
  28. public static function os_get_passwd() : String;
  29. public static function cpu_info() : Table<Int,CpuInfo>;
  30. public static function cwd() : String;
  31. public static function exepath() : String;
  32. public static function get_process_title() : String;
  33. public static function get_total_memory() : Int;
  34. public static function get_free_memory() : Int;
  35. public static function getpid() : Int;
  36. public static function os_getenv(env : String) : String;
  37. public static function os_setenv(env : String, value : String) : Void;
  38. // TODO Windows only?
  39. public static function getuid() : Int;
  40. public static function setuid(from : Int, to : Int) : String;
  41. public static function getgid() : Int;
  42. public static function setgid(from : Int, to : Int) : Void;
  43. public static function getrusage() : ResourceUsage;
  44. public static function guess_handle(handle : Int) : String;
  45. public static function hrtime() : Float;
  46. // TODO: implement this
  47. // public static function interface_addresses() : String;
  48. public static function loadavg() : Float;
  49. public static function resident_set_memory() : Int;
  50. public static function set_process_title(title : String) : Bool;
  51. public static function uptime() : Int;
  52. public static function version() : Int;
  53. public static function version_string() : String;
  54. // TODO : Windows only
  55. public static function print_all_handles() : Table<Int,String>;
  56. public static function print_active_handles() : Table<Int,String>;
  57. }
  58. typedef CpuInfo = {
  59. model : String,
  60. times : CpuTimes,
  61. speed : Int
  62. }
  63. typedef CpuTimes = {
  64. sys : Int,
  65. idle : Int,
  66. irq : Int,
  67. user : Int
  68. }
  69. typedef ResourceUsage = {
  70. nivcsw : Int,
  71. maxrss : Int,
  72. msgrcv : Int,
  73. isrss : Int,
  74. inblock : Int,
  75. ixrss : Int,
  76. nvcsw : Int,
  77. nsignals : Int,
  78. minflt : Int,
  79. nswap : Int,
  80. msgsnd : Int,
  81. oublock : Int,
  82. majflt : Int,
  83. stime : MicroTimeStamp,
  84. idrss : Int,
  85. utime : MicroTimeStamp
  86. }
  87. typedef MicroTimeStamp = {
  88. usec : Int,
  89. sec : Int
  90. }