Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Printf.printf "%d\n" Sys.word_size; (* Print word size *)
Printf.printf "%s\n" Sys.os_type; (* Print operating system *)

View file

@ -0,0 +1,2 @@
(* Print endianness *)
Printf.printf "%s\n" (if Sys.big_endian then "big endian" else "little endian");

View file

@ -0,0 +1,8 @@
let uname arg =
let arg = if arg = "" then "-" else arg in
let ic = Unix.open_process_in ("uname -" ^ arg) in
(input_line ic)
;;
# uname "sm";;
- : string = "Linux i686"

View file

@ -0,0 +1,34 @@
(* Reading all the lines from a file.
If the loop is implemented by a recursive auxiliary function, the try...with breaks
tail recursion if not written carefully *)
let lines name =
let f = open_in name
and r = ref []
in
(try
while true do
r := (input_line f)::!r
done
with End_of_file -> close_in f);
(List.rev !r)
;;
# lines "/proc/meminfo";;
- : string list =
["MemTotal: 2075240 kB"; "MemFree: 469964 kB";
"Buffers: 34512 kB"; "Cached: 1296380 kB";
"SwapCached: 96 kB"; "Active: 317484 kB";
"Inactive: 1233500 kB"; "HighTotal: 1178432 kB";
"HighFree: 45508 kB"; "LowTotal: 896808 kB";
"LowFree: 424456 kB"; "SwapTotal: 2650684 kB";
"SwapFree: 2650588 kB"; "Dirty: 228 kB";
"Writeback: 0 kB"; "AnonPages: 220036 kB";
"Mapped: 67160 kB"; "Slab: 41540 kB";
"SReclaimable: 34872 kB"; "SUnreclaim: 6668 kB";
"PageTables: 1880 kB"; "NFS_Unstable: 0 kB";
"Bounce: 0 kB"; "WritebackTmp: 0 kB";
"CommitLimit: 3688304 kB"; "Committed_AS: 549912 kB";
"VmallocTotal: 114680 kB"; "VmallocUsed: 5172 kB";
"VmallocChunk: 109320 kB"; "HugePages_Total: 0";
"HugePages_Free: 0"; "HugePages_Rsvd: 0";
"HugePages_Surp: 0"; "Hugepagesize: 4096 kB"]