Move top-level headers to cfg/ subdir.
[bertos.git] / cfg / os.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See devlib/README for information.
6  * -->
7  *
8  * \brief OS-specific definitions
9  *
10  * \version $Id$
11  *
12  * \author Bernardo Innocenti <bernie@develer.com>
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.1  2005/04/11 19:04:13  bernie
18  *#* Move top-level headers to cfg/ subdir.
19  *#*
20  *#* Revision 1.1  2004/12/31 17:40:24  bernie
21  *#* Add OS detection code.
22  *#*
23  *#*/
24 #ifndef DEVLIB_OS_H
25 #define DEVLIB_OS_H
26
27
28 /*! Macro to include OS-specific versions of the headers. */
29 #define OS_HEADER(module)  PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
30
31 /*
32  * OS autodetection (Some systems trigger multiple OS definitions)
33  */
34 #ifdef _WIN32
35         #define OS_WIN32  1
36         #define OS_ID     win32
37 #else
38         #define OS_WIN32  0
39 #endif
40
41 #ifdef __unix__
42         #define OS_UNIX   1
43         #define OS_POSIX  1  /* Not strictly UNIX, but no way to autodetect it. */
44         #define OS_ID     unix
45 #else
46         #define OS_UNIX   0
47         #define OS_POSIX  0
48 #endif
49
50 #ifdef __linux__
51         #define OS_LINUX  1
52 #else
53         #define OS_LINUX  0
54 #endif
55
56 #if defined(__APPLE__) && defined(__MACH__)
57         #define OS_DARWIN 1
58 #else
59         #define OS_DARWIN 0
60 #endif
61
62 /*
63  * Summarize hosted environments as OS_HOSTED.
64  */
65 #if OS_WIN32 || OS_UNIX
66         #define OS_HOSTED   1
67 #else
68         #define OS_HOSTED   0
69 #endif
70
71 /*
72  * Summarize embedded environments as OS_EMBEDDED.
73  */
74 #if CPU_AVR || CPU_DSP56K || CPU_I196 || defined(__embedded__)
75         #define OS_EMBEDDED  1
76 #else
77         #define OS_EMBEDDED  0
78 #endif
79
80
81 /* Self-check for the detection */
82 #if CPU_I196 + CPU_X86 + CPU_DSP56K + CPU_AVR == 0
83         #error Unknown CPU
84 #endif
85 #if !defined(OS_ID)
86         #error OS_ID not defined
87 #endif
88 #if OS_HOSTED && OS_EMBEDDED
89         #error Both hosted and embedded OS environment
90 #endif
91 #if !OS_HOSTED && !OS_EMBEDDED
92         #error Neither hosted nor embedded OS environment
93 #endif
94
95 #endif /* DEVLIB_OS_H */