SMBIOS 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 #define FSEEK(fh, pos, whence) fseeko(fh, static_cast<off_t>(pos), whence)
29 
30 //
31 // <stdint.h> added to glibc 2.1.1
32 // We can only test for 2.1 though:
33 //
34 #if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
35  // <stdint.h> defines int64_t unconditionally, but <sys/types.h> defines
36  // int64_t only if __GNUC__. Thus, assume a fully usable <stdint.h>
37  // only when using GCC.
38 # if defined __GNUC__
39 # define LIBSMBIOS_HAS_STDINT_H
40 # endif
41 #endif
42 
43 #if defined(__LIBCOMO__)
44  //
45  // como on linux doesn't have std:: c functions:
46  // NOTE: versions of libcomo prior to beta28 have octal version numbering,
47  // e.g. version 25 is 21 (dec)
48  //
49 # if __LIBCOMO_VERSION__ <= 20
50 # define LIBSMBIOS_NO_STDC_NAMESPACE
51 # endif
52 
53 # if __LIBCOMO_VERSION__ <= 21
54 # define LIBSMBIOS_NO_SWPRINTF
55 # endif
56 
57 #endif
58 
59 //
60 // If glibc is past version 2 then we definitely have
61 // gettimeofday, earlier versions may or may not have it:
62 //
63 #if defined(__GLIBC__) && (__GLIBC__ >= 2)
64 # define LIBSMBIOS_HAS_GETTIMEOFDAY
65 #endif
66 
67 #ifdef __USE_POSIX199309
68 # define LIBSMBIOS_HAS_NANOSLEEP
69 #endif
70 
71 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
72 // __GLIBC_PREREQ is available since 2.1.2
73 
74  // swprintf is available since glibc 2.2.0
75 # if !__GLIBC_PREREQ(2,2) || (!defined(__USE_ISOC99) && !defined(__USE_UNIX98))
76 # define LIBSMBIOS_NO_SWPRINTF
77 # endif
78 #else
79 # define LIBSMBIOS_NO_SWPRINTF
80 #endif
81 
82 // boilerplate code:
83 #define LIBSMBIOS_HAS_UNISTD_H
85 
86 #ifndef __GNUC__
87 //
88 // if the compiler is not gcc we still need to be able to parse
89 // the GNU system headers, some of which (mainly <stdint.h>)
90 // use GNU specific extensions:
91 //
92 # ifndef __extension__
93 # define __extension__
94 # endif
95 # ifndef __const__
96 # define __const__ const
97 # endif
98 # ifndef __volatile__
99 # define __volatile__ volatile
100 # endif
101 # ifndef __signed__
102 # define __signed__ signed
103 # endif
104 # ifndef __typeof__
105 # define __typeof__ typeof
106 # endif
107 # ifndef __inline__
108 # define __inline__ inline
109 # endif
110 #endif
111 
112