- single KERNEL_VERSION(a,b,c) macro in platform.h
[oweals/busybox.git] / include / platform.h
1 /*
2    Copyright 2006, Bernhard Fischer
3
4    Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
5 */
6 #ifndef __PLATFORM_H
7 #define __PLATFORM_H    1
8
9 /* Convenience macros to test the version of gcc. */
10 #undef __GNUC_PREREQ
11 #if defined __GNUC__ && defined __GNUC_MINOR__
12 # define __GNUC_PREREQ(maj, min) \
13                 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
14 #else
15 # define __GNUC_PREREQ(maj, min) 0
16 #endif
17
18 /* __restrict is known in EGCS 1.2 and above. */
19 #if !__GNUC_PREREQ (2,92)
20 # ifndef __restrict
21 #  define __restrict     /* Ignore */
22 # endif
23 #endif
24
25 /* Define macros for some gcc attributes.  This permits us to use the
26    macros freely, and know that they will come into play for the
27    version of gcc in which they are supported.  */
28
29 #if !__GNUC_PREREQ (2,7)
30 # ifndef __attribute__
31 #  define __attribute__(x)
32 # endif
33 #endif
34
35 #ifndef ATTRIBUTE_UNUSED
36 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
37 #endif /* ATTRIBUTE_UNUSED */
38
39 #ifndef ATTRIBUTE_NORETURN
40 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
41 #endif /* ATTRIBUTE_NORETURN */
42
43 #ifndef ATTRIBUTE_PACKED
44 # define ATTRIBUTE_PACKED __attribute__ ((__packed__))
45 #endif /* ATTRIBUTE_PACKED */
46
47 #ifndef ATTRIBUTE_ALIGNED
48 # define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m)))
49 #endif /* ATTRIBUTE_ALIGNED */
50
51 /* -fwhole-program makes all symbols local. The attribute externally_visible
52    forces a symbol global.  */
53 #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE
54 # if __GNUC_PREREQ (4,1)
55 #  define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__))
56 # else
57 #  define ATTRIBUTE_EXTERNALLY_VISIBLE
58 # endif /* GNUC >= 4.1 */
59 #endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */
60
61 /* We use __extension__ in some places to suppress -pedantic warnings
62    about GCC extensions.  This feature didn't work properly before
63    gcc 2.8.  */
64 #if !__GNUC_PREREQ (2,8)
65 # ifndef __extension__
66 #  define __extension__
67 # endif
68 #endif
69
70 /* ---- Endian Detection ------------------------------------ */
71 #ifndef __APPLE__
72 # include <byteswap.h>
73 # include <endian.h>
74 #endif
75
76 #ifdef __BIG_ENDIAN__
77 # define BB_BIG_ENDIAN 1
78 # define BB_LITTLE_ENDIAN 0
79 #elif __BYTE_ORDER == __BIG_ENDIAN
80 # define BB_BIG_ENDIAN 1
81 # define BB_LITTLE_ENDIAN 0
82 #else
83 # define BB_BIG_ENDIAN 0
84 # define BB_LITTLE_ENDIAN 1
85 #endif
86
87 /* ---- Networking ------------------------------------------ */
88 #ifndef __APPLE__
89 # include <arpa/inet.h>
90 #else
91 # include <netinet/in.h>
92 #endif
93
94 /*----- Kernel versioning ------------------------------------*/
95 #ifdef __linux__
96 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
97 #else
98 #error implement KERNEL_VERSION for your platform
99 #endif
100
101 /* ---- miscellaneous --------------------------------------- */
102 /* NLS stuff */
103 /* THIS SHOULD BE CLEANED OUT OF THE TREE ENTIRELY */
104 #define _(Text) Text
105 #define N_(Text) (Text)
106
107 #endif  /* platform.h   */