Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/tty.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/tty.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.239.2.1 retrieving revision 1.240 diff -u -p -r1.239.2.1 -r1.240 --- src/sys/kern/tty.c 2011/06/06 09:09:38 1.239.2.1 +++ src/sys/kern/tty.c 2011/01/23 07:30:07 1.240 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.239.2.1 2011/06/06 09:09:38 jruoho Exp $ */ +/* $NetBSD: tty.c,v 1.240 2011/01/23 07:30:07 matt Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.239.2.1 2011/06/06 09:09:38 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.240 2011/01/23 07:30:07 matt Exp $"); #include #include @@ -2429,36 +2429,31 @@ ttygetinfo(struct tty *tp, int fromsig, mutex_enter(pick->p_lock); LIST_FOREACH(l, &pick->p_lwps, l_sibling) { - const char *lp; lwp_lock(l); #ifdef LWP_PC -#define FMT_RUN "%#"PRIxVADDR -#define VAL_RUNNING (vaddr_t)LWP_PC(l) -#define VAL_RUNABLE (vaddr_t)LWP_PC(l) -#else -#define FMT_RUN "%s" -#define VAL_RUNNING "running" -#define VAL_RUNABLE "runnable" -#endif - switch (l->l_stat) { - case LSONPROC: - snprintf(lmsg, sizeof(lmsg), FMT_RUN"/%d", VAL_RUNNING, - cpu_index(l->l_cpu)); - lp = lmsg; - break; - case LSRUN: - snprintf(lmsg, sizeof(lmsg), FMT_RUN, VAL_RUNABLE); - lp = lmsg; - break; - default: - lp = l->l_wchan ? l->l_wmesg : "iowait"; - break; + if (l->l_stat == LSONPROC) { + snprintf(lmsg, sizeof(lmsg), "%#"PRIxVADDR"/%d", + LWP_PC(l), cpu_index(l->l_cpu)); + strlcat(buf, lmsg, bufsz); + } else if (l->l_stat == LSRUN) { + snprintf(lmsg, sizeof(lmsg), "%#"PRIxVADDR, LWP_PC(l)); + strlcat(buf, lmsg, bufsz); + } else { + strlcat(buf, l->l_wchan ? l->l_wmesg : "iowait", bufsz); } - strlcat(buf, lp, bufsz); - strlcat(buf, LIST_NEXT(l, l_sibling) != NULL ? " " : "] ", + lwp_unlock(l); + strlcat(buf, (LIST_NEXT(l, l_sibling) != NULL) ? " " : "] ", bufsz); - pctcpu += l->l_pctcpu; +#else + snprintf(lmsg, sizeof(lmsg), "%s%s", + l->l_stat == LSONPROC ? "running" : + l->l_stat == LSRUN ? "runnable" : + l->l_wchan ? l->l_wmesg : "iowait", + (LIST_NEXT(l, l_sibling) != NULL) ? " " : "] "); lwp_unlock(l); + strlcat(buf, lmsg, bufsz); +#endif + pctcpu += l->l_pctcpu; } pctcpu += pick->p_pctcpu; calcru(pick, &utime, &stime, NULL, NULL); @@ -2637,10 +2632,10 @@ ttysleep(struct tty *tp, kcondvar_t *cv, * This should be called ONLY once per real tty (including pty's). * eg, on the sparc, the keyboard and mouse have struct tty's that are * distinctly NOT usable as tty's, and thus should not be attached to - * the ttylist. This is why this call is not done from tty_alloc(). + * the ttylist. This is why this call is not done from ttymalloc(). * * Device drivers should attach tty's at a similar time that they are - * allocated, or, for the case of statically allocated struct tty's + * ttymalloc()'ed, or, for the case of statically allocated struct tty's * either in the attach or (first) open routine. */ void @@ -2674,10 +2669,10 @@ tty_detach(struct tty *tp) * Allocate a tty structure and its associated buffers. */ struct tty * -tty_alloc(void) +ttymalloc(void) { - struct tty *tp; - int i; + struct tty *tp; + int i; tp = kmem_zalloc(sizeof(*tp), KM_SLEEP); callout_init(&tp->t_rstrt_ch, 0); @@ -2695,14 +2690,11 @@ tty_alloc(void) cv_init(&tp->t_outcvf, "ttyoutf"); /* Set default line discipline. */ tp->t_linesw = ttyldisc_default(); - tp->t_dev = NODEV; selinit(&tp->t_rsel); selinit(&tp->t_wsel); - for (i = 0; i < TTYSIG_COUNT; i++) { + for (i = 0; i < TTYSIG_COUNT; i++) sigemptyset(&tp->t_sigs[i]); - } - - return tp; + return (tp); } /* @@ -2712,7 +2704,7 @@ tty_alloc(void) * tty_attach()ed. */ void -tty_free(struct tty *tp) +ttyfree(struct tty *tp) { int i;