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

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

?? library_20.html

?? linux_c函數(shù),linux下編程必備的
?? 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一区二区三区免费野_久草精品视频
欧美日韩精品久久久| 欧美精品一区二区在线播放| 宅男在线国产精品| 中文字幕一区二区三区精华液 | 成人一道本在线| 337p亚洲精品色噜噜狠狠| 国产精品国产精品国产专区不蜜 | 在线视频你懂得一区| 日韩欧美一级片| 亚洲国产中文字幕在线视频综合| 国产在线精品视频| 欧美年轻男男videosbes| 国产精品进线69影院| 蜜桃视频第一区免费观看| 欧美视频一区二区在线观看| 国产日韩欧美一区二区三区乱码 | 亚洲自拍偷拍av| 懂色中文一区二区在线播放| 欧美大片国产精品| 石原莉奈在线亚洲三区| 欧美三级欧美一级| 亚洲精品国产品国语在线app| 国产成人av电影在线播放| 2024国产精品视频| 精品一区二区久久| 精品国产乱码久久久久久久久 | 久久久.com| 国产精品自拍三区| 久久久久久一级片| 黑人精品欧美一区二区蜜桃| 日韩一级免费观看| 久久激情五月激情| 精品粉嫩超白一线天av| 国内一区二区在线| 久久精品视频免费观看| 国产成人免费视频网站高清观看视频| 日韩精品一区二区三区蜜臀| 久久se精品一区精品二区| 日韩午夜电影在线观看| 美国三级日本三级久久99| 日韩一级大片在线观看| 激情文学综合丁香| 国产清纯在线一区二区www| 国产成人综合在线| 亚洲视频综合在线| 91久久线看在观草草青青| 伊人性伊人情综合网| 欧美日韩国产影片| 全国精品久久少妇| 久久久精品免费免费| 成人综合婷婷国产精品久久| 国产精品久久久久一区二区三区| 99久久精品一区| 亚洲国产精品久久久久秋霞影院| 欧美裸体bbwbbwbbw| 裸体歌舞表演一区二区| 国产女人18毛片水真多成人如厕| 9l国产精品久久久久麻豆| 夜夜嗨av一区二区三区| 日韩三级在线免费观看| 国产高清不卡一区| 亚洲精品久久嫩草网站秘色| 日韩一区二区麻豆国产| 成人精品视频一区二区三区 | 色天使色偷偷av一区二区| 天天射综合影视| 国产欧美日韩精品a在线观看| 91女厕偷拍女厕偷拍高清| 喷水一区二区三区| 中文字幕在线不卡国产视频| 欧美老女人在线| 成人综合激情网| 日本va欧美va精品发布| 亚洲视频小说图片| 精品国产网站在线观看| 色婷婷av一区| av色综合久久天堂av综合| 亚洲成人免费看| 国产精品系列在线| 精品蜜桃在线看| 欧洲国内综合视频| 丁香五精品蜜臀久久久久99网站| 亚洲国产中文字幕在线视频综合| 国产女主播在线一区二区| 91精品国产综合久久小美女| 91性感美女视频| 国产老女人精品毛片久久| 天天av天天翘天天综合网| 欧美激情一区二区三区蜜桃视频 | 欧洲一区在线观看| 国产风韵犹存在线视精品| 日本中文字幕一区| 亚洲黄色免费电影| 国产精品热久久久久夜色精品三区| 欧美一区二区三区性视频| 91黄色激情网站| 色综合久久久久| jlzzjlzz欧美大全| 国产成人啪免费观看软件| 奇米影视一区二区三区| 亚洲午夜视频在线| 亚洲精选一二三| 国产精品青草久久| 欧美激情艳妇裸体舞| 欧美精品一区二区三区久久久| 欧美丰满少妇xxxbbb| 欧美性三三影院| 欧美性受xxxx| 欧洲一区在线电影| 欧美日韩亚洲综合在线| 91黄色免费看| 欧美在线你懂的| 欧美色欧美亚洲另类二区| 在线中文字幕一区二区| 91免费国产在线观看| 91美女福利视频| 91女人视频在线观看| 91年精品国产| 在线观看91精品国产入口| 欧美日韩一区在线观看| 欧美日韩精品福利| 欧美一级电影网站| 337p粉嫩大胆色噜噜噜噜亚洲| 精品国产乱码91久久久久久网站| 久久中文字幕电影| 国产女主播在线一区二区| 国产精品福利在线播放| 亚洲男人的天堂av| 亚洲大片一区二区三区| 五月天婷婷综合| 久草中文综合在线| 国产1区2区3区精品美女| 91亚洲精华国产精华精华液| 在线视频欧美精品| 日韩视频在线永久播放| 久久色视频免费观看| 中文字幕欧美日韩一区| 亚洲精品国久久99热| 日本美女一区二区三区视频| 久久97超碰国产精品超碰| 国产高清久久久| 色猫猫国产区一区二在线视频| 在线播放一区二区三区| 精品久久国产字幕高潮| 中文字幕一区在线观看| 天天色综合成人网| 丁香六月综合激情| 色老头久久综合| 精品久久人人做人人爽| 中文字幕一区二区三区精华液| 午夜天堂影视香蕉久久| 国内精品久久久久影院薰衣草| 97aⅴ精品视频一二三区| 精品视频999| 国产女同互慰高潮91漫画| 亚洲影视在线播放| 国产伦精品一区二区三区在线观看| 91网上在线视频| 日韩亚洲国产中文字幕欧美| 国产精品剧情在线亚洲| 日韩精品电影一区亚洲| 国产91精品精华液一区二区三区| 91极品美女在线| 国产丝袜美腿一区二区三区| 亚洲午夜久久久久久久久电影网 | 成人a级免费电影| 欧美日韩夫妻久久| 国产精品久久久久aaaa| 毛片av一区二区三区| 色噜噜狠狠色综合中国| 国产欧美日韩综合精品一区二区| 亚洲午夜视频在线| 91在线无精精品入口| 久久久精品日韩欧美| 日韩成人伦理电影在线观看| 99视频一区二区三区| 久久毛片高清国产| 日韩—二三区免费观看av| 色综合色狠狠综合色| 欧美国产日韩a欧美在线观看| 麻豆精品一二三| 在线播放亚洲一区| 亚洲高清免费在线| 色婷婷久久99综合精品jk白丝| 国产精品视频第一区| 国内精品伊人久久久久av一坑 | 99这里都是精品| 国产精品私人影院| 国产黄色精品网站| 国产精品视频麻豆| 国产盗摄女厕一区二区三区| 精品国产亚洲在线| 久久成人久久鬼色| 欧美v日韩v国产v| 免费精品视频在线| 91精品国产高清一区二区三区| 亚洲不卡在线观看| 欧美日韩视频在线观看一区二区三区| 亚洲免费观看在线视频| 91老师国产黑色丝袜在线|