Ticket #10021: boost_interprocess_use_windows_h.patch

File boost_interprocess_use_windows_h.patch, 11.1 KB (added by Minmin Gong <gongminmin@…>, 8 years ago)
  • boost/boost/interprocess/detail/os_thread_functions.hpp

    diff -r f8bde3457728 boost/boost/interprocess/detail/os_thread_functions.hpp
    a b  
    193193{
    194194   winapi::interprocess_filetime CreationTime, ExitTime, KernelTime, UserTime;
    195195
    196    get_process_times
     196   winapi::get_process_times
    197197      ( winapi::get_current_process(), &CreationTime, &ExitTime, &KernelTime, &UserTime);
    198198
    199199   typedef long double ldouble_t;
  • boost/boost/interprocess/detail/win32_api.hpp

    diff -r f8bde3457728 boost/boost/interprocess/detail/win32_api.hpp
    a b  
    229229namespace interprocess  {
    230230namespace winapi {
    231231
     232#ifdef BOOST_USE_WINDOWS_H
     233typedef ::GUID GUID_BIPC;
     234#else
    232235struct GUID_BIPC
    233236{
    234237   unsigned long  Data1;
     
    236239   unsigned short Data3;
    237240   unsigned char  Data4[8];
    238241};
     242#endif   // #ifdef BOOST_USE_WINDOWS_H
    239243
    240244const GUID_BIPC CLSID_WbemAdministrativeLocator =
    241245   { 0xcb8555cc, 0x9128, 0x11d1, {0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}};
     
    251255   } value;
    252256};
    253257
     258#ifdef BOOST_USE_WINDOWS_H
     259typedef ::IUnknown IUnknown_BIPC;
     260#else
    254261struct IUnknown_BIPC
    255262{
    256263   public:
     
    261268   virtual unsigned long __stdcall AddRef (void) = 0;
    262269   virtual unsigned long __stdcall Release(void) = 0;
    263270};
     271#endif   // #ifdef BOOST_USE_WINDOWS_H
    264272
    265273struct IWbemClassObject_BIPC : public IUnknown_BIPC
    266274{
     
    595603
    596604};
    597605
     606#ifdef BOOST_USE_WINDOWS_H
     607
     608typedef ::OVERLAPPED interprocess_overlapped;
     609typedef ::FILETIME interprocess_filetime;
     610typedef ::WIN32_FIND_DATA win32_find_data_t;
     611typedef ::SECURITY_ATTRIBUTES interprocess_security_attributes;
     612typedef ::SYSTEM_INFO system_info;
     613typedef ::ACL interprocess_acl;
     614typedef ::SECURITY_DESCRIPTOR interprocess_security_descriptor;
     615typedef ::BY_HANDLE_FILE_INFORMATION interprocess_by_handle_file_information;
     616
     617#else
     618
    598619struct interprocess_overlapped
    599620{
    600621   unsigned long *internal;
     
    610631   void *h_event;
    611632};
    612633
    613 struct interprocess_semaphore_basic_information
    614 {
    615         unsigned int count;             // current semaphore count
    616         unsigned int limit;             // max semaphore count
    617 };
    618 
    619 struct interprocess_section_basic_information
    620 {
    621   void *          base_address;
    622   unsigned long   section_attributes;
    623   __int64         section_size;
    624 };
    625 
    626634struct interprocess_filetime
    627635{
    628636   unsigned long  dwLowDateTime;
     
    669677    unsigned short wProcessorRevision;
    670678};
    671679
    672 struct interprocess_memory_basic_information
    673 {
    674    void *         BaseAddress;
    675    void *         AllocationBase;
    676    unsigned long  AllocationProtect;
    677    unsigned long  RegionSize;
    678    unsigned long  State;
    679    unsigned long  Protect;
    680    unsigned long  Type;
    681 };
    682 
    683680struct interprocess_acl
    684681{
    685682   unsigned char  AclRevision;
     
    700697   interprocess_acl *Dacl;
    701698} interprocess_security_descriptor;
    702699
     700struct interprocess_by_handle_file_information
     701{
     702    unsigned long dwFileAttributes;
     703    interprocess_filetime ftCreationTime;
     704    interprocess_filetime ftLastAccessTime;
     705    interprocess_filetime ftLastWriteTime;
     706    unsigned long dwVolumeSerialNumber;
     707    unsigned long nFileSizeHigh;
     708    unsigned long nFileSizeLow;
     709    unsigned long nNumberOfLinks;
     710    unsigned long nFileIndexHigh;
     711    unsigned long nFileIndexLow;
     712};
     713
     714#endif   // #ifdef BOOST_USE_WINDOWS_H
     715
     716struct interprocess_semaphore_basic_information
     717{
     718        unsigned int count;             // current semaphore count
     719        unsigned int limit;             // max semaphore count
     720};
     721
     722struct interprocess_section_basic_information
     723{
     724  void *          base_address;
     725  unsigned long   section_attributes;
     726  __int64         section_size;
     727};
     728
     729struct interprocess_memory_basic_information
     730{
     731   void *         BaseAddress;
     732   void *         AllocationBase;
     733   unsigned long  AllocationProtect;
     734   unsigned long  RegionSize;
     735   unsigned long  State;
     736   unsigned long  Protect;
     737   unsigned long  Type;
     738};
     739
    703740enum file_information_class_t {
    704741   file_directory_information = 1,
    705742   file_full_directory_information,
     
    797834   unsigned char Reserved1[SystemTimeOfDayInfoLength];
    798835};
    799836
    800 struct interprocess_by_handle_file_information
    801 {
    802     unsigned long dwFileAttributes;
    803     interprocess_filetime ftCreationTime;
    804     interprocess_filetime ftLastAccessTime;
    805     interprocess_filetime ftLastWriteTime;
    806     unsigned long dwVolumeSerialNumber;
    807     unsigned long nFileSizeHigh;
    808     unsigned long nFileSizeLow;
    809     unsigned long nNumberOfLinks;
    810     unsigned long nFileIndexHigh;
    811     unsigned long nFileIndexLow;
    812 };
    813 
    814837enum system_information_class {
    815838   system_basic_information = 0,
    816839   system_performance_information = 2,
     
    875898    //
    876899};
    877900
     901#ifdef BOOST_USE_WINDOWS_H
     902
     903//Kernel32.dll
     904
     905using ::GetCurrentProcessId;
     906using ::GetCurrentThreadId;
     907using ::GetProcessTimes;
     908using ::Sleep;
     909using ::GetTickCount;
     910using ::SwitchToThread;
     911using ::GetLastError;
     912using ::SetLastError;
     913using ::GetCurrentProcess;
     914using ::CloseHandle;
     915using ::DuplicateHandle;
     916using ::GetFileType;
     917using ::FindFirstFileA;
     918using ::FindNextFileA;
     919using ::FindClose;
     920//using ::GetSystemTimeAsFileTime
     921//using ::FileTimeToLocalFileTime
     922using ::CreateMutexA;
     923using ::OpenMutexA;
     924using ::WaitForSingleObject;
     925using ::ReleaseMutex;
     926using ::UnmapViewOfFile;
     927using ::CreateSemaphoreA;
     928using ::ReleaseSemaphore;
     929using ::OpenSemaphoreA;
     930using ::CreateFileMappingA;
     931using ::MapViewOfFileEx;
     932using ::OpenFileMappingA;
     933using ::CreateFileA;
     934using ::GetSystemInfo;
     935using ::FlushViewOfFile;
     936using ::VirtualUnlock;
     937using ::VirtualProtect;
     938using ::FlushFileBuffers;
     939using ::GetFileSizeEx;
     940using ::FormatMessageA;
     941using ::LocalFree;
     942using ::GetFileAttributesA;
     943using ::CreateDirectoryA;
     944using ::RemoveDirectoryA;
     945using ::GetTempPathA;
     946using ::CreateDirectory;
     947using ::SetFileValidData;
     948using ::SetEndOfFile;
     949using ::SetFilePointerEx;
     950using ::LockFile;
     951using ::UnlockFile;
     952using ::LockFileEx;
     953using ::UnlockFileEx;
     954using ::WriteFile;
     955using ::ReadFile;
     956using ::InitializeSecurityDescriptor;
     957using ::SetSecurityDescriptorDacl;
     958using ::LoadLibraryA;
     959using ::FreeLibrary;
     960using ::GetProcAddress;
     961using ::GetModuleHandleA;
     962using ::GetFileInformationByHandle;
     963
     964//Advapi32.dll
     965using ::RegOpenKeyExA;
     966using ::RegQueryValueExA;
     967using ::RegCloseKey;
     968
     969//Ole32.dll
     970using ::CoInitializeEx;
     971using ::CoInitializeSecurity;
     972 using ::CoSetProxyBlanket;
     973using ::CoCreateInstance;
     974using ::CoUninitialize;
     975
     976//OleAut32.dll
     977using ::VariantClear;
     978
     979
     980//EventLog access functions
     981
     982static const unsigned long eventlog_sequential_read = 0x0001;
     983static const unsigned long eventlog_backwards_read  = 0x0008;
     984
     985using ::OpenEventLogA;
     986using ::CloseEventLog;
     987using ::ReadEventLogA;
     988
     989#else
     990
    878991//Kernel32.dll
    879992
    880993//Some windows API declarations
     
    10011114    unsigned long *pnBytesRead,
    10021115    unsigned long *pnMinNumberOfBytesNeeded
    10031116   );
     1117   
     1118#endif   // #ifdef BOOST_USE_WINDOWS_H
    10041119
    10051120
    10061121//ntdll.dll
     
    12121327{  return 0 != FlushFileBuffers(handle); }
    12131328
    12141329inline bool get_file_size(void *handle, __int64 &size)
     1330#ifdef BOOST_USE_WINDOWS_H
     1331{  return 0 != GetFileSizeEx(handle, reinterpret_cast<PLARGE_INTEGER>(&size));  }
     1332#else
    12151333{  return 0 != GetFileSizeEx(handle, &size);  }
     1334#endif
    12161335
    12171336inline bool create_directory(const char *name)
    12181337{
     
    12301349{  return 0 != SetEndOfFile(handle);   }
    12311350
    12321351inline bool set_file_pointer_ex(void *handle, __int64 distance, __int64 *new_file_pointer, unsigned long move_method)
     1352#ifdef BOOST_USE_WINDOWS_H
     1353{  return 0 != SetFilePointerEx(handle, *reinterpret_cast<PLARGE_INTEGER>(&distance), reinterpret_cast<PLARGE_INTEGER>(new_file_pointer), move_method);   }
     1354#else
    12331355{  return 0 != SetFilePointerEx(handle, distance, new_file_pointer, move_method);   }
     1356#endif
    12341357
    12351358inline bool lock_file_ex(void *hnd, unsigned long flags, unsigned long reserved, unsigned long size_low, unsigned long size_high, interprocess_overlapped *overlapped)
    12361359{  return 0 != LockFileEx(hnd, flags, reserved, size_low, size_high, overlapped); }
     
    12671390{  return LoadLibraryA(name); }
    12681391
    12691392inline bool free_library(void *module)
     1393#ifdef BOOST_USE_WINDOWS_H
     1394{  return 0 != FreeLibrary(static_cast<HMODULE>(module)); }
     1395#else
    12701396{  return 0 != FreeLibrary(module); }
     1397#endif   // #ifdef BOOST_USE_WINDOWS_H
    12711398
    12721399inline void *get_proc_address(void *module, const char *name)
     1400#ifdef BOOST_USE_WINDOWS_H
     1401{  return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(module), name)); }
     1402#else
    12731403{  return GetProcAddress(module, name); }
     1404#endif   // #ifdef BOOST_USE_WINDOWS_H
    12741405
    12751406inline void *get_current_process()
    12761407{  return GetCurrentProcess();  }
     
    12791410{  return GetModuleHandleA(name); }
    12801411
    12811412inline long reg_open_key_ex(void *hKey, const char *lpSubKey, unsigned long ulOptions, unsigned long samDesired, void **phkResult)
     1413#ifdef BOOST_USE_WINDOWS_H
     1414{  return RegOpenKeyExA(static_cast<HKEY>(hKey), lpSubKey, ulOptions, samDesired, reinterpret_cast<PHKEY>(phkResult)); }
     1415#else
    12821416{  return RegOpenKeyExA(hKey, lpSubKey, ulOptions, samDesired, phkResult); }
     1417#endif   // #ifdef BOOST_USE_WINDOWS_H
    12831418
    12841419inline long reg_query_value_ex(void *hKey, const char *lpValueName, unsigned long*lpReserved, unsigned long*lpType, unsigned char *lpData, unsigned long*lpcbData)
     1420#ifdef BOOST_USE_WINDOWS_H
     1421{  return RegQueryValueExA(static_cast<HKEY>(hKey), lpValueName, lpReserved, lpType, lpData, lpcbData); }
     1422#else
    12851423{  return RegQueryValueExA(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData); }
     1424#endif   // #ifdef BOOST_USE_WINDOWS_H
    12861425
    12871426inline long reg_close_key(void *hKey)
     1427#ifdef BOOST_USE_WINDOWS_H
     1428{  return RegCloseKey(static_cast<HKEY>(hKey)); }
     1429#else
    12881430{  return RegCloseKey(hKey); }
     1431#endif   // #ifdef BOOST_USE_WINDOWS_H
    12891432
    12901433inline void initialize_object_attributes
    12911434( object_attributes_t *pobject_attr, unicode_string_t *name
     
    19572100         if ( 0 == pClassObject->Get( L"LastBootUpTime", 0, &vwchar, 0, 0 ) ){
    19582101            bRet = true;
    19592102            strValue = vwchar.value.pbstrVal;
     2103#ifdef BOOST_USE_WINDOWS_H
     2104            VariantClear(reinterpret_cast<VARIANT*>(&vwchar));
     2105#else
    19602106            VariantClear(&vwchar );
     2107#endif   // #ifdef BOOST_USE_WINDOWS_H
    19612108            break;
    19622109         }
    19632110      }
  • boost/boost/interprocess/mapped_region.hpp

    diff -r f8bde3457728 boost/boost/interprocess/mapped_region.hpp
    a b  
    374374inline std::size_t mapped_region::page_size_holder<dummy>::get_page_size()
    375375{
    376376   winapi::system_info info;
    377    get_system_info(&info);
     377   winapi::get_system_info(&info);
    378378   return std::size_t(info.dwAllocationGranularity);
    379379}
    380380