[PATCH] Cygwin: unbreak the build with GCC 7
Ken Brown
kbrown@cornell.edu
Fri Jul 19 18:27:00 GMT 2019
The recent port to GCC 8 used the 'nonstring' attribute, which is
unknown to GCC 7. Define and use an 'ATTRIBUTE_NONSTRING' macro
instead.
---
winsup/cygwin/include/sys/utmp.h | 11 ++++++++---
winsup/cygwin/uname.cc | 8 +++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/include/sys/utmp.h b/winsup/cygwin/include/sys/utmp.h
index acf804ad0..443c44252 100644
--- a/winsup/cygwin/include/sys/utmp.h
+++ b/winsup/cygwin/include/sys/utmp.h
@@ -19,16 +19,21 @@ extern "C" {
#define ut_name ut_user
#endif
+#if __GNUC__ >= 8
+#define ATTRIBUTE_NONSTRING __attribute__ ((nonstring))
+#else
+#define ATTRIBUTE_NONSTRING
+#endif
struct utmp
{
short ut_type;
pid_t ut_pid;
- char ut_line[UT_LINESIZE] __attribute__ ((nonstring));
+ char ut_line[UT_LINESIZE] ATTRIBUTE_NONSTRING;
char ut_id[UT_IDLEN];
time_t ut_time;
- char ut_user[UT_NAMESIZE] __attribute__ ((nonstring));
- char ut_host[UT_HOSTSIZE] __attribute__ ((nonstring));
+ char ut_user[UT_NAMESIZE] ATTRIBUTE_NONSTRING;
+ char ut_host[UT_HOSTSIZE] ATTRIBUTE_NONSTRING;
long ut_addr;
};
diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index e323335b4..350216681 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -17,6 +17,12 @@ details. */
extern "C" int cygwin_gethostname (char *__name, size_t __len);
extern "C" int getdomainname (char *__name, size_t __len);
+#if __GNUC__ >= 8
+#define ATTRIBUTE_NONSTRING __attribute__ ((nonstring))
+#else
+#define ATTRIBUTE_NONSTRING
+#endif
+
/* uname: POSIX 4.4.1.1 */
/* New entrypoint for applications since API 335 */
@@ -25,7 +31,7 @@ uname_x (struct utsname *name)
{
__try
{
- char buf[NI_MAXHOST + 1] __attribute__ ((nonstring));
+ char buf[NI_MAXHOST + 1] ATTRIBUTE_NONSTRING;
char *snp = strstr (cygwin_version.dll_build_date, "SNP");
memset (name, 0, sizeof (*name));
--
2.21.0
More information about the Cygwin-patches
mailing list