Browse Source

added sys_string/sys_is64

Nicolas Cannasse 8 years ago
parent
commit
dc4d6d2ff6
1 changed files with 25 additions and 0 deletions
  1. 25 0
      src/generators/hlinterp.ml

+ 25 - 0
src/generators/hlinterp.ml

@@ -1496,6 +1496,31 @@ let load_native ctx lib name t =
 			(function
 			| [] -> VBool true
 			| _ -> assert false)
+		| "sys_string" ->
+			let cached_sys_name = ref None in
+			(function
+			| [] ->
+				VBytes (caml_to_hl (match Sys.os_type with
+				| "Unix" ->
+					(match !cached_sys_name with
+					| Some n -> n
+					| None ->
+						let ic = Unix.open_process_in "uname" in
+						let uname = (match input_line ic with
+							| "Darwin" -> "Mac"
+							| n -> n
+						) in
+						close_in ic;
+						cached_sys_name := Some uname;
+						uname)
+				| "Win32" | "Cygwin" -> "Windows"
+				| s -> s))
+			| _ ->
+				assert false)
+		| "sys_is64" ->
+			(function
+			| [] -> VBool (Sys.word_size = 64)
+			| _ -> assert false)
 		| "hash" ->
 			(function
 			| [VBytes str] -> VInt (hash ctx (hl_to_caml str))