about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2018-10-09 10:00:14 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-01-03 09:32:12 -0200
commite5a50db36eaa6e8c6427b3a971563240b633ca85 (patch)
tree1fd926d4a122add2a014c07af558c9e786f941fb
parent8083afa55d8c68abc02902e9a6ff16be5f301940 (diff)
downloadglibc-e5a50db36eaa6e8c6427b3a971563240b633ca85.tar.gz
glibc-e5a50db36eaa6e8c6427b3a971563240b633ca85.tar.xz
glibc-e5a50db36eaa6e8c6427b3a971563240b633ca85.zip
termios: Consolidate struct termios
This patch consolidates the struct termios definition on its own header
and adds arch-defined ones for ABIs that deviate from generic
implementation. They are:

  - alpha which has a slight different layout than generic one (c_cc
    field is defined prior c_line).

  - sparc and mips which do not have the c_ispeed/c_ospeed fields.

No semantic change is expected, checked on a build against x86_64-linux-gnu,
alpha-linux-gnu, mips64-linux-gnu, and sparc64-linux-gnu.

	* sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h: New file.
	* sysdeps/unix/sysv/linux/bits/termios-struct.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/termios-struct.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h: Likewise.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	termios-struct.h.
	* sysdeps/unix/sysv/linux/bits/termios.h (struct termios): Move to
	termios-struct.h.
	* sysdeps/unix/sysv/linux/alpha/bits/termios.h (struct termios):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/termios.h (struct termios):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/termios.h (struct termios):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/termios.h (struct termios):
	Likewise.
	* sysdeps/unix/sysv/linux/kernel_termios.h (_HAVE_C_ISPEED,
	_HAVE_C_OSPEED): Define.
	* sysdeps/unix/sysv/linux/mips/kernel_termios.h (_HAVE_C_ISPEED,
	_HAVE_C_OSPEED): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel_termios.h (_HAVE_C_ISPEED,
	_HAVE_C_OSPEED): Likewise.
	* sysdeps/unix/sysv/linux/speed.c [_HAVE_STRUCT_TERMIOS_C_OSPEED]
	(cfsetospeed): Check for define value instead of existence.
	[_HAVE_STRUCT_TERMIOS_C_ISPEED] (cfsetispeed): Likewise.
	* sysdeps/unix/sysv/linux/tcgetattr.c [_HAVE_STRUCT_TERMIOS_C_ISPEED
	&& _HAVE_C_ISPEED] (__tcgetattr): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c [_HAVE_STRUCT_TERMIOS_C_ISPEED
	&& _HAVE_C_ISPEED] (__tcsetattr): Likewise.
-rw-r--r--ChangeLog30
-rw-r--r--sysdeps/unix/sysv/linux/Makefile3
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h37
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/termios.h15
-rw-r--r--sysdeps/unix/sysv/linux/bits/termios-struct.h36
-rw-r--r--sysdeps/unix/sysv/linux/bits/termios.h15
-rw-r--r--sysdeps/unix/sysv/linux/kernel_termios.h3
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/termios-struct.h34
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/termios.h11
-rw-r--r--sysdeps/unix/sysv/linux/mips/kernel_termios.h3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/bits/termios.h20
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h34
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/termios.h11
-rw-r--r--sysdeps/unix/sysv/linux/sparc/kernel_termios.h3
-rw-r--r--sysdeps/unix/sysv/linux/speed.c4
-rw-r--r--sysdeps/unix/sysv/linux/tcgetattr.c8
-rw-r--r--sysdeps/unix/sysv/linux/tcsetattr.c4
17 files changed, 195 insertions, 76 deletions
diff --git a/ChangeLog b/ChangeLog
index 879578967e..f369fd0282 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
 2019-01-03  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h: New file.
