30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Language Tools Libraries<br />

DS51456B-page 214<br />

2004 Microchip Technology Inc.<br />

4.9 NON-LOCAL JUMPS<br />

The header file setjmp.hconsists of a type, a macro anda function that allow<br />

control<br />

transfers to occur that bypass the normal function call and return process.<br />

jmp_buf<br />

Description: A type that is an array used by setjmpand longjmpto save and<br />

restore the program environment.<br />

Include: <br />

Prototype: typedef int jmp_buf[_NSETJMP];<br />

Remarks: _NSETJMPis defined as 16 + 2 that represents 16 registers and a<br />

32-bit return address.<br />

setjmp<br />

Description: A macro that saves the current state of the program for later use by<br />

longjmp.<br />

Include: <br />

Prototype: #define setjmp(jmp_buf env)<br />

Argument: env variable where environment is stored<br />

Return Value: If the return is from a direct call, setjmpreturns zero. If the return<br />

is<br />

from a call to longjmp, setjmpreturns a non-zero value.<br />

Note:If the argument valfrom longjmpis 0, setjmpreturns 1.<br />

Example: See longjmp.<br />

longjmp<br />

Description: A function that restores the environment saved by setjmp.<br />

Include: <br />

Prototype: void longjmp(jmp_buf env, int val);<br />

Arguments: env variable where environment is stored<br />

val value to be returned to setjmp call.<br />

Remarks: The value parameter valshould be non-zero. If longjmpis invoked<br />

from a nested signal handler (that is, invoked as a result of a signal<br />

raised during the handling of another signal), the behavior is undefined.<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 215<br />

4.10 SIGNAL HANDLING<br />

The header file signal.hconsists of a type, several macros and two functions that<br />

specify how the program handles signals while it is executing. A signal is a<br />

condition<br />

that may be reported during the program execution. Signals are synchronous,<br />

occurring under software control via the raisefunction.<br />

bởi<br />

một chức năng người dùng định nghĩa các hành động xử lý tín hiệu. Xem<br />

signalfor<br />

một ví dụ về một người dùng xác định chức năng.<br />

Ví dụ: # include / * Forraise, SIGILL * /<br />

# include / * Cho printf * /<br />

int main (void)<br />

{<br />

nâng cao (SIGILL);<br />

printf ("Chương trình không bao giờ đạt ở đây");<br />

}<br />

Đầu ra:<br />

ILL<br />

Giải thích:<br />

ILL là viết tắt của "hướng dẫn bất hợp pháp".<br />

SIGINT<br />

Mô tả: tín hiệu ngắt.<br />

Bao gồm:<br />

Prototype: # define SIGINT<br />

Bình luận: SIGINTis sử dụng như một tham số cho raiseand / hoặc tín hiệu. Kh<br />

được sử dụng, hành vi mặc định là in một thông bị gián đoạn và<br />

chấm dứt chương trình gọi điện thoại. Thismay được ghi đè bởi một người dùng<br />

chức năng xác định các hành động xử lý tín hiệu. Xem signalfor một<br />

ví dụ về một người dùng xác định chức năng.<br />

Ví dụ: # include / * Forraise, SIGINT * /<br />

# include / * Cho printf * /<br />

int main (void)<br />

{<br />

nâng cao (SIGINT);<br />

printf ("Chương trình không bao giờ đạt ở đây.");<br />

}<br />

Đầu ra:<br />

INT<br />

Giải thích:<br />

INT là viết tắt của "gián đoạn".<br />

dsPIC<br />

®<br />

Thư viện Công cụ Ngôn ngữ<br />

DS51456B trang 218<br />

SIGSEGV<br />

2004 Microchip Technology Inc

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!