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