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