\hypertarget{tty__outq_8c_source}{}\doxysection{tty\+\_\+outq.\+c}
\label{tty__outq_8c_source}\index{kern/tty\_outq.c@{kern/tty\_outq.c}}
\mbox{\hyperlink{tty__outq_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00007}00007 \textcolor{comment}{ * Portions of this software were developed under sponsorship from Snow}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00008}00008 \textcolor{comment}{ * B.V., the Netherlands.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00009}00009 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00010}00010 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00011}00011 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00012}00012 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00013}00013 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00014}00014 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00015}00015 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00016}00016 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00017}00017 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00018}00018 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00019}00019 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00020}00020 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00021}00021 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00022}00022 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00023}00023 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00024}00024 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00025}00025 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00026}00026 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00027}00027 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00028}00028 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00029}00029 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00030}00030 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00033}\mbox{\hyperlink{tty__outq_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00033}} \mbox{\hyperlink{tty__outq_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/queue.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/tty.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/uio.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00042}00042 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <vm/uma.h>}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00044}00044 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00045}00045 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00046}00046 \textcolor{comment}{ * TTY output queue buffering.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00047}00047 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00048}00048 \textcolor{comment}{ * The previous design of the TTY layer offered the so-\/called clists.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00049}00049 \textcolor{comment}{ * These clists were used for both the input queues and the output}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00050}00050 \textcolor{comment}{ * queue. We don't use certain features on the output side, like quoting}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00051}00051 \textcolor{comment}{ * bits for parity marking and such. This mechanism is similar to the}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00052}00052 \textcolor{comment}{ * old clists, but only contains the features we need to buffer the}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00053}00053 \textcolor{comment}{ * output.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00054}00054 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00055}00055 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00056}\mbox{\hyperlink{structttyoutq__block}{00056}} \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00057}\mbox{\hyperlink{structttyoutq__block_add8032693f7540e3e0350ee06bb05f45}{00057}}         \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}}       *\mbox{\hyperlink{structttyoutq__block_add8032693f7540e3e0350ee06bb05f45}{tob\_next}};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00058}\mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{00058}}         \textcolor{keywordtype}{char}                    \mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{tob\_data}}[TTYOUTQ\_DATASIZE];}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00059}00059 \};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00060}00060 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00061}\mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{00061}} \textcolor{keyword}{static} uma\_zone\_t \mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{ttyoutq\_zone}};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00063}\mbox{\hyperlink{tty__outq_8c_aa45e19ea0bef57bfdb500d8fe29589f5}{00063}} \textcolor{preprocessor}{\#define TTYOUTQ\_INSERT\_TAIL(to, tob) do \{                               \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00064}00064 \textcolor{preprocessor}{        if (to-\/>to\_end == 0) \{                                          \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00065}00065 \textcolor{preprocessor}{                tob-\/>tob\_next = to-\/>to\_firstblock;                      \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00066}00066 \textcolor{preprocessor}{                to-\/>to\_firstblock = tob;                                \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00067}00067 \textcolor{preprocessor}{        \} else \{                                                        \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00068}00068 \textcolor{preprocessor}{                tob-\/>tob\_next = to-\/>to\_lastblock-\/>tob\_next;             \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00069}00069 \textcolor{preprocessor}{                to-\/>to\_lastblock-\/>tob\_next = tob;                       \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00070}00070 \textcolor{preprocessor}{        \}                                                               \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00071}00071 \textcolor{preprocessor}{        to-\/>to\_nblocks++;                                               \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00072}00072 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00073}00073 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00074}\mbox{\hyperlink{tty__outq_8c_a79e20cb01077879e37e897835bc6e6d7}{00074}} \textcolor{preprocessor}{\#define TTYOUTQ\_REMOVE\_HEAD(to) do \{                                    \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00075}00075 \textcolor{preprocessor}{        to-\/>to\_firstblock = to-\/>to\_firstblock-\/>tob\_next;                \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00076}00076 \textcolor{preprocessor}{        to-\/>to\_nblocks-\/-\/;                                               \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00077}00077 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00079}\mbox{\hyperlink{tty__outq_8c_a096691a2465ac6f1052efc3e036f5c77}{00079}} \textcolor{preprocessor}{\#define TTYOUTQ\_RECYCLE(to, tob) do \{                                   \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00080}00080 \textcolor{preprocessor}{        if (to-\/>to\_quota <= to-\/>to\_nblocks)                             \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00081}00081 \textcolor{preprocessor}{                uma\_zfree(ttyoutq\_zone, tob);                           \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00082}00082 \textcolor{preprocessor}{        else                                                            \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00083}00083 \textcolor{preprocessor}{                TTYOUTQ\_INSERT\_TAIL(to, tob);                           \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00084}00084 \textcolor{preprocessor}{\} while (0)}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00086}00086 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00087}\mbox{\hyperlink{tty__outq_8c_ad46a61f0fe8b66a258726e6e800b836c}{00087}} \mbox{\hyperlink{tty__outq_8c_ad46a61f0fe8b66a258726e6e800b836c}{ttyoutq\_flush}}(\textcolor{keyword}{struct} ttyoutq *to)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00088}00088 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00089}00089 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00090}00090         to-\/>to\_begin = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00091}00091         to-\/>to\_end = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00092}00092 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00093}00093 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00094}00094 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00095}\mbox{\hyperlink{tty__outq_8c_a69a14dacb94c5f850c73e141a6b56457}{00095}} \mbox{\hyperlink{tty__outq_8c_a69a14dacb94c5f850c73e141a6b56457}{ttyoutq\_setsize}}(\textcolor{keyword}{struct} ttyoutq *to, \textcolor{keyword}{struct} tty *tp, \textcolor{keywordtype}{size\_t} size)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00096}00096 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00097}00097         \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} *tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00099}00099         to-\/>to\_quota = howmany(size, TTYOUTQ\_DATASIZE);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00100}00100 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00101}00101         \textcolor{keywordflow}{while} (to-\/>to\_quota > to-\/>to\_nblocks) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00102}00102                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00103}00103 \textcolor{comment}{                 * List is getting bigger.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00104}00104 \textcolor{comment}{                 * Add new blocks to the tail of the list.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00105}00105 \textcolor{comment}{                 *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00106}00106 \textcolor{comment}{                 * We must unlock the TTY temporarily, because we need}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00107}00107 \textcolor{comment}{                 * to allocate memory. This won't be a problem, because}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00108}00108 \textcolor{comment}{                 * in the worst case, another thread ends up here, which}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00109}00109 \textcolor{comment}{                 * may cause us to allocate too many blocks, but this}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00110}00110 \textcolor{comment}{                 * will be caught by the loop below.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00111}00111 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00112}00112                 tty\_unlock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00113}00113                 tob = uma\_zalloc(\mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{ttyoutq\_zone}}, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00114}00114                 tty\_lock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00115}00115 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00116}00116                 \textcolor{keywordflow}{if} (tty\_gone(tp)) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00117}00117                         uma\_zfree(\mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{ttyoutq\_zone}}, tob);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00118}00118                         \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00119}00119                 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00120}00120 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00121}00121                 \mbox{\hyperlink{tty__outq_8c_aa45e19ea0bef57bfdb500d8fe29589f5}{TTYOUTQ\_INSERT\_TAIL}}(to, tob);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00122}00122         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00123}00123         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00124}00124 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00125}00125 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00126}00126 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00127}\mbox{\hyperlink{tty__outq_8c_a9c3dd9e2b0b55a0f47ff5b0ed065eafa}{00127}} \mbox{\hyperlink{tty__outq_8c_a9c3dd9e2b0b55a0f47ff5b0ed065eafa}{ttyoutq\_free}}(\textcolor{keyword}{struct} ttyoutq *to)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00128}00128 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00129}00129         \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} *tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00130}00130 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00131}00131         \mbox{\hyperlink{tty__outq_8c_ad46a61f0fe8b66a258726e6e800b836c}{ttyoutq\_flush}}(to);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00132}00132         to-\/>to\_quota = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00133}00133 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00134}00134         \textcolor{keywordflow}{while} ((tob = to-\/>to\_firstblock) != NULL) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00135}00135                 \mbox{\hyperlink{tty__outq_8c_a79e20cb01077879e37e897835bc6e6d7}{TTYOUTQ\_REMOVE\_HEAD}}(to);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00136}00136                 uma\_zfree(\mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{ttyoutq\_zone}}, tob);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00137}00137         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00139}00139         MPASS(to-\/>to\_nblocks == 0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00140}00140 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00141}00141 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00142}00142 \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00143}\mbox{\hyperlink{tty__outq_8c_a34f6361e5f6e44be12dbe10b767ac495}{00143}} \mbox{\hyperlink{tty__outq_8c_a34f6361e5f6e44be12dbe10b767ac495}{ttyoutq\_read}}(\textcolor{keyword}{struct} ttyoutq *to, \textcolor{keywordtype}{void} *\mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}}, \textcolor{keywordtype}{size\_t} len)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00144}00144 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00145}00145         \textcolor{keywordtype}{char} *cbuf = \mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00146}00146 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00147}00147         \textcolor{keywordflow}{while} (len > 0) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00148}00148                 \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} *tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00149}00149                 \textcolor{keywordtype}{size\_t} cbegin, cend, clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00150}00150 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00151}00151                 \textcolor{comment}{/* See if there still is data. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00152}00152                 \textcolor{keywordflow}{if} (to-\/>to\_begin == to-\/>to\_end)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00153}00153                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00154}00154                 tob = to-\/>to\_firstblock;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00155}00155                 \textcolor{keywordflow}{if} (tob == NULL)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00156}00156                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00158}00158                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00159}00159 \textcolor{comment}{                 * The end address should be the lowest of these three:}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00160}00160 \textcolor{comment}{                 * -\/ The write pointer}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00161}00161 \textcolor{comment}{                 * -\/ The blocksize -\/ we can't read beyond the block}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00162}00162 \textcolor{comment}{                 * -\/ The end address if we could perform the full read}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00163}00163 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00164}00164                 cbegin = to-\/>to\_begin;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00165}00165                 cend = MIN(MIN(to-\/>to\_end, to-\/>to\_begin + len),}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00166}00166                     TTYOUTQ\_DATASIZE);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00167}00167                 clen = cend -\/ cbegin;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00168}00168 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00169}00169                 \textcolor{comment}{/* Copy the data out of the buffers. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00170}00170                 memcpy(cbuf, tob-\/>\mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{tob\_data}} + cbegin, clen);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00171}00171                 cbuf += clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00172}00172                 len -\/= clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00173}00173 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00174}00174                 \textcolor{keywordflow}{if} (cend == to-\/>to\_end) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00175}00175                         \textcolor{comment}{/* Read the complete queue. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00176}00176                         to-\/>to\_begin = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00177}00177                         to-\/>to\_end = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00178}00178                 \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (cend == TTYOUTQ\_DATASIZE) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00179}00179                         \textcolor{comment}{/* Read the block until the end. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00180}00180                         \mbox{\hyperlink{tty__outq_8c_a79e20cb01077879e37e897835bc6e6d7}{TTYOUTQ\_REMOVE\_HEAD}}(to);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00181}00181                         to-\/>to\_begin = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00182}00182                         to-\/>to\_end -\/= TTYOUTQ\_DATASIZE;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00183}00183                         \mbox{\hyperlink{tty__outq_8c_a096691a2465ac6f1052efc3e036f5c77}{TTYOUTQ\_RECYCLE}}(to, tob);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00184}00184                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00185}00185                         \textcolor{comment}{/* Read the block partially. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00186}00186                         to-\/>to\_begin += clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00187}00187                 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00188}00188         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00189}00189 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00190}00190         \textcolor{keywordflow}{return} (cbuf -\/ (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}});}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00191}00191 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00192}00192 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00193}00193 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00194}00194 \textcolor{comment}{ * An optimized version of ttyoutq\_read() which can be used in pseudo}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00195}00195 \textcolor{comment}{ * TTY drivers to directly copy data from the outq to userspace, instead}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00196}00196 \textcolor{comment}{ * of buffering it.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00197}00197 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00198}00198 \textcolor{comment}{ * We can only copy data directly if we need to read the entire block}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00199}00199 \textcolor{comment}{ * back to the user, because we temporarily remove the block from the}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00200}00200 \textcolor{comment}{ * queue. Otherwise we need to copy it to a temporary buffer first, to}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00201}00201 \textcolor{comment}{ * make sure data remains in the correct order.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00202}00202 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00203}00203 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00204}\mbox{\hyperlink{tty__outq_8c_a2440d8966a0d22a358ea9a7a7cba48bb}{00204}} \mbox{\hyperlink{tty__outq_8c_a2440d8966a0d22a358ea9a7a7cba48bb}{ttyoutq\_read\_uio}}(\textcolor{keyword}{struct} ttyoutq *to, \textcolor{keyword}{struct} tty *tp, \textcolor{keyword}{struct} uio *uio)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00205}00205 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00206}00206 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00207}00207         \textcolor{keywordflow}{while} (uio-\/>uio\_resid > 0) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00208}00208                 \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00209}00209                 \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} *tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00210}00210                 \textcolor{keywordtype}{size\_t} cbegin, cend, clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00211}00211 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00212}00212                 \textcolor{comment}{/* See if there still is data. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00213}00213                 \textcolor{keywordflow}{if} (to-\/>to\_begin == to-\/>to\_end)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00214}00214                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00215}00215                 tob = to-\/>to\_firstblock;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00216}00216                 \textcolor{keywordflow}{if} (tob == NULL)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00217}00217                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00218}00218 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00219}00219                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00220}00220 \textcolor{comment}{                 * The end address should be the lowest of these three:}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00221}00221 \textcolor{comment}{                 * -\/ The write pointer}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00222}00222 \textcolor{comment}{                 * -\/ The blocksize -\/ we can't read beyond the block}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00223}00223 \textcolor{comment}{                 * -\/ The end address if we could perform the full read}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00224}00224 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00225}00225                 cbegin = to-\/>to\_begin;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00226}00226                 cend = MIN(MIN(to-\/>to\_end, to-\/>to\_begin + uio-\/>uio\_resid),}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00227}00227                     TTYOUTQ\_DATASIZE);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00228}00228                 clen = cend -\/ cbegin;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00229}00229 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00230}00230                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00231}00231 \textcolor{comment}{                 * We can prevent buffering in some cases:}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00232}00232 \textcolor{comment}{                 * -\/ We need to read the block until the end.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00233}00233 \textcolor{comment}{                 * -\/ We don't need to read the block until the end, but}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00234}00234 \textcolor{comment}{                 *   there is no data beyond it, which allows us to move}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00235}00235 \textcolor{comment}{                 *   the write pointer to a new block.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00236}00236 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00237}00237                 \textcolor{keywordflow}{if} (cend == TTYOUTQ\_DATASIZE || cend == to-\/>to\_end) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00238}00238                         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00239}00239 \textcolor{comment}{                         * Fast path: zero copy. Remove the first block,}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00240}00240 \textcolor{comment}{                         * so we can unlock the TTY temporarily.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00241}00241 \textcolor{comment}{                         */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00242}00242                         \mbox{\hyperlink{tty__outq_8c_a79e20cb01077879e37e897835bc6e6d7}{TTYOUTQ\_REMOVE\_HEAD}}(to);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00243}00243                         to-\/>to\_begin = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00244}00244                         \textcolor{keywordflow}{if} (to-\/>to\_end <= TTYOUTQ\_DATASIZE)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00245}00245                                 to-\/>to\_end = 0;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00246}00246                         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00247}00247                                 to-\/>to\_end -\/= TTYOUTQ\_DATASIZE;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00248}00248 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00249}00249                         \textcolor{comment}{/* Temporary unlock and copy the data to userspace. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00250}00250                         tty\_unlock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00251}00251                         error = \mbox{\hyperlink{subr__uio_8c_aa4232d34ca9bc2bc4786b368c5de60c9}{uiomove}}(tob-\/>\mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{tob\_data}} + cbegin, clen, uio);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00252}00252                         tty\_lock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00253}00253 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00254}00254                         \textcolor{comment}{/* Block can now be readded to the list. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00255}00255                         \mbox{\hyperlink{tty__outq_8c_a096691a2465ac6f1052efc3e036f5c77}{TTYOUTQ\_RECYCLE}}(to, tob);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00256}00256                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00257}00257                         \textcolor{keywordtype}{char} ob[TTYOUTQ\_DATASIZE -\/ 1];}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00258}00258 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00259}00259                         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00260}00260 \textcolor{comment}{                         * Slow path: store data in a temporary buffer.}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00261}00261 \textcolor{comment}{                         */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00262}00262                         memcpy(ob, tob-\/>\mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{tob\_data}} + cbegin, clen);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00263}00263                         to-\/>to\_begin += clen;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00264}00264                         MPASS(to-\/>to\_begin < TTYOUTQ\_DATASIZE);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00265}00265 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00266}00266                         \textcolor{comment}{/* Temporary unlock and copy the data to userspace. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00267}00267                         tty\_unlock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00268}00268                         error = \mbox{\hyperlink{subr__uio_8c_aa4232d34ca9bc2bc4786b368c5de60c9}{uiomove}}(ob, clen, uio);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00269}00269                         tty\_lock(tp);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00270}00270                 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00271}00271 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00272}00272                 \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00273}00273                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00274}00274         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00275}00275 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00276}00276         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00277}00277 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00278}00278 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00279}00279 \textcolor{keywordtype}{size\_t}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00280}\mbox{\hyperlink{tty__outq_8c_aea732bcec93c957a9b0ca8e219e5faec}{00280}} \mbox{\hyperlink{tty__outq_8c_aea732bcec93c957a9b0ca8e219e5faec}{ttyoutq\_write}}(\textcolor{keyword}{struct} ttyoutq *to, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *\mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}}, \textcolor{keywordtype}{size\_t} \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}})}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00281}00281 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00282}00282         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *cbuf = \mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00283}00283         \textcolor{keyword}{struct }\mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}} *tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00284}00284         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} boff;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00285}00285         \textcolor{keywordtype}{size\_t} l;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00286}00286 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00287}00287         \textcolor{keywordflow}{while} (\mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}} > 0) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00288}00288                 boff = to-\/>to\_end \% TTYOUTQ\_DATASIZE;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00289}00289 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00290}00290                 \textcolor{keywordflow}{if} (to-\/>to\_end == 0) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00291}00291                         \textcolor{comment}{/* First time we're being used or drained. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00292}00292                         MPASS(to-\/>to\_begin == 0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00293}00293                         tob = to-\/>to\_firstblock;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00294}00294                         \textcolor{keywordflow}{if} (tob == NULL) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00295}00295                                 \textcolor{comment}{/* Queue has no blocks. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00296}00296                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00297}00297                         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00298}00298                         to-\/>to\_lastblock = tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00299}00299                 \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (boff == 0) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00300}00300                         \textcolor{comment}{/* We reached the end of this block on last write. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00301}00301                         tob = to-\/>to\_lastblock-\/>\mbox{\hyperlink{structttyoutq__block_add8032693f7540e3e0350ee06bb05f45}{tob\_next}};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00302}00302                         \textcolor{keywordflow}{if} (tob == NULL) \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00303}00303                                 \textcolor{comment}{/* We've reached the watermark. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00304}00304                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00305}00305                         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00306}00306                         to-\/>to\_lastblock = tob;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00307}00307                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00308}00308                         tob = to-\/>to\_lastblock;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00309}00309                 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00310}00310 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00311}00311                 \textcolor{comment}{/* Don't copy more than was requested. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00312}00312                 l = MIN(\mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}}, TTYOUTQ\_DATASIZE -\/ boff);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00313}00313                 MPASS(l > 0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00314}00314                 memcpy(tob-\/>\mbox{\hyperlink{structttyoutq__block_a6f8b5c7873baf3bc9d4a2028c409701c}{tob\_data}} + boff, cbuf, l);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00315}00315 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00316}00316                 cbuf += l;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00317}00317                 \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}} -\/= l;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00318}00318                 to-\/>to\_end += l;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00319}00319         \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00320}00320 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00321}00321         \textcolor{keywordflow}{return} (cbuf -\/ (\textcolor{keyword}{const} \textcolor{keywordtype}{char} *)\mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}});}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00322}00322 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00323}00323 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00324}00324 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00325}\mbox{\hyperlink{tty__outq_8c_a1d6bea834eb8805735e10a3f594d33b8}{00325}} \mbox{\hyperlink{tty__outq_8c_a1d6bea834eb8805735e10a3f594d33b8}{ttyoutq\_write\_nofrag}}(\textcolor{keyword}{struct} ttyoutq *to, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *\mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}}, \textcolor{keywordtype}{size\_t} \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}})}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00326}00326 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00327}00327         \textcolor{keywordtype}{size\_t} ret \_\_unused;}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00328}00328 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00329}00329         \textcolor{keywordflow}{if} (ttyoutq\_bytesleft(to) < \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}})}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00330}00330                 \textcolor{keywordflow}{return} (-\/1);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00331}00331 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00332}00332         \textcolor{comment}{/* We should always be able to write it back. */}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00333}00333         ret = \mbox{\hyperlink{tty__outq_8c_aea732bcec93c957a9b0ca8e219e5faec}{ttyoutq\_write}}(to, \mbox{\hyperlink{vfs__syscalls_8c_a6defe41b89c760943b86089ec1838319}{buf}}, \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}});}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00334}00334         MPASS(ret == \mbox{\hyperlink{vfs__extattr_8c_a871dfd9f7374995e216460d4e64c1c64}{nbytes}});}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00335}00335 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00336}00336         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00337}00337 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00338}00338 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00339}00339 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00340}\mbox{\hyperlink{tty__outq_8c_a1f30747b88c3a851219aaff9967bb623}{00340}} \mbox{\hyperlink{tty__outq_8c_a1f30747b88c3a851219aaff9967bb623}{ttyoutq\_startup}}(\textcolor{keywordtype}{void} *\mbox{\hyperlink{uipc__sockbuf_8c_a7c1d654b7b6114d7a0abc8d351dd1bcd}{dummy}})}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00341}00341 \{}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00342}00342 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00343}00343         \mbox{\hyperlink{tty__outq_8c_a8beca3f21722d1964fe293738d394ae0}{ttyoutq\_zone}} = uma\_zcreate(\textcolor{stringliteral}{"{}ttyoutq"{}}, \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} \mbox{\hyperlink{structttyoutq__block}{ttyoutq\_block}}),}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00344}00344             NULL, NULL, NULL, NULL, UMA\_ALIGN\_PTR, 0);}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00345}00345 \}}
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00346}00346 }
\DoxyCodeLine{\Hypertarget{tty__outq_8c_source_l00347}\mbox{\hyperlink{tty__outq_8c_a945f34a6352d56ad81c364775356e3f7}{00347}} \mbox{\hyperlink{tty__outq_8c_a945f34a6352d56ad81c364775356e3f7}{SYSINIT}}(ttyoutq, SI\_SUB\_DRIVERS, SI\_ORDER\_FIRST, \mbox{\hyperlink{tty__outq_8c_a1f30747b88c3a851219aaff9967bb623}{ttyoutq\_startup}}, NULL);}

\end{DoxyCode}
