libsmbios_c library
linux.hpp
Go to the documentation of this file.
1 // (C) Copyright John Maddock 2001 - 2003.
2 // (C) Copyright Jens Maurer 2001 - 2003.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 // See http://www.boost.org for most recent version.
8 
9 // linux specific config options:
10 
11 #define LIBSMBIOS_PLATFORM "linux"
12 #define LIBSMBIOS_PLATFORM_LINUX
13 
14 // don't want to enable this just yet.
15 // // we can assume gettext on linux
16 // #define LIBSMBIOS_HAS_GETTEXT
17 
18 // make sure we have __GLIBC_PREREQ if available at all
19 #include <cstdlib>
20 
21 // If we are on IA64 we will need to macro define inb_p and outb_p
22 #if defined(__ia64__)
23 # define outb_p outb
24 # define inb_p inb
25 #endif
26 
27 // Enable 64-bit file access
28 #ifndef FSEEK
29 #define FSEEK(fh, pos, whence) fseeko(fh, static_cast<off_t>(pos), whence)
30 #endif
31 
32 //
33 // <stdint.h> added to glibc 2.1.1
34 // We can only test for 2.1 though:
35 //
36 #if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
37  // <stdint.h> defines int64_t unconditionally, but <sys/types.h> defines
38  // int64_t only if __GNUC__. Thus, assume a fully usable <stdint.h>
39  // only when using GCC.
40 # if defined __GNUC__
41 # define LIBSMBIOS_HAS_STDINT_H
42 # endif
43 #endif
44 
45 #if defined(__LIBCOMO__)
46  //
47  // como on linux doesn't have std:: c functions:
48  // NOTE: versions of libcomo prior to beta28 have octal version numbering,
49  // e.g. version 25 is 21 (dec)
50  //
51 # if __LIBCOMO_VERSION__ <= 20
52 # define LIBSMBIOS_NO_STDC_NAMESPACE
53 # endif
54 
55 # if __LIBCOMO_VERSION__ <= 21
56 # define LIBSMBIOS_NO_SWPRINTF
57 # endif
58 
59 #endif
60 
61 //
62 // If glibc is past version 2 then we definitely have
63 // gettimeofday, earlier versions may or may not have it:
64 //
65 #if defined(__GLIBC__) && (__GLIBC__ >= 2)
66 # define LIBSMBIOS_HAS_GETTIMEOFDAY
67 #endif
68 
69 #ifdef __USE_POSIX199309
70 # define LIBSMBIOS_HAS_NANOSLEEP
71 #endif
72 
73 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
74 // __GLIBC_PREREQ is available since 2.1.2
75 
76  // swprintf is available since glibc 2.2.0
77 # if !__GLIBC_PREREQ(2,2) || (!defined(__USE_ISOC99) && !defined(__USE_UNIX98))
78 # define LIBSMBIOS_NO_SWPRINTF
79 # endif
80 #else
81 # define LIBSMBIOS_NO_SWPRINTF
82 #endif
83 
84 // boilerplate code:
85 #define LIBSMBIOS_HAS_UNISTD_H
87 
88 #ifndef __GNUC__
89 //
90 // if the compiler is not gcc we still need to be able to parse
91 // the GNU system headers, some of which (mainly <stdint.h>)
92 // use GNU specific extensions:
93 //
94 # ifndef __extension__
95 # define __extension__
96 # endif
97 # ifndef __const__
98 # define __const__ const
99 # endif
100 # ifndef __volatile__
101 # define __volatile__ volatile
102 # endif
103 # ifndef __signed__
104 # define __signed__ signed
105 # endif
106 # ifndef __typeof__
107 # define __typeof__ typeof
108 # endif
109 # ifndef __inline__
110 # define __inline__ inline
111 # endif
112 #endif
113 
114