4 * This file is part of BeRTOS.
6 * Bertos 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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
33 * \brief OS-specific definitions
37 * \author Bernardo Innocenti <bernie@develer.com>
43 /** Macro to include OS-specific versions of the headers. */
44 #define OS_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
45 #define OS_CSOURCE(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).c)
48 * OS autodetection (Some systems trigger multiple OS definitions)
54 // FIXME: Maybe disable Win32 exceptions?
55 typedef int cpuflags_t;
56 #define IRQ_DISABLE /* FIXME */
57 #define IRQ_ENABLE /* FIXME */
58 #define IRQ_SAVE_DISABLE(old_sigs) /* FIXME */
59 #define IRQ_RESTORE(old_sigs) /* FIXME */
65 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
67 #define OS_POSIX 1 /* Not strictly UNIX, but no way to autodetect it. */
71 * The POSIX moral equivalent of disabling IRQs is disabling signals.
74 typedef sigset_t cpuflags_t;
76 #define SET_ALL_SIGNALS(sigs) \
79 sigdelset(&sigs, SIGINT); \
80 sigdelset(&sigs, SIGSTOP); \
81 sigdelset(&sigs, SIGCONT); \
87 SET_ALL_SIGNALS(sigs); \
88 sigprocmask(SIG_BLOCK, &sigs, NULL); \
94 SET_ALL_SIGNALS(sigs); \
95 sigprocmask(SIG_UNBLOCK, &sigs, NULL); \
98 #define IRQ_SAVE_DISABLE(old_sigs) \
101 SET_ALL_SIGNALS(sigs); \
102 sigprocmask(SIG_BLOCK, &sigs, &old_sigs); \
105 #define IRQ_RESTORE(old_sigs) \
107 sigprocmask(SIG_SETMASK, &old_sigs, NULL); \
120 #if defined(__APPLE__) && defined(__MACH__)
127 * We want Qt and other frameworks to look like OSes because you would
128 * tipically want their portable abstractions if you're using one of these.
139 * Summarize hosted environments as OS_HOSTED and embedded
140 * environment with OS_EMBEDDED.
142 #if OS_WIN32 || OS_UNIX || OS_DARWIN || OS_QT
144 #define OS_EMBEDDED 0
147 #define OS_EMBEDDED 1
149 /* Embedded environments fall back to CPU-specific code. */
153 /* Self-check for the detection */
155 #error OS_ID not defined
157 #if OS_HOSTED && OS_EMBEDDED
158 #error Both hosted and embedded OS environment
160 #if !OS_HOSTED && !OS_EMBEDDED
161 #error Neither hosted nor embedded OS environment
164 #endif /* DEVLIB_OS_H */