svn commit: r189222 - head/sys/kern

Ed Schouten ed at FreeBSD.org
Sun Mar 1 01:50:14 PST 2009


Author: ed
Date: Sun Mar  1 09:50:13 2009
New Revision: 189222
URL: http://svn.freebsd.org/changeset/base/189222

Log:
  Improve my previous changes to the TTY code: also remove memcpy().
  
  It's better to just use internal language constructs, because it is
  likely the compiler has a better opinion on whether to perform inlining,
  which is very likely to happen to struct winsize.
  
  Submitted by:	Christoph Mallon <christoph mallon gmx de>

Modified:
  head/sys/kern/tty.c
  head/sys/kern/tty_pts.c

Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c	Sun Mar  1 09:35:41 2009	(r189221)
+++ head/sys/kern/tty.c	Sun Mar  1 09:50:13 2009	(r189222)
@@ -724,14 +724,14 @@ ttyil_ioctl(struct cdev *dev, u_long cmd
 	switch (cmd) {
 	case TIOCGETA:
 		/* Obtain terminal flags through tcgetattr(). */
-		memcpy(data, dev->si_drv2, sizeof(struct termios));
+		*(struct termios*)data = *(struct termios*)dev->si_drv2;
 		break;
 	case TIOCSETA:
 		/* Set terminal flags through tcsetattr(). */
 		error = priv_check(td, PRIV_TTY_SETA);
 		if (error)
 			break;
-		memcpy(dev->si_drv2, data, sizeof(struct termios));
+		*(struct termios*)dev->si_drv2 = *(struct termios*)data;
 		break;
 	case TIOCGETD:
 		*(int *)data = TTYDISC;
@@ -1344,7 +1344,7 @@ tty_generic_ioctl(struct tty *tp, u_long
 		return (0);
 	case TIOCGETA:
 		/* Obtain terminal flags through tcgetattr(). */
-		memcpy(data, &tp->t_termios, sizeof(struct termios));
+		*(struct termios*)data = tp->t_termios;
 		return (0);
 	case TIOCSETA:
 	case TIOCSETAW:
@@ -1568,13 +1568,13 @@ tty_generic_ioctl(struct tty *tp, u_long
 		return (0);
 	case TIOCGWINSZ:
 		/* Obtain window size. */
-		memcpy(data, &tp->t_winsize, sizeof(struct winsize));
+		*(struct winsize*)data = tp->t_winsize;
 		return (0);
 	case TIOCSWINSZ:
 		/* Set window size. */
 		if (bcmp(&tp->t_winsize, data, sizeof(struct winsize)) == 0)
 			return (0);
-		memcpy(&tp->t_winsize, data, sizeof(struct winsize));
+		tp->t_winsize = *(struct winsize*)data;
 		tty_signal_pgrp(tp, SIGWINCH);
 		return (0);
 	case TIOCEXCL:

Modified: head/sys/kern/tty_pts.c
==============================================================================
--- head/sys/kern/tty_pts.c	Sun Mar  1 09:35:41 2009	(r189221)
+++ head/sys/kern/tty_pts.c	Sun Mar  1 09:50:13 2009	(r189222)
@@ -310,7 +310,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd
 	case TIOCGETA:
 		/* Obtain terminal flags through tcgetattr(). */
 		tty_lock(tp);
-		memcpy(data, &tp->t_termios, sizeof(struct termios));
+		*(struct termios*)data = tp->t_termios;
 		tty_unlock(tp);
 		return (0);
 #endif /* PTS_LINUX */


More information about the svn-src-head mailing list