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