libsmbios_c library
win32.hpp
Go to the documentation of this file.
1 // (C) Copyright John Maddock 2001 - 2003.
2 // (C) Copyright Bill Kempf 2001.
3 // (C) Copyright Aleksey Gurtovoy 2003.
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 
8 // See http://www.boost.org for most recent version.
9 
10 // Win32 specific config options:
11 
12 #define LIBSMBIOS_PLATFORM "Win32"
13 #define LIBSMBIOS_PLATFORM_WIN32
14 
15 // Windows has a special platform-specific smbios table accessor method
16 // that can be used if generic memory access fails.
17 #define LIBSMBIOS_HAS_ARCH_TABLE_CLASS
18 
19 // Enable 64-bit file access (changes off_t to 64-bit)
20 #ifndef FSEEK
21 #define FSEEK(fh, pos, whence) fseek(fh, static_cast<long>(pos), whence)
22 #endif
23 
24 #if defined(__GNUC__) && !defined(LIBSMBIOS_NO_SWPRINTF)
25 # define LIBSMBIOS_NO_SWPRINTF
26 #endif
27 
28 #if !defined(__GNUC__) && !defined(LIBSMBIOS_HAS_DECLSPEC)
29 # define LIBSMBIOS_HAS_DECLSPEC
30 #endif
31 
32 #if defined(__MINGW32__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
33 # define LIBSMBIOS_HAS_STDINT_H
34 # define __STDC_LIMIT_MACROS
35 #endif
36 
37 //
38 // Win32 will normally be using native Win32 threads,
39 // but there is a pthread library available as an option,
40 // we used to disable this when LIBSMBIOS_DISABLE_WIN32 was
41 // defined but no longer - this should allow some
42 // files to be compiled in strict mode - while maintaining
43 // a consistent setting of LIBSMBIOS_HAS_THREADS across
44 // all translation units (needed for shared_ptr etc).
45 //
46 #ifndef LIBSMBIOS_HAS_PTHREADS
47 # define LIBSMBIOS_HAS_WINTHREADS
48 #endif
49 
50 #ifndef LIBSMBIOS_DISABLE_WIN32
51 // WEK: Added
52 #define LIBSMBIOS_HAS_FTIME
53 
54 #endif
55 
56 //
57 // disable min/max macros:
58 //
59 #ifdef min
60 # undef min
61 #endif
62 #ifdef max
63 # undef max
64 #endif
65 #ifndef NOMINMAX
66 # define NOMINMAX
67 #endif
68 
69 #ifdef LIBSMBIOS_MSVC
70 #include <algorithm> // for existing std::min and std::max
71 namespace std{
72  // Apparently, something in the Microsoft libraries requires the "long"
73  // overload, because it calls the min/max functions with arguments of
74  // slightly different type. (If this proves to be incorrect, this
75  // whole "LIBSMBIOS_MSVC" section can be removed.)
76  inline long min(long __a, long __b) {
77  return __b < __a ? __b : __a;
78  }
79  inline long max(long __a, long __b) {
80  return __a < __b ? __b : __a;
81  }
82  // The "long double" overload is required, otherwise user code calling
83  // min/max for floating-point numbers will use the "long" overload.
84  // (SourceForge bug #495495)
85  inline long double min(long double __a, long double __b) {
86  return __b < __a ? __b : __a;
87  }
88  inline long double max(long double __a, long double __b) {
89  return __a < __b ? __b : __a;
90  }
91 }
92 using std::min;
93 using std::max;
94 # endif
95 
96