+	* sysdeps/unix/sysv/linux/bits/termios-struct.h: Likewise.
+	* sysdeps/unix/sysv/linux/mips/bits/termios-struct.h: Likewise.
+	* sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h: Likewise.
+	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
+	termios-struct.h.
+	* sysdeps/unix/sysv/linux/bits/termios.h (struct termios): Move to
+	termios-struct.h.
+	* sysdeps/unix/sysv/linux/alpha/bits/termios.h (struct termios):
+	Likewise.
+	* sysdeps/unix/sysv/linux/mips/bits/termios.h (struct termios):
+	Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/bits/termios.h (struct termios):
+	Likewise.
+	* sysdeps/unix/sysv/linux/sparc/bits/termios.h (struct termios):
+	Likewise.
+	* sysdeps/unix/sysv/linux/kernel_termios.h (_HAVE_C_ISPEED,
+	_HAVE_C_OSPEED): Define.
+	* sysdeps/unix/sysv/linux/mips/kernel_termios.h (_HAVE_C_ISPEED,
+	_HAVE_C_OSPEED): Likewise.
+	* sysdeps/unix/sysv/linux/sparc/kernel_termios.h (_HAVE_C_ISPEED,
+	_HAVE_C_OSPEED): Likewise.
+	* sysdeps/unix/sysv/linux/speed.c [_HAVE_STRUCT_TERMIOS_C_OSPEED]
+	(cfsetospeed): Check for define value instead of existence.
+	[_HAVE_STRUCT_TERMIOS_C_ISPEED] (cfsetispeed): Likewise.
+	* sysdeps/unix/sysv/linux/tcgetattr.c [_HAVE_STRUCT_TERMIOS_C_ISPEED
+	&& _HAVE_C_ISPEED] (__tcgetattr): Likewise.
+	* sysdeps/unix/sysv/linux/tcsetattr.c [_HAVE_STRUCT_TERMIOS_C_ISPEED
+	&& _HAVE_C_ISPEED] (__tcsetattr): Likewise.
+
 	[BZ #17783]
 	* sysdeps/unix/sysv/linux/bits/termios.h [__USE_MISC] (TIOCSER_TEMT):
 	Define.
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index f8274552a7..f9c886448a 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -43,7 +43,8 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 		  bits/siginfo-arch.h bits/siginfo-consts-arch.h \
 		  bits/procfs.h bits/procfs-id.h bits/procfs-extra.h \
 		  bits/procfs-prregset.h bits/mman-map-flags-generic.h \
-		  bits/msq-pad.h bits/sem-pad.h bits/shmlba.h bits/shm-pad.h
+		  bits/msq-pad.h bits/sem-pad.h bits/shmlba.h bits/shm-pad.h \
+		  bits/termios-struct.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h b/sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h
new file mode 100644
index 0000000000..55f9f2e500
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/bits/termios-struct.h
@@ -0,0 +1,37 @@
+/* struct termios definition.  Linux/alpha version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#endif
+
+/* Alpha has C_CC before C_LINE compare to Linux generic definition.  */
+#define NCCS 32
+struct termios
+  {
+    tcflag_t c_iflag;		/* input mode flags */
+    tcflag_t c_oflag;		/* output mode flags */
+    tcflag_t c_cflag;		/* control mode flags */
+    tcflag_t c_lflag;		/* local mode flags */
+    cc_t c_cc[NCCS];		/* control characters */
+    cc_t c_line;		/* line discipline (== c_cc[33]) */
+    speed_t c_ispeed;		/* input speed */
+    speed_t c_ospeed;		/* output speed */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
+  };
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/termios.h b/sysdeps/unix/sysv/linux/alpha/bits/termios.h
index 8fb39312c6..6b6fdfb234 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/termios.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/termios.h
@@ -24,20 +24,7 @@ typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
 typedef unsigned int	tcflag_t;
 
-#define NCCS 32
-struct termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_cc[NCCS];		/* control characters */
-    cc_t c_line;		/* line discipline (== c_cc[33]) */
-    speed_t c_ispeed;		/* input speed */
-    speed_t c_ospeed;		/* output speed */
-#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
-#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
-  };
+#include <bits/termios-struct.h>
 
 /* c_cc characters */
 #define VEOF 0
diff --git a/sysdeps/unix/sysv/linux/bits/termios-struct.h b/sysdeps/unix/sysv/linux/bits/termios-struct.h
new file mode 100644
index 0000000000..af5c1b1f35
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/termios-struct.h
@@ -0,0 +1,36 @@
+/* struct termios definition.  Linux/generic version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#endif
+
+#define NCCS 32
+struct termios
+  {
+    tcflag_t c_iflag;		/* input mode flags */
+    tcflag_t c_oflag;		/* output mode flags */
+    tcflag_t c_cflag;		/* control mode flags */
+    tcflag_t c_lflag;		/* local mode flags */
+    cc_t c_line;			/* line discipline */
+    cc_t c_cc[NCCS];		/* control characters */
+    speed_t c_ispeed;		/* input speed */
+    speed_t c_ospeed;		/* output speed */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
+  };
diff --git a/sysdeps/unix/sysv/linux/bits/termios.h b/sysdeps/unix/sysv/linux/bits/termios.h
index 96b68a0abc..74468db8e4 100644
--- a/sysdeps/unix/sysv/linux/bits/termios.h
+++ b/sysdeps/unix/sysv/linux/bits/termios.h
@@ -24,20 +24,7 @@ typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
 typedef unsigned int	tcflag_t;
 
