4 * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
8 * \brief OS-specific definitions
12 * \author Bernardo Innocenti <bernie@develer.com>
17 *#* Revision 1.5 2005/11/27 23:32:42 bernie
18 *#* Add CPU fallback for OS_ID.
20 *#* Revision 1.4 2005/11/27 03:07:13 bernie
21 *#* IRQ_SAVE_DISABLE(): Really block signals.
23 *#* Revision 1.3 2005/11/27 03:02:40 bernie
24 *#* Add POSIX emulation for IRQ_* macros; Add Qt support.
26 *#* Revision 1.2 2005/11/04 16:20:01 bernie
27 *#* Fix reference to README.devlib in header.
29 *#* Revision 1.1 2005/04/11 19:04:13 bernie
30 *#* Move top-level headers to cfg/ subdir.
32 *#* Revision 1.1 2004/12/31 17:40:24 bernie
33 *#* Add OS detection code.
39 /*! Macro to include OS-specific versions of the headers. */
40 #define OS_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
41 #define OS_CSOURCE(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).c)
44 * OS autodetection (Some systems trigger multiple OS definitions)
55 #define OS_POSIX 1 /* Not strictly UNIX, but no way to autodetect it. */
59 * The POSIX moral equivalent of disabling IRQs is disabling signals.
61 #define _XOPEN_SOURCE 600 /* Avoid BSDish stuff */
62 #undef _GNU_SOURCE /* This implies _BSD_SOURCE and is predefined on Linux. */
64 typedef sigset_t cpuflags_t;
69 sigprocmask(SIG_BLOCK, &sigs, NULL); \
76 sigprocmask(SIG_UNBLOCK, &sigs, NULL); \
79 #define IRQ_SAVE_DISABLE(old_sigs) \
83 sigprocmask(SIG_BLOCK, &sigs, &old_sigs); \
86 #define IRQ_RESTORE(old_sigs) \
88 sigprocmask(SIG_SETMASK, &old_sigs, NULL); \
101 #if defined(__APPLE__) && defined(__MACH__)
108 * We want Qt and other frameworks to look like OSes because you would
109 * tipically want their portable abstractions if you're using one of these.
120 * Summarize hosted environments as OS_HOSTED and embedded
121 * environment with OS_EMBEDDED.
123 #if OS_WIN32 || OS_UNIX
125 #define OS_EMBEDDED 0
128 #define OS_EMBEDDED 1
130 /* Embedded environments fall back to CPU-specific code. */
134 /* Self-check for the detection */
136 #error OS_ID not defined
138 #if OS_HOSTED && OS_EMBEDDED
139 #error Both hosted and embedded OS environment
141 #if !OS_HOSTED && !OS_EMBEDDED
142 #error Neither hosted nor embedded OS environment
145 #endif /* DEVLIB_OS_H */