1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <asm/setjmp.h>
6 * struct resume_data - data for resume after interrupt
9 /** @jump: longjmp buffer */
11 /** @code: exception code */
16 * set_resume() - set longjmp buffer for resuming after exception
18 * By calling this function it is possible to use a long jump to catch an
19 * exception. The caller sets the long jump buffer with set_resume() and then
20 * executes setjmp(). If an exception occurs, the code will return to the
21 * setjmp caller(). The exception code will be returned in @data->code.
23 * After the critical operation call set_resume(NULL) so that an exception in
24 * another part of the code will not accidently invoke the long jump.
28 * // This example shows how to use set_resume().
30 * struct resume_data resume;
33 * set_resume(&resume);
34 * ret = setjmp(resume.jump);
36 * printf("An exception %ld occurred\n", resume.code);
38 * // Do what might raise an exception here.
42 * @data: pointer to structure with longjmp address
43 * Return: 0 before an exception, 1 after an exception occurred
45 void set_resume(struct resume_data *data);