/usr/lib/avr/include/setjmp.h is in avr-libc 1:2.0.0+Atmel3.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /* Copyright (c) 2002,2007 Marek Michalkiewicz
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* $Id$ */
#ifndef __SETJMP_H_
#define __SETJMP_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
jmp_buf:
offset size description
0 16/2 call-saved registers (r2-r17)
(AVR_TINY arch has only 2 call saved registers (r18,r19))
16/2 2 frame pointer (r29:r28)
18/4 2 stack pointer (SPH:SPL)
20/6 1 status register (SREG)
21/7 2/3 return address (PC) (2 bytes used for <=128Kw flash)
23/24/9 = total size (AVR_TINY arch always has 2 bytes PC)
*/
#if !defined(__DOXYGEN__)
#if defined(__AVR_TINY__)
# define _JBLEN 9
#elif defined(__AVR_3_BYTE_PC__) && __AVR_3_BYTE_PC__
# define _JBLEN 24
#else
# define _JBLEN 23
#endif
typedef struct _jmp_buf { unsigned char _jb[_JBLEN]; } jmp_buf[1];
#endif /* not __DOXYGEN__ */
/** \file */
/** \defgroup setjmp <setjmp.h>: Non-local goto
While the C language has the dreaded \c goto statement, it can only be
used to jump to a label in the same (local) function. In order to jump
directly to another (non-local) function, the C library provides the
setjmp() and longjmp() functions. setjmp() and longjmp() are useful for
dealing with errors and interrupts encountered in a low-level subroutine
of a program.
\note setjmp() and longjmp() make programs hard to understand and maintain.
If possible, an alternative should be used.
\note longjmp() can destroy changes made to global register
variables (see \ref faq_regbind).
For a very detailed discussion of setjmp()/longjmp(), see Chapter 7 of
<em>Advanced Programming in the UNIX Environment</em>, by W. Richard
Stevens.
Example:
\code
#include <setjmp.h>
jmp_buf env;
int main (void)
{
if (setjmp (env))
{
... handle error ...
}
while (1)
{
... main processing loop which calls foo() some where ...
}
}
...
void foo (void)
{
... blah, blah, blah ...
if (err)
{
longjmp (env, 1);
}
}
\endcode */
#if !(defined(__ATTR_NORETURN__) || defined(__DOXYGEN__))
#define __ATTR_NORETURN__ __attribute__((__noreturn__))
#endif
/** \ingroup setjmp
\brief Save stack context for non-local goto.
\code #include <setjmp.h>\endcode
setjmp() saves the stack context/environment in \e __jmpb for later use by
longjmp(). The stack context will be invalidated if the function which
called setjmp() returns.
\param __jmpb Variable of type \c jmp_buf which holds the stack
information such that the environment can be restored.
\returns setjmp() returns 0 if returning directly, and
non-zero when returning from longjmp() using the saved context. */
extern int setjmp(jmp_buf __jmpb);
/** \ingroup setjmp
\brief Non-local jump to a saved stack context.
\code #include <setjmp.h>\endcode
longjmp() restores the environment saved by the last call of setjmp() with
the corresponding \e __jmpb argument. After longjmp() is completed,
program execution continues as if the corresponding call of setjmp() had
just returned the value \e __ret.
\note longjmp() cannot cause 0 to be returned. If longjmp() is invoked
with a second argument of 0, 1 will be returned instead.
\param __jmpb Information saved by a previous call to setjmp().
\param __ret Value to return to the caller of setjmp().
\returns This function never returns. */
extern void longjmp(jmp_buf __jmpb, int __ret) __ATTR_NORETURN__;
#ifdef __cplusplus
}
#endif
#endif /* !__SETJMP_H_ */
|