亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_20.html

?? Glibc的中文手冊
?? HTML
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Non-Local Exits</TITLE>
<P>Go to the <A HREF="library_19.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html">previous</A>, <A HREF="library_21.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html">next</A> section.<P>
<A NAME="IDX1442"></A>
<A NAME="IDX1443"></A>
<H1><A NAME="SEC326" HREF="library_toc.html#SEC326" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC326">Non-Local Exits</A></H1>
<P>
Sometimes when your program detects an unusual situation inside a deeply
nested set of function calls, you would like to be able to immediately
return to an outer level of control.  This section describes how you can
do such <DFN>non-local exits</DFN> using the <CODE>setjmp</CODE> and <CODE>longjmp</CODE>
functions.
<P>
<H2><A NAME="SEC327" HREF="library_toc.html#SEC327" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC327">Introduction to Non-Local Exits</A></H2>
<P>
As an example of a situation where a non-local exit can be useful,
suppose you have an interactive program that has a "main loop" that
prompts for and executes commands.  Suppose the "read" command reads
input from a file, doing some lexical analysis and parsing of the input
while processing it.  If a low-level input error is detected, it would
be useful to be able to return immediately to the "main loop" instead
of having to make each of the lexical analysis, parsing, and processing
phases all have to explicitly deal with error situations initially
detected by nested calls.
<P>
(On the other hand, if each of these phases has to do a substantial
amount of cleanup when it exits--such as closing files, deallocating
buffers or other data structures, and the like--then it can be more
appropriate to do a normal return and have each phase do its own
cleanup, because a non-local exit would bypass the intervening phases and
their associated cleanup code entirely.  Alternatively, you could use a
non-local exit but do the cleanup explicitly either before or after
returning to the "main loop".)
<P>
In some ways, a non-local exit is similar to using the <SAMP>`return'</SAMP>
statement to return from a function.  But while <SAMP>`return'</SAMP> abandons
only a single function call, transferring control back to the point at
which it was called, a non-local exit can potentially abandon many
levels of nested function calls.
<P>
You identify return points for non-local exits calling the function
<CODE>setjmp</CODE>.  This function saves information about the execution
environment in which the call to <CODE>setjmp</CODE> appears in an object of
type <CODE>jmp_buf</CODE>.  Execution of the program continues normally after
the call to <CODE>setjmp</CODE>, but if a exit is later made to this return
point by calling <CODE>longjmp</CODE> with the corresponding <CODE>jmp_buf</CODE>
object, control is transferred back to the point where <CODE>setjmp</CODE> was
called.  The return value from <CODE>setjmp</CODE> is used to distinguish
between an ordinary return and a return made by a call to
<CODE>longjmp</CODE>, so calls to <CODE>setjmp</CODE> usually appear in an <SAMP>`if'</SAMP>
statement.
<P>
Here is how the example program described above might be set up:  
<P>
<PRE>
#include &#60;setjmp.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;stdio.h&#62;

jmp_buf main_loop;

void 
abort_to_main_loop (int status)
{
  longjmp (main_loop, status);
}

int
main (void)
{
  while (1)
    if (setjmp (main_loop))
      puts ("Back at main loop....");
    else
      do_command ();
}


void 
do_command (void)
{
  char buffer[128];
  if (fgets (buffer, 128, stdin) == NULL)
    abort_to_main_loop (-1);
  else
    exit (EXIT_SUCCESS);
}
</PRE>
<P>
The function <CODE>abort_to_main_loop</CODE> causes an immediate transfer of
control back to the main loop of the program, no matter where it is
called from.
<P>
The flow of control inside the <CODE>main</CODE> function may appear a little
mysterious at first, but it is actually a common idiom with
<CODE>setjmp</CODE>.  A normal call to <CODE>setjmp</CODE> returns zero, so the
"else" clause of the conditional is executed.  If
<CODE>abort_to_main_loop</CODE> is called somewhere within the execution of
<CODE>do_command</CODE>, then it actually appears as if the <EM>same</EM> call
to <CODE>setjmp</CODE> in <CODE>main</CODE> were returning a second time with a value
of <CODE>-1</CODE>.
<P>
So, the general pattern for using <CODE>setjmp</CODE> looks something like:
<P>
<PRE>
if (setjmp (<VAR>buffer</VAR>))
  /* Code to clean up after premature return. */
  ...
else
  /* Code to be executed normally after setting up the return point. */
  ...
</PRE>
<P>
<H2><A NAME="SEC328" HREF="library_toc.html#SEC328" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC328">Details of Non-Local Exits</A></H2>
<P>
Here are the details on the functions and data structures used for
performing non-local exits.  These facilities are declared in
<TT>`setjmp.h'</TT>.
<A NAME="IDX1444"></A>
<P>
<A NAME="IDX1445"></A>
<U>Data Type:</U> <B>jmp_buf</B><P>
Objects of type <CODE>jmp_buf</CODE> hold the state information to
be restored by a non-local exit.  The contents of a <CODE>jmp_buf</CODE>
identify a specific place to return to.
<P>
<A NAME="IDX1446"></A>
<U>Macro:</U> int <B>setjmp</B> <I>(jmp_buf <VAR>state</VAR>)</I><P>
When called normally, <CODE>setjmp</CODE> stores information about the
execution state of the program in <VAR>state</VAR> and returns zero.  If
<CODE>longjmp</CODE> is later used to perform a non-local exit to this
<VAR>state</VAR>, <CODE>setjmp</CODE> returns a nonzero value.
<P>
<A NAME="IDX1447"></A>
<U>Function:</U> void <B>longjmp</B> <I>(jmp_buf <VAR>state</VAR>, int <VAR>value</VAR>)</I><P>
This function restores current execution to the state saved in
<VAR>state</VAR>, and continues execution from the call to <CODE>setjmp</CODE> that
established that return point.  Returning from <CODE>setjmp</CODE> by means of
<CODE>longjmp</CODE> returns the <VAR>value</VAR> argument that was passed to
<CODE>longjmp</CODE>, rather than <CODE>0</CODE>.  (But if <VAR>value</VAR> is given as
<CODE>0</CODE>, <CODE>setjmp</CODE> returns <CODE>1</CODE>).<P>
There are a lot of obscure but important restrictions on the use of
<CODE>setjmp</CODE> and <CODE>longjmp</CODE>.  Most of these restrictions are
present because non-local exits require a fair amount of magic on the
part of the C compiler and can interact with other parts of the language
in strange ways.
<P>
The <CODE>setjmp</CODE> function is actually a macro without an actual
function definition, so you shouldn't try to <SAMP>`#undef'</SAMP> it or take
its address.  In addition, calls to <CODE>setjmp</CODE> are safe in only the
following contexts:
<P>
<UL>
<LI>
As the test expression of a selection or iteration
statement (such as <SAMP>`if'</SAMP> or <SAMP>`while'</SAMP>).
<P>
<LI>
As one operand of a equality or comparison operator that appears as the
test expression of a selection or iteration statement.  The other
operand must be an integer constant expression.
<P>
<LI>
As the operand of a unary <SAMP>`!'</SAMP> operator, that appears as the
test expression of a selection or iteration statement.
<P>
<LI>
By itself as an expression statement.
</UL>
<P>
Return points are valid only during the dynamic extent of the function
that called <CODE>setjmp</CODE> to establish them.  If you <CODE>longjmp</CODE> to
a return point that was established in a function that has already
returned, unpredictable and disastrous things are likely to happen.
<P>
You should use a nonzero <VAR>value</VAR> argument to <CODE>longjmp</CODE>.  While
<CODE>longjmp</CODE> refuses to pass back a zero argument as the return value
from <CODE>setjmp</CODE>, this is intended as a safety net against accidental
misuse and is not really good programming style.
<P>
When you perform a non-local exit, accessible objects generally retain
whatever values they had at the time <CODE>longjmp</CODE> was called.  The
exception is that the values of automatic variables local to the
function containing the <CODE>setjmp</CODE> call that have been changed since
the call to <CODE>setjmp</CODE> are indeterminate, unless you have declared
them <CODE>volatile</CODE>.
<P>
<H2><A NAME="SEC329" HREF="library_toc.html#SEC329" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC329">Non-Local Exits and Signals</A></H2>
<P>
In BSD Unix systems, <CODE>setjmp</CODE> and <CODE>longjmp</CODE> also save and
restore the set of blocked signals; see section <A HREF="library_21.html#SEC368" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC368">Blocking Signals</A>.  However,
the POSIX.1 standard requires <CODE>setjmp</CODE> and <CODE>longjmp</CODE> not to
change the set of blocked signals, and provides an additional pair of
functions (<CODE>sigsetjmp</CODE> and <CODE>sigsetjmp</CODE>) to get the BSD
behavior.
<P>
The behavior of <CODE>setjmp</CODE> and <CODE>longjmp</CODE> in the GNU library is
controlled by feature test macros; see section <A HREF="library_1.html#SEC12" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_1.html#SEC12">Feature Test Macros</A>.  The
default in the GNU system is the POSIX.1 behavior rather than the BSD
behavior.
<P>
The facilities in this section are declared in the header file
<TT>`setjmp.h'</TT>.
<A NAME="IDX1448"></A>
<P>
<A NAME="IDX1449"></A>
<U>Data Type:</U> <B>sigjmp_buf</B><P>
This is similar to <CODE>jmp_buf</CODE>, except that it can also store state
information about the set of blocked signals.
<P>
<A NAME="IDX1450"></A>
<U>Function:</U> int <B>sigsetjmp</B> <I>(sigjmp_buf <VAR>state</VAR>, int <VAR>savesigs</VAR>)</I><P>
This is similar to <CODE>setjmp</CODE>.  If <VAR>savesigs</VAR> is nonzero, the set
of blocked signals is saved in <VAR>state</VAR> and will be restored if a
<CODE>siglongjmp</CODE> is later performed with this <VAR>state</VAR>.
<P>
<A NAME="IDX1451"></A>
<U>Function:</U> void <B>siglongjmp</B> <I>(sigjmp_buf <VAR>state</VAR>, int <VAR>value</VAR>)</I><P>
This is similar to <CODE>longjmp</CODE> except for the type of its <VAR>state</VAR>
argument.  If the <CODE>sigsetjmp</CODE> call that set this <VAR>state</VAR> used a
nonzero <VAR>savesigs</VAR> flag, <CODE>siglongjmp</CODE> also restores the set of
blocked signals.
<P>
<P>Go to the <A HREF="library_19.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html">previous</A>, <A HREF="library_21.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html">next</A> section.<P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成a人v欧美综合天堂| 精品粉嫩超白一线天av| 亚洲精品国产一区二区精华液 | 欧美中文字幕一二三区视频| 亚洲欧洲中文日韩久久av乱码| www.亚洲色图.com| 亚洲伊人伊色伊影伊综合网| 欧美精三区欧美精三区| 另类小说一区二区三区| 国产欧美综合在线观看第十页| 成人一区二区三区视频在线观看| 国产精品日日摸夜夜摸av| 91小视频在线观看| 亚洲一区二区三区国产| 日韩欧美色综合| 成人污视频在线观看| 一区二区三区在线播放| 91精品国产综合久久精品性色| 国内欧美视频一区二区| 国产精品成人免费在线| 欧美日韩国产综合一区二区三区| 人人爽香蕉精品| 亚洲国产精品ⅴa在线观看| 色天天综合久久久久综合片| 不卡视频一二三四| 亚洲国产精品久久久久婷婷884| 91精品免费在线| 风流少妇一区二区| 亚洲亚洲精品在线观看| 国产亚洲福利社区一区| 欧美吻胸吃奶大尺度电影 | 色综合久久综合网欧美综合网| 一区二区三区美女| 欧美精品一区二区三区蜜桃视频| 不卡一区中文字幕| 蜜桃精品在线观看| 亚洲乱码国产乱码精品精98午夜| 欧美一级淫片007| 99久久精品国产导航| 麻豆成人久久精品二区三区红 | 狠狠色狠狠色合久久伊人| 亚洲免费观看视频| 26uuu国产在线精品一区二区| av午夜一区麻豆| 久久99精品久久只有精品| 亚洲黄色小视频| 久久久久久久综合| 91精品国产免费| 色综合久久久网| 国产呦萝稀缺另类资源| 偷拍一区二区三区四区| 亚洲色大成网站www久久九九| 日韩精品中文字幕一区二区三区 | 欧美丰满少妇xxxxx高潮对白| 国产福利一区二区| 毛片av一区二区| 天堂av在线一区| 亚洲色图一区二区| 中文字幕巨乱亚洲| 久久久久久黄色| 日韩免费观看2025年上映的电影| 91黄色免费网站| 91免费视频网| 成人污污视频在线观看| 国产麻豆精品theporn| 另类的小说在线视频另类成人小视频在线 | 国产夫妻精品视频| 九九久久精品视频| 久久99热狠狠色一区二区| 日韩高清在线电影| 日韩成人伦理电影在线观看| 亚洲高清三级视频| 午夜a成v人精品| 亚洲线精品一区二区三区| 亚洲一区二区视频在线观看| 亚洲六月丁香色婷婷综合久久| 亚洲人成精品久久久久久| 亚洲人成网站影音先锋播放| 17c精品麻豆一区二区免费| 国产精品天天摸av网| 日本一区二区三区国色天香| 国产日韩av一区| 国产精品萝li| 一区二区三区自拍| 亚洲高清免费观看高清完整版在线观看| 亚洲激情一二三区| 亚洲成av人片| 日本不卡视频在线观看| 日韩中文字幕不卡| 老司机免费视频一区二区| 久久99精品国产.久久久久| 精品系列免费在线观看| 国产在线播精品第三| 国产一区二区三区蝌蚪| 高清免费成人av| 91老司机福利 在线| 欧美三级电影精品| 91麻豆精品久久久久蜜臀| 91麻豆精品国产91久久久久久| 精品久久免费看| 国产精品久久久久久一区二区三区 | 日韩一区二区免费视频| 精品久久久久久久一区二区蜜臀| 久久综合九色综合欧美就去吻| 中文一区在线播放| 一区二区日韩电影| 琪琪一区二区三区| 国产91露脸合集magnet| 91视频国产观看| 欧美一级欧美三级在线观看| 久久久精品天堂| 亚洲另类春色国产| 视频在线观看一区| 久久99精品久久久久婷婷| 波多野洁衣一区| 欧美精品色一区二区三区| 2021中文字幕一区亚洲| 亚洲色图制服丝袜| 精品一区二区免费| 91麻豆高清视频| 日韩精品一区二区三区视频在线观看 | 亚洲色图欧美偷拍| 激情五月激情综合网| 91成人在线精品| 久久综合色播五月| 亚洲国产日韩在线一区模特| 国产精品一级黄| 欧美日韩高清一区二区不卡| 久久久一区二区| 香蕉久久一区二区不卡无毒影院 | 精品久久久久久无| 一区二区三区四区乱视频| 精品一区二区三区免费毛片爱| 欧洲精品中文字幕| 国产农村妇女精品| 精品一区二区三区在线观看| 欧美日免费三级在线| 日本一区二区不卡视频| 日韩av一区二区在线影视| 色综合久久久久综合| 国产日韩欧美亚洲| 秋霞电影网一区二区| 欧洲一区二区三区在线| 国产精品女主播av| 国产呦萝稀缺另类资源| 欧美一级午夜免费电影| 亚洲国产欧美另类丝袜| 色又黄又爽网站www久久| 欧美国产丝袜视频| 国产一区福利在线| 欧美一区二区三区视频免费| 亚洲国产视频一区二区| 色婷婷亚洲精品| 亚洲色图在线播放| a亚洲天堂av| 国产欧美日韩久久| 国产专区欧美精品| www久久精品| 国产尤物一区二区在线| 久久久影院官网| 国产一区二区免费在线| 精品国产乱码久久| 久久国产精品第一页| 精品美女被调教视频大全网站| 蜜臀99久久精品久久久久久软件| 在线播放91灌醉迷j高跟美女| 亚洲一区中文在线| 欧美视频一区二区三区在线观看| 亚洲欧美日韩在线| 色综合天天综合| 亚洲精品欧美二区三区中文字幕| 色婷婷综合久久久久中文一区二区 | 一区二区欧美精品| 欧美性色欧美a在线播放| 一区二区免费在线| 欧美日韩国产一级| 热久久一区二区| 精品国产亚洲在线| 国产一区二区三区四| 国产精品视频一区二区三区不卡| 丁香亚洲综合激情啪啪综合| 国产精品乱码久久久久久| 91在线视频观看| 亚洲一本大道在线| 欧美一区二区精美| 国产麻豆成人传媒免费观看| 欧美激情艳妇裸体舞| 色网综合在线观看| 日本亚洲欧美天堂免费| 精品国产乱码久久| 99精品欧美一区二区蜜桃免费| 亚洲欧美日韩国产中文在线| 欧美情侣在线播放| 精品一区二区三区在线观看国产 | 一区二区三区毛片| 欧美一区在线视频| 国产成人aaa| 亚洲第一搞黄网站| 久久精品一区四区| 欧美日韩综合在线|