Deleted Added
full compact
tty_inq.c (203611) tty_inq.c (223575)
1/*-
2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Portions of this software were developed under sponsorship from Snow
6 * B.V., the Netherlands.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Portions of this software were developed under sponsorship from Snow
6 * B.V., the Netherlands.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/kern/tty_inq.c 203611 2010-02-07 15:42:15Z ed $");
31__FBSDID("$FreeBSD: head/sys/kern/tty_inq.c 223575 2011-06-26 18:26:20Z ed $");
32
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/lock.h>
36#include <sys/queue.h>
37#include <sys/sysctl.h>
38#include <sys/systm.h>
39#include <sys/tty.h>

--- 97 unchanged lines hidden (view full) ---

137 TTYINQ_INSERT_TAIL(ti, tib);
138 }
139}
140
141void
142ttyinq_free(struct ttyinq *ti)
143{
144 struct ttyinq_block *tib;
32
33#include <sys/param.h>
34#include <sys/kernel.h>
35#include <sys/lock.h>
36#include <sys/queue.h>
37#include <sys/sysctl.h>
38#include <sys/systm.h>
39#include <sys/tty.h>

--- 97 unchanged lines hidden (view full) ---

137 TTYINQ_INSERT_TAIL(ti, tib);
138 }
139}
140
141void
142ttyinq_free(struct ttyinq *ti)
143{
144 struct ttyinq_block *tib;
145
145
146 ttyinq_flush(ti);
147 ti->ti_quota = 0;
148
149 while ((tib = ti->ti_firstblock) != NULL) {
150 TTYINQ_REMOVE_HEAD(ti);
151 uma_zfree(ttyinq_zone, tib);
152 }
153

--- 117 unchanged lines hidden (view full) ---

271
272size_t
273ttyinq_write(struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
274{
275 const char *cbuf = buf;
276 struct ttyinq_block *tib;
277 unsigned int boff;
278 size_t l;
146 ttyinq_flush(ti);
147 ti->ti_quota = 0;
148
149 while ((tib = ti->ti_firstblock) != NULL) {
150 TTYINQ_REMOVE_HEAD(ti);
151 uma_zfree(ttyinq_zone, tib);
152 }
153

--- 117 unchanged lines hidden (view full) ---

271
272size_t
273ttyinq_write(struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
274{
275 const char *cbuf = buf;
276 struct ttyinq_block *tib;
277 unsigned int boff;
278 size_t l;
279
279
280 while (nbytes > 0) {
281 boff = ti->ti_end % TTYINQ_DATASIZE;
282
283 if (ti->ti_end == 0) {
284 /* First time we're being used or drained. */
285 MPASS(ti->ti_begin == 0);
286 tib = ti->ti_firstblock;
287 if (tib == NULL) {

--- 20 unchanged lines hidden (view full) ---

308
309 /* Set the quoting bits for the proper region. */
310 ttyinq_set_quotes(tib, boff, l, quote);
311
312 cbuf += l;
313 nbytes -= l;
314 ti->ti_end += l;
315 }
280 while (nbytes > 0) {
281 boff = ti->ti_end % TTYINQ_DATASIZE;
282
283 if (ti->ti_end == 0) {
284 /* First time we're being used or drained. */
285 MPASS(ti->ti_begin == 0);
286 tib = ti->ti_firstblock;
287 if (tib == NULL) {

--- 20 unchanged lines hidden (view full) ---

308
309 /* Set the quoting bits for the proper region. */
310 ttyinq_set_quotes(tib, boff, l, quote);
311
312 cbuf += l;
313 nbytes -= l;
314 ti->ti_end += l;
315 }
316
316
317 return (cbuf - (const char *)buf);
318}
319
320int
321ttyinq_write_nofrag(struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
322{
323 size_t ret;
324

--- 67 unchanged lines hidden (view full) ---

392 if (ti->ti_linestart == ti->ti_end)
393 return (-1);
394
395 MPASS(ti->ti_end > 0);
396 boff = (ti->ti_end - 1) % TTYINQ_DATASIZE;
397
398 *c = tib->tib_data[boff];
399 *quote = GETBIT(tib, boff);
317 return (cbuf - (const char *)buf);
318}
319
320int
321ttyinq_write_nofrag(struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
322{
323 size_t ret;
324

--- 67 unchanged lines hidden (view full) ---

392 if (ti->ti_linestart == ti->ti_end)
393 return (-1);
394
395 MPASS(ti->ti_end > 0);
396 boff = (ti->ti_end - 1) % TTYINQ_DATASIZE;
397
398 *c = tib->tib_data[boff];
399 *quote = GETBIT(tib, boff);
400
400
401 return (0);
402}
403
404void
405ttyinq_unputchar(struct ttyinq *ti)
406{
407
408 MPASS(ti->ti_linestart < ti->ti_end);

--- 81 unchanged lines hidden ---
401 return (0);
402}
403
404void
405ttyinq_unputchar(struct ttyinq *ti)
406{
407
408 MPASS(ti->ti_linestart < ti->ti_end);

--- 81 unchanged lines hidden ---