blob: b0b979ddd76f9d2c82cf628915f68e8ac99c1b14 [file] [log] [blame]
Alexandre Lision67916dd2014-01-24 13:33:04 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJ_COMPAT_SETJMP_H__
21#define __PJ_COMPAT_SETJMP_H__
22
23/**
24 * @file setjmp.h
25 * @brief Provides setjmp.h functionality.
26 */
27
28#if defined(PJ_HAS_SETJMP_H) && PJ_HAS_SETJMP_H != 0
29# include <setjmp.h>
30 typedef jmp_buf pj_jmp_buf;
31# ifndef pj_setjmp
32# define pj_setjmp(buf) setjmp(buf)
33# endif
34# ifndef pj_longjmp
35# define pj_longjmp(buf,d) longjmp(buf,d)
36# endif
37
38#elif defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL != 0 && \
39 defined(PJ_M_I386) && PJ_M_I386 != 0
40
41 /*
42 * These are taken from uClibc.
43 * Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
44 */
45# if defined __USE_MISC || defined _ASM
46# define JB_BX 0
47# define JB_SI 1
48# define JB_DI 2
49# define JB_BP 3
50# define JB_SP 4
51# define JB_PC 5
52# define JB_SIZE 24
53# endif
54
55# ifndef _ASM
56 typedef int __jmp_buf[6];
57
58 /* A `sigset_t' has a bit for each signal. */
59# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
60 typedef struct __sigset_t_tag
61 {
62 unsigned long int __val[_SIGSET_NWORDS];
63 } __sigset_t;
64
65 /* Calling environment, plus possibly a saved signal mask. */
66 typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
67 {
68 /* NOTE: The machine-dependent definitions of `__sigsetjmp'
69 assume that a `jmp_buf' begins with a `__jmp_buf' and that
70 `__mask_was_saved' follows it. Do not move these members
71 or add others before it. */
72 __jmp_buf __jmpbuf; /* Calling environment. */
73 int __mask_was_saved; /* Saved the signal mask? */
74 // we never saved the mask.
75 __sigset_t __saved_mask; /* Saved signal mask. */
76 } jmp_buf[1];
77
78 typedef jmp_buf sigjmp_buf;
79 typedef jmp_buf pj_jmp_buf;
80
81 PJ_DECL(int) pj_setjmp(pj_jmp_buf env);
82 PJ_DECL(void) pj_longjmp(pj_jmp_buf env, int val) __attribute__((noreturn));
83
84# endif /* _ASM */
85
86#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
87 /* Symbian framework don't use setjmp/longjmp */
88
89#else
90# warning "setjmp()/longjmp() is not implemented"
91 typedef int pj_jmp_buf[1];
92# define pj_setjmp(buf) 0
93# define pj_longjmp(buf,d) 0
94#endif
95
96
97#endif /* __PJ_COMPAT_SETJMP_H__ */
98