-#define NCCS 32
-struct termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_line;			/* line discipline */
-    cc_t c_cc[NCCS];		/* control characters */
-    speed_t c_ispeed;		/* input speed */
-    speed_t c_ospeed;		/* output speed */
-#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
-#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
-  };
+#include <bits/termios-struct.h>
 
 /* c_cc characters */
 #define VINTR 0
diff --git a/sysdeps/unix/sysv/linux/kernel_termios.h b/sysdeps/unix/sysv/linux/kernel_termios.h
index 3159e03165..bc4294762b 100644
--- a/sysdeps/unix/sysv/linux/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/kernel_termios.h
@@ -31,4 +31,7 @@ struct __kernel_termios
     cc_t c_cc[__KERNEL_NCCS];	/* control characters */
   };
 
+#define _HAVE_C_ISPEED 0
+#define _HAVE_C_OSPEED 0
+
 #endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h b/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h
new file mode 100644
index 0000000000..ca89009823
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h
@@ -0,0 +1,34 @@
+/* struct termios definition.  Linux/mips version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#endif
+
+#define NCCS 32
+struct termios
+  {
+    tcflag_t c_iflag;		/* input mode flags */
+    tcflag_t c_oflag;		/* output mode flags */
+    tcflag_t c_cflag;		/* control mode flags */
+    tcflag_t c_lflag;		/* local mode flags */
+    cc_t c_line;		/* line discipline */
+    cc_t c_cc[NCCS];		/* control characters */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 0
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 0
+  };
diff --git a/sysdeps/unix/sysv/linux/mips/bits/termios.h b/sysdeps/unix/sysv/linux/mips/bits/termios.h
index dd3470c306..68d771d8b2 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/termios.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/termios.h
@@ -24,16 +24,7 @@ typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
 typedef unsigned int	tcflag_t;
 
-#define NCCS 32
-struct termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_line;		/* line discipline */
-    cc_t c_cc[NCCS];		/* control characters */
-  };
+#include <bits/termios-struct.h>
 
 /* c_cc characters */
 #define VINTR		0	/* Interrupt character [ISIG].  */
diff --git a/sysdeps/unix/sysv/linux/mips/kernel_termios.h b/sysdeps/unix/sysv/linux/mips/kernel_termios.h
index 0200d50747..a607d78da1 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel_termios.h
@@ -31,4 +31,7 @@ struct __kernel_termios
     cc_t c_cc[__KERNEL_NCCS];	/* control characters */
   };
 
+#define _HAVE_C_ISPEED 0
+#define _HAVE_C_OSPEED 0
+
 #endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/termios.h b/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
index 050d947eb9..4dafb60cad 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
@@ -23,25 +23,7 @@ typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
 typedef unsigned int	tcflag_t;
 
-/*
- * termios type and macro definitions.  Be careful about adding stuff
- * to this file since it's used in GNU libc and there are strict rules
- * concerning namespace pollution.
- */
-
-#define NCCS 32
-struct termios {
-	tcflag_t c_iflag;		/* input mode flags */
-	tcflag_t c_oflag;		/* output mode flags */
-	tcflag_t c_cflag;		/* control mode flags */
-	tcflag_t c_lflag;		/* local mode flags */
-	cc_t c_line;			/* line discipline (== c_cc[19]) */
-	cc_t c_cc[NCCS];		/* control characters */
-	speed_t c_ispeed;		/* input speed */
-	speed_t c_ospeed;		/* output speed */
-#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
-#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
-};
+#include <bits/termios-struct.h>
 
 /* c_cc characters */
 #define VINTR	0
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h b/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h
new file mode 100644
index 0000000000..bb51170bca
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h
@@ -0,0 +1,34 @@
+/* struct termios definition.  Linux/sparc version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#endif
+
+#define NCCS 17
+struct termios
+  {
+    tcflag_t c_iflag;		/* input mode flags */
+    tcflag_t c_oflag;		/* output mode flags */
+    tcflag_t c_cflag;		/* control mode flags */
+    tcflag_t c_lflag;		/* local mode flags */
+    cc_t c_line;		/* line discipline */
+    cc_t c_cc[NCCS];		/* control characters */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 0
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 0
+  };
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/termios.h b/sysdeps/unix/sysv/linux/sparc/bits/termios.h
index 0c35d27772..a440aeb8bd 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/termios.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/termios.h
@@ -24,16 +24,7 @@ typedef unsigned char cc_t;
 typedef unsigned int speed_t;
 typedef unsigned int tcflag_t;
 
-#define NCCS 17
-struct termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_line;		/* line discipline */
-    cc_t c_cc[NCCS];		/* control characters */
-  };
+#include <bits/termios-struct.h>
 
 /* c_cc characters */
 #define VINTR    0
diff --git a/sysdeps/unix/sysv/linux/sparc/kernel_termios.h b/sysdeps/unix/sysv/linux/sparc/kernel_termios.h
index 03a2ade71b..b88c1ec419 100644
--- a/sysdeps/unix/sysv/linux/sparc/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/sparc/kernel_termios.h
@@ -34,4 +34,7 @@ struct __kernel_termios
     cc_t c_cc[__KERNEL_NCCS];	/* control characters */
   };
 
+#define _HAVE_C_ISPEED 0
+#define _HAVE_C_OSPEED 0
+
 #endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c
index 83fb540de8..45dc7f3fb9 100644
--- a/sysdeps/unix/sysv/linux/speed.c
+++ b/sysdeps/unix/sysv/linux/speed.c
@@ -58,7 +58,7 @@ cfsetospeed (struct termios *termios_p, speed_t speed)
       && (speed < B57600 || speed > __MAX_BAUD))
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-#ifdef _HAVE_STRUCT_TERMIOS_C_OSPEED
+#if _HAVE_STRUCT_TERMIOS_C_OSPEED
   termios_p->c_ospeed = speed;
 #endif
   termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
@@ -80,7 +80,7 @@ cfsetispeed (struct termios *termios_p, speed_t speed)
       && (speed < B57600 || speed > __MAX_BAUD))
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-#ifdef _HAVE_STRUCT_TERMIOS_C_ISPEED
+#if _HAVE_STRUCT_TERMIOS_C_ISPEED
   termios_p->c_ispeed = speed;
 #endif
   if (speed == 0)
diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c
index f933fe6a51..c0f810207f 100644
--- a/sysdeps/unix/sysv/linux/tcgetattr.c
+++ b/sysdeps/unix/sysv/linux/tcgetattr.c
@@ -44,15 +44,15 @@ __tcgetattr (int fd, struct termios *termios_p)
       termios_p->c_cflag = k_termios.c_cflag;
       termios_p->c_lflag = k_termios.c_lflag;
       termios_p->c_line = k_termios.c_line;
-#ifdef _HAVE_STRUCT_TERMIOS_C_ISPEED
-# ifdef _HAVE_C_ISPEED
+#if _HAVE_STRUCT_TERMIOS_C_ISPEED
+# if _HAVE_C_ISPEED
       termios_p->c_ispeed = k_termios.c_ispeed;
 # else
       termios_p->c_ispeed = k_termios.c_cflag & (CBAUD | CBAUDEX);
 # endif
 #endif
-#ifdef _HAVE_STRUCT_TERMIOS_C_OSPEED
-# ifdef _HAVE_C_OSPEED
+#if _HAVE_STRUCT_TERMIOS_C_OSPEED
+# if _HAVE_C_OSPEED
       termios_p->c_ospeed = k_termios.c_ospeed;
 # else
       termios_p->c_ospeed = k_termios.c_cflag & (CBAUD | CBAUDEX);
diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
index 3988532ef3..3fb474ed63 100644
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -66,10 +66,10 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
   k_termios.c_cflag = termios_p->c_cflag;
   k_termios.c_lflag = termios_p->c_lflag;
   k_termios.c_line = termios_p->c_line;
-#if defined _HAVE_C_ISPEED && defined _HAVE_STRUCT_TERMIOS_C_ISPEED
+#if _HAVE_C_ISPEED && _HAVE_STRUCT_TERMIOS_C_ISPEED
   k_termios.c_ispeed = termios_p->c_ispeed;
 #endif
-#if defined _HAVE_C_OSPEED && defined _HAVE_STRUCT_TERMIOS_C_OSPEED
+#if _HAVE_C_OSPEED && _HAVE_STRUCT_TERMIOS_C_OSPEED
   k_termios.c_ospeed = termios_p->c_ospeed;
 #endif
   memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],