Misc.hx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. // TODO Windows only?
  37. public static function getuid() : Int;
  38. public static function setuid(from : Int, to : Int) : String;
  39. public static function getgid() : Int;
  40. public static function setgid(from : Int, to : Int) : Void;
  41. public static function getrusage() : ResourceUsage;
  42. public static function guess_handle(handle : Int) : String;
  43. public static function hrtime() : Float;
  44. // TODO: implement this
  45. // public static function interface_addresses() : String;
  46. public static function loadavg() : Float;
  47. public static function resident_set_memory() : Int;
  48. public static function set_process_title(title : String) : Bool;
  49. public static function uptime() : Int;
  50. public static function version() : Int;
  51. public static function version_string() : String;
  52. // TODO : Windows only
  53. public static function print_all_handles() : Table<Int,String>;
  54. public static function print_active_handles() : Table<Int,String>;
  55. }
  56. typedef CpuInfo = {
  57. model : String,
  58. times : CpuTimes,
  59. speed : Int
  60. }
  61. typedef CpuTimes = {
  62. sys : Int,
  63. idle : Int,
  64. irq : Int,
  65. user : Int
  66. }
  67. typedef ResourceUsage = {
  68. nivcsw : Int,
  69. maxrss : Int,
  70. msgrcv : Int,
  71. isrss : Int,
  72. inblock : Int,
  73. ixrss : Int,
  74. nvcsw : Int,
  75. nsignals : Int,
  76. minflt : Int,
  77. nswap : Int,
  78. msgsnd : Int,
  79. oublock : Int,
  80. majflt : Int,
  81. stime : MicroTimeStamp,
  82. idrss : Int,
  83. utime : MicroTimeStamp
  84. }
  85. typedef MicroTimeStamp = {
  86. usec : Int,
  87. sec : Int
  88. }