Fixup to the previous (portability) patch. Linux actually does need
[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 #if 0
36 /* Attribute __malloc__ on functions was valid as of gcc 2.96. */
37 #ifndef ATTRIBUTE_MALLOC
38 # if __GNUC_PREREQ (2,96)
39 #  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
40 # else
41 #  define ATTRIBUTE_MALLOC
42 # endif /* GNUC >= 2.96 */
43 #endif /* ATTRIBUTE_MALLOC */
44 #endif
45
46 #ifndef ATTRIBUTE_UNUSED
47 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
48 #endif /* ATTRIBUTE_UNUSED */
49
50 #ifndef ATTRIBUTE_NORETURN
51 #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
52 #endif /* ATTRIBUTE_NORETURN */
53
54 #ifndef ATTRIBUTE_PACKED
55 #define ATTRIBUTE_PACKED __attribute__ ((__packed__))
56 #endif /* ATTRIBUTE_NORETURN */
57
58 #ifndef ATTRIBUTE_ALIGNED
59 #define ATTRIBUTE_ALIGNED(m) __attribute__ ((__aligned__(m)))
60 #endif /* ATTRIBUTE_ALIGNED */
61
62 /* -fwhole-program makes all symbols local. The attribute externally_visible
63    forces a symbol global.  */
64 #ifndef ATTRIBUTE_EXTERNALLY_VISIBLE
65 # if __GNUC_PREREQ (4,1)
66 # define ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((__externally_visible__))
67 # else
68 # define ATTRIBUTE_EXTERNALLY_VISIBLE
69 # endif /* GNUC >= 4.1 */
70 #endif /* ATTRIBUTE_EXTERNALLY_VISIBLE */
71
72 /* We use __extension__ in some places to suppress -pedantic warnings
73    about GCC extensions.  This feature didn't work properly before
74    gcc 2.8.  */
75 #if !__GNUC_PREREQ (2,8)
76 # ifndef __extension__
77 #  define __extension__
78 # endif
79 #endif
80
81 /* ---- Endian Detection ------------------------------------ */
82 #ifndef __APPLE__
83     #include <byteswap.h>
84     #include <endian.h>
85 #endif
86
87 #ifdef __BIG_ENDIAN__
88     #define BB_BIG_ENDIAN 1
89 #elif __BYTE_ORDER == __BIG_ENDIAN
90     #define BB_BIG_ENDIAN 1
91 #else
92     #define BB_BIG_ENDIAN 0
93 #endif
94
95 /* ---- Networking ------------------------------------------ */
96 #ifndef __APPLE__
97 #include <arpa/inet.h>
98 #else
99 #include <netinet/in.h>
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   */