Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-01-24 14:01:01 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-01-26 20:37:25 +0300
commit84230b71c64765ad0e34faffdfe6d1c58477a84d (patch)
tree7d81d3736e86804de21aa9bf40e8b3fe4557f1ee
parent6ffcc50f192b75971b88d5e5bdffdeec945153a8 (diff)
Cygwin: uname: Raise size of utsname fields and revamp uname(2) output
New format: sysname: CYGWIN_NT-${osversion}-${os_build_number}[-WOW64] nodename: `gethostname` release: ${cygwin_version}-${API minor}.${arch}[.snap] version: YYYY-MM-DD HH:MM UTC machine: ${arch} _GNU_SOURCE: domainname: `getdomainname` !_GNU_SOURCE: __domainname: `getdomainname` Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/Makefile.in1
-rw-r--r--winsup/cygwin/common.din1
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/sys/utsname.h17
-rw-r--r--winsup/cygwin/release/2.12.02
-rw-r--r--winsup/cygwin/uname.cc70
-rw-r--r--winsup/cygwin/wincap.h1
-rw-r--r--winsup/doc/new-features.xml4
8 files changed, 92 insertions, 7 deletions
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 32c02b87b..ecdabb003 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -440,6 +440,7 @@ GMON_OFILES:=gmon.o mcount.o profil.o mcountFunc.o
NEW_FUNCTIONS:=$(addprefix --replace=,\
atexit= \
timezone= \
+ uname=uname_x \
__xdrrec_getrec= \
__xdrrec_setnonblock= \
xdr_array= \
diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index ca819c63e..f620d8183 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
@@ -1522,6 +1522,7 @@ ualarm SIGFE
umask NOSIGFE
umount SIGFE
uname SIGFE
+uname_x SIGFE
ungetc SIGFE
ungetwc SIGFE
unlink SIGFE
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index c3e971ed8..478d080f5 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -505,12 +505,13 @@ details. */
332: Add signalfd.
333: Add timerfd_create, timerfd_gettime, timerfd_settime.
334: Remove matherr.
+ 335: Change size of utsname, change uname output.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 334
+#define CYGWIN_VERSION_API_MINOR 335
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/include/sys/utsname.h b/winsup/cygwin/include/sys/utsname.h
index e9dd019df..d6b3be96f 100644
--- a/winsup/cygwin/include/sys/utsname.h
+++ b/winsup/cygwin/include/sys/utsname.h
@@ -13,13 +13,20 @@ details. */
extern "C" {
#endif
+#define _UTSNAME_LENGTH 65
+
struct utsname
{
- char sysname[20];
- char nodename[20];
- char release[20];
- char version[20];
- char machine[20];
+ char sysname[_UTSNAME_LENGTH];
+ char nodename[_UTSNAME_LENGTH];
+ char release[_UTSNAME_LENGTH];
+ char version[_UTSNAME_LENGTH];
+ char machine[_UTSNAME_LENGTH];
+#if __GNU_VISIBLE
+ char domainname[_UTSNAME_LENGTH];
+#else
+ char __domainname[_UTSNAME_LENGTH];
+#endif
};
int uname (struct utsname *);
diff --git a/winsup/cygwin/release/2.12.0 b/winsup/cygwin/release/2.12.0
index c2abc9329..19e05565a 100644
--- a/winsup/cygwin/release/2.12.0
+++ b/winsup/cygwin/release/2.12.0
@@ -56,6 +56,8 @@ What changed:
- Remove matherr, and SVID and X/Open math library configurations.
Default math library configuration is now IEEE.
+- Improve uname(2) for newly built applications.
+
Bug Fixes
---------
diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index 778ca5738..306cdee4a 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -10,15 +10,83 @@ details. */
#include "winsup.h"
#include <sys/utsname.h>
+#include <netdb.h>
#include "cygwin_version.h"
#include "cygtls.h"
extern "C" int cygwin_gethostname (char *__name, size_t __len);
+extern "C" int getdomainname (char *__name, size_t __len);
/* uname: POSIX 4.4.1.1 */
+
+/* New entrypoint for applications since API 335 */
+extern "C" int
+uname_x (struct utsname *name)
+{
+ __try
+ {
+ char buf[NI_MAXHOST + 1];
+ char *snp = strstr (cygwin_version.dll_build_date, "SNP");
+
+ memset (name, 0, sizeof (*name));
+ /* sysname */
+ __small_sprintf (name->sysname, "CYGWIN_%s-%u%s",
+ wincap.osname (), wincap.build_number (),
+ wincap.is_wow64 () ? "-WOW64" : "");
+ /* nodename */
+ memset (buf, 0, sizeof buf);
+ cygwin_gethostname (buf, sizeof buf - 1);
+ strncat (name->nodename, buf, sizeof (name->nodename) - 1);
+ /* release */
+ __small_sprintf (name->release, "%d.%d.%d-%d.",
+ cygwin_version.dll_major / 1000,
+ cygwin_version.dll_major % 1000,
+ cygwin_version.dll_minor,
+ cygwin_version.api_minor);
+ /* version */
+ stpcpy (name->version, cygwin_version.dll_build_date);
+ if (snp)
+ name->version[snp - cygwin_version.dll_build_date] = '\0';
+ strcat (name->version, " UTC");
+ /* machine */
+ switch (wincap.cpu_arch ())
+ {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ strcat (name->release, strcpy (name->machine, "i686"));
+ break;
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ strcat (name->release, strcpy (name->machine, "x86_64"));
+ break;
+ default:
+ strcpy (name->machine, "unknown");
+ break;
+ }
+ if (snp)
+ strcat (name->release, ".snap");
+ /* domainame */
+ memset (buf, 0, sizeof buf);
+ getdomainname (buf, sizeof buf - 1);
+ strncat (name->domainname, buf, sizeof (name->domainname) - 1);
+ }
+ __except (EFAULT) { return -1; }
+ __endtry
+ return 0;
+}
+
+/* Old entrypoint for applications up to API 334 */
+struct old_utsname
+{
+ char sysname[20];
+ char nodename[20];
+ char release[20];
+ char version[20];
+ char machine[20];
+};
+
extern "C" int
-uname (struct utsname *name)
+uname (struct utsname *in_name)
{
+ struct old_utsname *name = (struct old_utsname *) in_name;
__try
{
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index d89fd71b4..f8846f91d 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -59,6 +59,7 @@ public:
const size_t allocation_granularity () const
{ return (size_t) system_info.dwAllocationGranularity; }
const char *osname () const { return osnam; }
+ const DWORD build_number () const { return version.dwBuildNumber; }
const bool is_wow64 () const { return !!wow64; }
#define IMPLEMENT(cap) cap() const { return ((wincaps *) this->caps)->cap; }
diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml
index 59db9c98a..ae5088d27 100644
--- a/winsup/doc/new-features.xml
+++ b/winsup/doc/new-features.xml
@@ -91,6 +91,10 @@ Remove matherr, and SVID and X/Open math library configurations.
Default math library configuration is now IEEE.
<listitem><para>
+</para></listitem>
+Improve uname(2) for newly built applications.
+</para></listitem>
+
</itemizedlist>
</sect2>