1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: properly document os.uname, for both nix and windows

This commit is contained in:
Delyan Angelov 2023-01-22 13:18:28 +02:00
parent dd55365dee
commit f69b994c73
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 23 additions and 6 deletions

View File

@ -206,6 +206,22 @@ pub fn utime(path string, actime int, modtime int) ! {
}
}
// uname returns information about the platform on which the program is running
// For example:
// os.Uname{
// sysname: 'Linux'
// nodename: 'nemesis'
// release: '5.15.0-57-generic'
// version: '#63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022'
// machine: 'x86_64'
// }
// where the fields have the following meaning:
// sysname is the name of this implementation of the operating system
// nodename is the name of this node within an implementation-dependent communications network
// release is the current release level of this implementation
// version is the current version level of this release
// machine is the name of the hardware type, on which the system is running
// See also https://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
pub fn uname() Uname {
mut u := Uname{}
utsize := sizeof(C.utsname)

View File

@ -458,12 +458,13 @@ pub fn debugger_present() bool {
return C.IsDebuggerPresent()
}
// `uname` is not standardized, so mimic current practices
// busybox-v1.35.0 * `busybox uname -a` => "Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows"
// rust/coreutils-v0.0.17 * `coreutils uname -a` => `Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows (Windows 10)`
// Python3 => `uname_result(system='Windows', node='HOSTNAME', release='10', version='10.0.19044', machine='AMD64')`
// ref: [NT Version Info](https://en.wikipedia.org/wiki/Windows_NT) @@ <https://archive.is/GnnvF>
// ref: [NT Version Info (detailed)](https://en.wikipedia.org/wiki/Comparison_of_Microsoft_Windows_versions#NT_Kernel-based_2)
// uname returns information about the platform on which the program is running.
// Currently `uname` on windows is not standardized, so it just mimics current practices from other popular software/language implementations:
// busybox-v1.35.0 * `busybox uname -a` => "Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows"
// rust/coreutils-v0.0.17 * `coreutils uname -a` => `Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows (Windows 10)`
// Python3 => `uname_result(system='Windows', node='HOSTNAME', release='10', version='10.0.19044', machine='AMD64')`
// See: [NT Version Info](https://en.wikipedia.org/wiki/Windows_NT) @@ <https://archive.is/GnnvF>
// and: [NT Version Info (detailed)](https://en.wikipedia.org/wiki/Comparison_of_Microsoft_Windows_versions#NT_Kernel-based_2)
pub fn uname() Uname {
nodename := hostname()
// ToDO: environment variables have low reliability; check for another quick way