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.4 2005/11/27 03:07:13 bernie
18 *#* IRQ_SAVE_DISABLE(): Really block signals.
20 *#* Revision 1.3 2005/11/27 03:02:40 bernie
21 *#* Add POSIX emulation for IRQ_* macros; Add Qt support.
23 *#* Revision 1.2 2005/11/04 16:20:01 bernie
24 *#* Fix reference to README.devlib in header.
26 *#* Revision 1.1 2005/04/11 19:04:13 bernie
27 *#* Move top-level headers to cfg/ subdir.
29 *#* Revision 1.1 2004/12/31 17:40:24 bernie
30 *#* Add OS detection code.
36 /*! Macro to include OS-specific versions of the headers. */
37 #define OS_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
38 #define OS_CSOURCE(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).c)
41 * OS autodetection (Some systems trigger multiple OS definitions)
52 #define OS_POSIX 1 /* Not strictly UNIX, but no way to autodetect it. */
56 * The POSIX moral equivalent of disabling IRQs is disabling signals.
58 #define _XOPEN_SOURCE 600 /* Avoid BSDish stuff */
59 #undef _GNU_SOURCE /* This implies _BSD_SOURCE and is predefined on Linux. */
61 typedef sigset_t cpuflags_t;
66 sigprocmask(SIG_BLOCK, &sigs, NULL); \
73 sigprocmask(SIG_UNBLOCK, &sigs, NULL); \
76 #define IRQ_SAVE_DISABLE(old_sigs) \
80 sigprocmask(SIG_BLOCK, &sigs, &old_sigs); \
83 #define IRQ_RESTORE(old_sigs) \
85 sigprocmask(SIG_SETMASK, &old_sigs, NULL); \
98 #if defined(__APPLE__) && defined(__MACH__)
105 * We want Qt and other frameworks to look like OSes because you would
106 * tipically want their portable abstractions if you're using one of these.
119 * Summarize hosted environments as OS_HOSTED and embedded
120 * environment with OS_EMBEDDED.
122 #if OS_WIN32 || OS_UNIX
124 #define OS_EMBEDDED 0
127 #define OS_EMBEDDED 1
130 /* Self-check for the detection */
132 #error OS_ID not defined
134 #if OS_HOSTED && OS_EMBEDDED
135 #error Both hosted and embedded OS environment
137 #if !OS_HOSTED && !OS_EMBEDDED
138 #error Neither hosted nor embedded OS environment
141 #endif /* DEVLIB_OS_H */