2 Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com
3 Rewritten by Geoffrey Noer of Cygnus Solutions, noer@cygnus.com
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
13 #include <sys/utsname.h>
15 #include "cygwin_version.h"
18 extern "C" int cygwin_gethostname (char *__name
, size_t __len
);
19 extern "C" int getdomainname (char *__name
, size_t __len
);
22 #define ATTRIBUTE_NONSTRING __attribute__ ((nonstring))
24 #define ATTRIBUTE_NONSTRING
27 /* uname: POSIX 4.4.1.1 */
29 /* New entrypoint for applications since API 335 */
31 uname_x (struct utsname
*name
)
35 char buf
[NI_MAXHOST
+ 1] ATTRIBUTE_NONSTRING
;
37 memset (name
, 0, sizeof (*name
));
39 __small_sprintf (name
->sysname
, "CYGWIN_%s-%u",
40 wincap
.osname (), wincap
.build_number ());
42 memset (buf
, 0, sizeof buf
);
43 cygwin_gethostname (buf
, sizeof buf
- 1);
44 strncat (name
->nodename
, buf
, sizeof (name
->nodename
) - 1);
46 switch (wincap
.cpu_arch ())
48 case PROCESSOR_ARCHITECTURE_AMD64
:
49 strcpy (name
->machine
, "x86_64");
52 strcpy (name
->machine
, "unknown");
56 #pragma GCC diagnostic push
57 #pragma GCC diagnostic ignored "-Wformat-truncation="
58 #ifdef CYGPORT_RELEASE_INFO
59 snprintf (name
->release
, _UTSNAME_LENGTH
, "%s.%s",
60 __XSTRING (CYGPORT_RELEASE_INFO
), name
->machine
);
62 extern const char *uname_dev_version
;
63 if (uname_dev_version
&& uname_dev_version
[0])
64 snprintf (name
->release
, _UTSNAME_LENGTH
, "%s.%s",
65 uname_dev_version
, name
->machine
);
67 __small_sprintf (name
->release
, "%d.%d.%d-api-%d.%s",
68 cygwin_version
.dll_major
/ 1000,
69 cygwin_version
.dll_major
% 1000,
70 cygwin_version
.dll_minor
,
71 cygwin_version
.api_minor
,
74 #pragma GCC diagnostic pop
76 stpcpy (name
->version
, cygwin_version
.dll_build_date
);
77 strcat (name
->version
, " UTC");
79 memset (buf
, 0, sizeof buf
);
80 getdomainname (buf
, sizeof buf
- 1);
81 strncat (name
->domainname
, buf
, sizeof (name
->domainname
) - 1);
83 __except (EFAULT
) { return -1; }
88 /* Old entrypoint for applications up to API 334 */
99 uname (struct utsname
*in_name
)
101 struct old_utsname
*name
= (struct old_utsname
*) in_name
;
104 memset (name
, 0, sizeof (*name
));
105 __small_sprintf (name
->sysname
, "CYGWIN_%s", wincap
.osname ());
108 cygwin_gethostname (name
->nodename
, sizeof (name
->nodename
) - 1);
110 /* Cygwin dll release */
111 __small_sprintf (name
->release
, "%d.%d.%d(%d.%d/%d/%d)",
112 cygwin_version
.dll_major
/ 1000,
113 cygwin_version
.dll_major
% 1000,
114 cygwin_version
.dll_minor
,
115 cygwin_version
.api_major
,
116 cygwin_version
.api_minor
,
117 cygwin_version
.shared_data
,
118 cygwin_version
.mount_registry
);
120 /* Cygwin "version" aka build date */
121 strcpy (name
->version
, cygwin_version
.dll_build_date
);
124 switch (wincap
.cpu_arch ())
126 case PROCESSOR_ARCHITECTURE_AMD64
:
127 strcpy (name
->machine
, "x86_64");
130 strcpy (name
->machine
, "unknown");