mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Add Cosmopolitan to uname()
This commit is contained in:
parent
ed316491ca
commit
3ffc17c50e
9 changed files with 56 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int sigwait(const sigset_t *, int *);
|
||||
int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
|
||||
int sigwaitinfo(const sigset_t *, siginfo_t *);
|
||||
|
||||
|
|
26
libc/calls/sigwait.c
Normal file
26
libc/calls/sigwait.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/sigtimedwait.h"
|
||||
|
||||
int sigwait(const sigset_t *mask, int *sig) {
|
||||
siginfo_t si;
|
||||
if (sigtimedwait(mask, &si, 0) < 0) return -1;
|
||||
*sig = si.si_signo;
|
||||
return 0;
|
||||
}
|
|
@ -145,12 +145,12 @@ int uname(struct utsname *uts) {
|
|||
} else if (IsLinux()) {
|
||||
struct utsname_linux linux;
|
||||
if (!(rc = sys_uname_linux(&linux))) {
|
||||
stpcpy(uts->sysname, linux.sysname);
|
||||
stpcpy(uts->nodename, linux.nodename);
|
||||
stpcpy(uts->release, linux.release);
|
||||
stpcpy(uts->version, linux.version);
|
||||
stpcpy(uts->machine, linux.machine);
|
||||
stpcpy(uts->domainname, linux.domainname);
|
||||
strlcpy(uts->sysname, linux.sysname, SYS_NMLN);
|
||||
strlcpy(uts->nodename, linux.nodename, SYS_NMLN);
|
||||
strlcpy(uts->release, linux.release, SYS_NMLN);
|
||||
strlcpy(uts->version, linux.version, SYS_NMLN);
|
||||
strlcpy(uts->machine, linux.machine, SYS_NMLN);
|
||||
strlcpy(uts->domainname, linux.domainname, SYS_NMLN);
|
||||
if (!strcmp(uts->domainname, "(none)")) {
|
||||
uts->domainname[0] = 0;
|
||||
}
|
||||
|
@ -166,7 +166,6 @@ int uname(struct utsname *uts) {
|
|||
} else if (IsWindows()) {
|
||||
stpcpy(uts->sysname, "Windows");
|
||||
stpcpy(uts->machine, "x86_64");
|
||||
GetNtVersion(stpcpy(uts->version, "Windows "));
|
||||
GetNtVersion(uts->release);
|
||||
GetNtName(uts->nodename, kNtComputerNamePhysicalDnsHostname);
|
||||
GetNtName(uts->domainname, kNtComputerNamePhysicalDnsDomain);
|
||||
|
@ -174,6 +173,18 @@ int uname(struct utsname *uts) {
|
|||
} else {
|
||||
rc = enosys();
|
||||
}
|
||||
if (!rc) {
|
||||
char buf[SYS_NMLN];
|
||||
stpcpy(buf, "Cosmopolitan 3.0-alpha");
|
||||
if (*MODE) {
|
||||
strlcat(buf, " MODE=" MODE, SYS_NMLN);
|
||||
}
|
||||
if (*uts->version) {
|
||||
strlcat(buf, "; ", SYS_NMLN);
|
||||
strlcat(buf, uts->version, SYS_NMLN);
|
||||
}
|
||||
strlcpy(uts->version, buf, SYS_NMLN);
|
||||
}
|
||||
STRACE("uname([{%#s, %#s, %#s, %#s, %#s, %#s}]) → %d% m",
|
||||
Str(rc, uts->sysname), Str(rc, uts->nodename), Str(rc, uts->release),
|
||||
Str(rc, uts->version), Str(rc, uts->machine), Str(rc, uts->domainname),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue