--- old/usr/src/lib/libc/amd64/Makefile	Thu Oct  3 17:49:51 2019
+++ new/usr/src/lib/libc/amd64/Makefile	Thu Oct  3 17:49:51 2019
@@ -362,11 +362,9 @@
 	calloc.o		\
 	catgets.o		\
 	catopen.o		\
-	cfgetispeed.o		\
-	cfgetospeed.o		\
+	cfmakeraw.o		\
 	cfree.o			\
-	cfsetispeed.o		\
-	cfsetospeed.o		\
+	cfsetspeed.o		\
 	cftime.o		\
 	clock.o			\
 	closedir.o		\
--- old/usr/src/lib/libc/i386/Makefile.com	Thu Oct  3 17:49:52 2019
+++ new/usr/src/lib/libc/i386/Makefile.com	Thu Oct  3 17:49:52 2019
@@ -398,11 +398,9 @@
 	calloc.o		\
 	catgets.o		\
 	catopen.o		\
-	cfgetispeed.o		\
-	cfgetospeed.o		\
+	cfmakeraw.o		\
 	cfree.o			\
-	cfsetispeed.o		\
-	cfsetospeed.o		\
+	cfsetspeed.o		\
 	cftime.o		\
 	clock.o			\
 	closedir.o		\
--- old/usr/src/lib/libc/port/gen/cfgetispeed.c	Thu Oct  3 17:49:52 2019
+++ /dev/null	Thu Oct  3 17:40:06 2019
@@ -1,48 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	  All Rights Reserved  	*/
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#pragma weak _cfgetispeed = cfgetispeed
-
-#include "lint.h"
-#include <sys/types.h>
-#include <sys/termios.h>
-
-/*
- * returns input baud rate stored in c_cflag pointed by termios_p
- */
-
-speed_t
-cfgetispeed(const struct termios *termios_p)
-{
-	return (termios_p->c_cflag & CIBAUDEXT ?
-	    ((termios_p->c_cflag & CIBAUD) >> 16) + (CIBAUD >> 16) + 1 :
-	    (termios_p->c_cflag & CIBAUD) >> 16);
-}
--- old/usr/src/lib/libc/port/gen/cfgetospeed.c	Thu Oct  3 17:49:52 2019
+++ /dev/null	Thu Oct  3 17:40:06 2019
@@ -1,48 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	  All Rights Reserved  	*/
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#pragma weak _cfgetospeed = cfgetospeed
-
-#include "lint.h"
-#include <sys/types.h>
-#include <sys/termios.h>
-
-/*
- * returns output baud rate stored in c_cflag pointed by termios_p
- */
-
-speed_t
-cfgetospeed(const struct termios *termios_p)
-{
-	return (termios_p->c_cflag & CBAUDEXT ?
-	    (termios_p->c_cflag & CBAUD) + CBAUD + 1 :
-	    termios_p->c_cflag & CBAUD);
-}
--- /dev/null	Thu Oct  3 17:49:52 2019
+++ new/usr/src/lib/libc/port/gen/cfmakeraw.c	Thu Oct  3 17:49:52 2019
@@ -0,0 +1,39 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 Pluribus Networks Inc.
+ * Copyright 2017 Joyent, Inc.
+ */
+
+#include <sys/uio.h>
+
+#include <termios.h>
+#include <unistd.h>
+
+/*
+ * Make a pre-existing termios structure into "raw" mode: character-at-a-time
+ * mode with no characters interpreted, 8-bit data path.
+ */
+void
+cfmakeraw(struct termios *t)
+{
+	t->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|
+	    ICRNL|IXON|IGNPAR);
+	t->c_iflag |= IGNBRK;
+	t->c_oflag &= ~OPOST;
+	t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|
+	    TOSTOP|PENDIN);
+	t->c_cflag &= ~(CSIZE|PARENB);
+	t->c_cflag |= CS8|CREAD;
+	t->c_cc[VMIN] = 1;
+	t->c_cc[VTIME] = 0;
+}
--- old/usr/src/lib/libc/port/gen/cfsetispeed.c	Thu Oct  3 17:49:52 2019
+++ /dev/null	Thu Oct  3 17:49:52 2019
@@ -1,62 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	  All Rights Reserved  	*/
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#pragma weak _cfsetispeed = cfsetispeed
-
-#include "lint.h"
-#include <sys/types.h>
-#include <sys/termios.h>
-
-/*
- * sets the input baud rate stored in c_cflag to speed
- */
-
-int
-cfsetispeed(struct termios *termios_p, speed_t speed)
-{
-	/*
-	 * If the input speed is zero, set it to output speed
-	 */
-	if (speed == 0) {
-		speed = termios_p->c_cflag & CBAUD;
-		if (termios_p->c_cflag & CBAUDEXT)
-			speed += (CBAUD + 1);
-	}
-
-	if ((speed << 16) > CIBAUD) {
-		termios_p->c_cflag |= CIBAUDEXT;
-		speed -= ((CIBAUD >> 16) + 1);
-	} else
-		termios_p->c_cflag &= ~CIBAUDEXT;
-	termios_p->c_cflag =
-	    (termios_p->c_cflag & ~CIBAUD) | ((speed << 16) & CIBAUD);
-	return (0);
-}
--- old/usr/src/lib/libc/port/gen/cfsetospeed.c	Thu Oct  3 17:49:52 2019
+++ /dev/null	Thu Oct  3 17:49:52 2019
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright (c) 1988 AT&T	*/
-/*	  All Rights Reserved  	*/
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#pragma weak _cfsetospeed = cfsetospeed
-
-#include "lint.h"
-#include <sys/types.h>
-#include <sys/termios.h>
-
-/*
- * sets the output baud rate stored in c_cflag to speed
- */
-
-int
-cfsetospeed(struct termios *termios_p, speed_t speed)
-{
-	if (speed > CBAUD) {
-		termios_p->c_cflag |= CBAUDEXT;
-		speed -= (CBAUD + 1);
-	} else
-		termios_p->c_cflag &= ~CBAUDEXT;
-
-	termios_p->c_cflag =
-	    (termios_p->c_cflag & ~CBAUD) | (speed & CBAUD);
-	return (0);
-}
--- /dev/null	Thu Oct  3 17:49:52 2019
+++ new/usr/src/lib/libc/port/gen/cfsetspeed.c	Thu Oct  3 17:49:52 2019
@@ -0,0 +1,113 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*      Copyright (c) 1988 AT&T */
+/*        All Rights Reserved   */
+
+/* Copyright 2019, Joyent, Inc. */
+
+#pragma weak _cfsetispeed = cfsetispeed
+#pragma weak _cfsetospeed = cfsetospeed
+#pragma weak _cfgetospeed = cfgetospeed
+#pragma weak _cfgetispeed = cfgetispeed
+
+#include <sys/types.h>
+#include <sys/termios.h>
+
+/*
+ * returns input baud rate stored in c_cflag pointed by termios_p
+ */
+
+speed_t
+cfgetispeed(const struct termios *termios_p)
+{
+	return (termios_p->c_cflag & CIBAUDEXT ?
+	    ((termios_p->c_cflag & CIBAUD) >> 16) + (CIBAUD >> 16) + 1 :
+	    (termios_p->c_cflag & CIBAUD) >> 16);
+}
+
+/*
+ * returns output baud rate stored in c_cflag pointed by termios_p
+ */
+
+speed_t
+cfgetospeed(const struct termios *termios_p)
+{
+	return (termios_p->c_cflag & CBAUDEXT ?
+	    (termios_p->c_cflag & CBAUD) + CBAUD + 1 :
+	    termios_p->c_cflag & CBAUD);
+}
+
+/*
+ * sets the input baud rate stored in c_cflag to speed
+ */
+
+int
+cfsetispeed(struct termios *termios_p, speed_t speed)
+{
+	/*
+	 * If the input speed is zero, set it to output speed
+	 */
+	if (speed == 0) {
+		speed = termios_p->c_cflag & CBAUD;
+		if (termios_p->c_cflag & CBAUDEXT)
+			speed += (CBAUD + 1);
+	}
+
+	if ((speed << 16) > CIBAUD) {
+		termios_p->c_cflag |= CIBAUDEXT;
+		speed -= ((CIBAUD >> 16) + 1);
+	} else
+		termios_p->c_cflag &= ~CIBAUDEXT;
+	termios_p->c_cflag =
+	    (termios_p->c_cflag & ~CIBAUD) | ((speed << 16) & CIBAUD);
+	return (0);
+}
+
+/*
+ * sets the output baud rate stored in c_cflag to speed
+ */
+
+int
+cfsetospeed(struct termios *termios_p, speed_t speed)
+{
+	if (speed > CBAUD) {
+		termios_p->c_cflag |= CBAUDEXT;
+		speed -= (CBAUD + 1);
+	} else
+		termios_p->c_cflag &= ~CBAUDEXT;
+
+	termios_p->c_cflag =
+	    (termios_p->c_cflag & ~CBAUD) | (speed & CBAUD);
+	return (0);
+}
+
+int
+cfsetspeed(struct termios *termios_p, speed_t speed)
+{
+	(void) cfsetispeed(termios_p, speed);
+	(void) cfsetospeed(termios_p, speed);
+}
--- old/usr/src/lib/libc/port/mapfile-vers	Thu Oct  3 17:49:53 2019
+++ new/usr/src/lib/libc/port/mapfile-vers	Thu Oct  3 17:49:53 2019
@@ -23,7 +23,7 @@
 # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2018 Nexenta Systems, Inc.
 # Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2018 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
 # Copyright (c) 2013 Gary Mills
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
@@ -78,6 +78,12 @@
 $add amd64
 $endif
 
+SYMBOL_VERSION ILLUMOS_0.31 {
+    protected:
+        cfmakeraw;
+        cfsetspeed;
+} ILLUMOS_0.30;
+
 SYMBOL_VERSION ILLUMOS_0.30 {
     protected:
 	reallocf;
--- old/usr/src/lib/libc/sparc/Makefile.com	Thu Oct  3 17:49:53 2019
+++ new/usr/src/lib/libc/sparc/Makefile.com	Thu Oct  3 17:49:53 2019
@@ -424,11 +424,9 @@
 	calloc.o		\
 	catgets.o		\
 	catopen.o		\
-	cfgetispeed.o		\
-	cfgetospeed.o		\
+	cfmakeraw.o		\
 	cfree.o			\
-	cfsetispeed.o		\
-	cfsetospeed.o		\
+	cfsetspeed.o		\
 	cftime.o		\
 	clock.o			\
 	closedir.o		\
--- old/usr/src/lib/libc/sparcv9/Makefile.com	Thu Oct  3 17:49:53 2019
+++ new/usr/src/lib/libc/sparcv9/Makefile.com	Thu Oct  3 17:49:53 2019
@@ -381,11 +381,9 @@
 	calloc.o		\
 	catgets.o		\
 	catopen.o		\
-	cfgetispeed.o		\
-	cfgetospeed.o		\
+	cfmakeraw.o		\
 	cfree.o			\
-	cfsetispeed.o		\
-	cfsetospeed.o		\
+	cfsetspeed.o		\
 	cftime.o		\
 	clock.o			\
 	closedir.o		\
--- old/usr/src/man/man3c/Makefile	Thu Oct  3 17:49:54 2019
+++ new/usr/src/man/man3c/Makefile	Thu Oct  3 17:49:54 2019
@@ -14,7 +14,7 @@
 # Copyright 2018 Nexenta Systems, Inc.
 # Copyright 2013, OmniTI Computer Consulting, Inc. All rights reserved.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright 2018 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
 # Copyright 2018 Jason King
 # Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
 #
@@ -66,6 +66,7 @@
 		catgets.3c					\
 		catopen.3c					\
 		cfgetispeed.3c					\
+		cfmakeraw.3c					\
 		cfsetispeed.3c					\
 		clearenv.3c					\
 		clock.3c					\
@@ -729,6 +730,7 @@
 		catclose.3c				\
 		cfgetospeed.3c				\
 		cfsetospeed.3c				\
+		cfsetspeed.3c				\
 		cftime.3c				\
 		clearerr.3c				\
 		clock_getres.3c				\
@@ -1600,6 +1602,7 @@
 cfgetospeed.3c				:= LINKSRC = cfgetispeed.3c
 
 cfsetospeed.3c				:= LINKSRC = cfsetispeed.3c
+cfsetspeed.3c				:= LINKSRC = cfsetispeed.3c
 
 clock_getres.3c				:= LINKSRC = clock_settime.3c
 clock_gettime.3c			:= LINKSRC = clock_settime.3c
--- /dev/null	Thu Oct  3 17:49:54 2019
+++ new/usr/src/man/man3c/cfmakeraw.3c	Thu Oct  3 17:49:54 2019
@@ -0,0 +1,48 @@
+.\"
+.\" This file and its contents are supplied under the terms of the
+.\" Common Development and Distribution License ("CDDL"), version 1.0.
+.\" You may only use this file in accordance with the terms of version
+.\" 1.0 of the CDDL.
+.\"
+.\" A full copy of the text of the CDDL should have accompanied this
+.\" source.  A copy of the CDDL is also available via the Internet at
+.\" http://www.illumos.org/license/CDDL.
+.\"
+.\"
+.\" Copyright 2019, Joyent, Inc.
+.\"
+.Dd January 21, 2019
+.Dt CFMAKERAW 3C
+.Os
+.Sh NAME
+.Nm cfmakeraw
+.Nd set raw I/O mode
+.Sh SYNOPSIS
+.In termios.h
+.Ft void
+.Fo cfmakeraw
+.Fa "struct termios *termios_p"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn cfmakeraw
+function sets the flags in
+.Fa termios_p
+to disable all input and output processing.
+.Pp
+There is no effect on the terminal until a subsequent
+successful call to
+.Xr tcsetattr 3C
+on the same
+.Vt termios
+structure.
+.Sh INTERFACE STABILITY
+Standard
+.Sh MT-LEVEL
+MT-Safe
+.Pp
+Async-Signal-Safe
+.Sh SEE ALSO
+.Xr tcsetattr 3C ,
+.Xr attributes 4 ,
+.Xr termio 7I
--- old/usr/src/man/man3c/cfsetispeed.3c	Thu Oct  3 17:49:54 2019
+++ new/usr/src/man/man3c/cfsetispeed.3c	Thu Oct  3 17:49:54 2019
@@ -49,7 +49,8 @@
 .Os
 .Sh NAME
 .Nm cfsetispeed ,
-.Nm cfsetospeed
+.Nm cfsetospeed ,
+.Nm cfsetspeed
 .Nd set input and output baud rate
 .Sh SYNOPSIS
 .In termios.h
@@ -63,6 +64,11 @@
 .Fa "struct termios *termios_p"
 .Fa "speed_t speed"
 .Fc
+.Ft int
+.Fo cfsetspeed
+.Fa "struct termios *termios_p"
+.Fa "speed_t speed"
+.Fc
 .Sh DESCRIPTION
 The
 .Fn cfsetispeed
@@ -80,6 +86,14 @@
 to
 .Fa speed .
 .Pp
+The
+.Fn cfsetspeed
+function sets both the input and output baud rate stored in the structure
+pointed to by
+.Fa termios_p
+to
+.Fa speed.
+.Pp
 There is no effect on the baud rates set in the hardware until a subsequent
 successful call to
 .Xr tcsetattr 3C
