Skip to content

Commit

Permalink
merging interprocess from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
igaztanaga committed Nov 5, 2018
2 parents 1624494 + b962143 commit 2dc189b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
2 changes: 2 additions & 0 deletions doc/interprocess.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -6765,6 +6765,8 @@ thank them:
[section:release_notes_boost_1_69_00 Boost 1.69 Release]
* Fixed bugs:
* [@https://github.com/boostorg/interprocess/issues/59 GitHub Issue #59 (['"warning: ISO C++ prohibits anonymous structs [-Wpedantic]"])].
* [@https://github.com/boostorg/interprocess/issues/60 GitHub Issue #60 (['"warning: cast between incompatible function types from boost::interprocess::winapi::farproc_t..."])].
* [@https://github.com/boostorg/interprocess/issues/61 GitHub Issue #61 (['"warning: struct winapi::*_BIPC has virtual functions and accessible non-virtual destructor"])].

[endsect]

Expand Down
34 changes: 20 additions & 14 deletions include/boost/interprocess/detail/win32_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,24 @@
//
//////////////////////////////////////////////////////////////////////////////
//Ignore -pedantic errors here (anonymous structs, etc.)
#if defined(BOOST_GCC)
//Ignore -pedantic errors here (anonymous structs, etc.)
# if (BOOST_GCC >= 40600)
# pragma GCC diagnostic push
# if (BOOST_GCC >= 40800)
# pragma GCC diagnostic ignored "-Wpedantic"
# else
# pragma GCC diagnostic ignored "-pedantic"
# endif
# pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
# else
# pragma GCC system_header
# endif
//When loading DLLs we have no option but reinterpret casting function types
# if (BOOST_GCC >= 80000)
# pragma GCC diagnostic ignored "-Wcast-function-type"
# endif
#endif
namespace boost {
Expand Down Expand Up @@ -1672,8 +1678,8 @@ struct library_unloader
inline bool get_system_time_of_day_information(system_timeofday_information &info)
{
NtQuerySystemInformation_t pNtQuerySystemInformation = (NtQuerySystemInformation_t)
dll_func::get(dll_func::NtQuerySystemInformation);
NtQuerySystemInformation_t pNtQuerySystemInformation = reinterpret_cast<NtQuerySystemInformation_t>
(dll_func::get(dll_func::NtQuerySystemInformation));
unsigned long res;
long status = pNtQuerySystemInformation(system_time_of_day_information, &info, sizeof(info), &res);
if(status){
Expand Down Expand Up @@ -1889,9 +1895,9 @@ inline bool unlink_file(const char *filename)
// file name can't be used to open this file again
try{
NtSetInformationFile_t pNtSetInformationFile =
(NtSetInformationFile_t)dll_func::get(dll_func::NtSetInformationFile);
reinterpret_cast<NtSetInformationFile_t>(dll_func::get(dll_func::NtSetInformationFile));
NtQueryObject_t pNtQueryObject = (NtQueryObject_t)dll_func::get(dll_func::NtQueryObject);
NtQueryObject_t pNtQueryObject = reinterpret_cast<NtQueryObject_t>(dll_func::get(dll_func::NtQueryObject));
//First step: Obtain a handle to the file using Win32 rules. This resolves relative paths
void *fh = create_file(filename, generic_read | delete_access, open_existing, 0, 0);
Expand Down Expand Up @@ -1963,8 +1969,8 @@ inline bool unlink_file(const char *filename)
{
//Don't use pNtSetInformationFile with file_disposition_information as it can return STATUS_CANNOT_DELETE
//if the file is still mapped. Reopen it with NtOpenFile and file_delete_on_close
NtOpenFile_t pNtOpenFile = (NtOpenFile_t)dll_func::get(dll_func::NtOpenFile);
NtClose_t pNtClose = (NtClose_t)dll_func::get(dll_func::NtClose);
NtOpenFile_t pNtOpenFile = reinterpret_cast<NtOpenFile_t>(dll_func::get(dll_func::NtOpenFile));
NtClose_t pNtClose = reinterpret_cast<NtClose_t>(dll_func::get(dll_func::NtClose));
const wchar_t empty_str [] = L"";
unicode_string_t ustring = { sizeof(empty_str) - sizeof (wchar_t) //length in bytes without null
, sizeof(empty_str) //total size in bytes of memory allocated for Buffer.
Expand Down Expand Up @@ -2410,7 +2416,7 @@ inline bool is_directory(const char *path)
inline bool get_file_mapping_size(void *file_mapping_hnd, __int64 &size)
{
NtQuerySection_t pNtQuerySection =
(NtQuerySection_t)dll_func::get(dll_func::NtQuerySection);
reinterpret_cast<NtQuerySection_t>(dll_func::get(dll_func::NtQuerySection));
//Obtain file name
interprocess_section_basic_information info;
unsigned long ntstatus =
Expand All @@ -2423,7 +2429,7 @@ inline bool get_semaphore_info(void *handle, long &count, long &limit)
{
winapi::interprocess_semaphore_basic_information info;
winapi::NtQuerySemaphore_t pNtQuerySemaphore =
(winapi::NtQuerySemaphore_t)dll_func::get(winapi::dll_func::NtQuerySemaphore);
reinterpret_cast<winapi::NtQuerySemaphore_t>(dll_func::get(winapi::dll_func::NtQuerySemaphore));
unsigned int ret_len;
long status = pNtQuerySemaphore(handle, winapi::semaphore_basic_information, &info, sizeof(info), &ret_len);
count = info.count;
Expand All @@ -2434,21 +2440,21 @@ inline bool get_semaphore_info(void *handle, long &count, long &limit)
inline bool query_timer_resolution(unsigned long *lowres, unsigned long *highres, unsigned long *curres)
{
winapi::NtQueryTimerResolution_t pNtQueryTimerResolution =
(winapi::NtQueryTimerResolution_t)dll_func::get(winapi::dll_func::NtQueryTimerResolution);
reinterpret_cast<winapi::NtQueryTimerResolution_t>(dll_func::get(winapi::dll_func::NtQueryTimerResolution));
return !pNtQueryTimerResolution(lowres, highres, curres);
}
inline bool query_performance_counter(__int64 *lpPerformanceCount)
{
QueryPerformanceCounter_t pQueryPerformanceCounter = (QueryPerformanceCounter_t)
dll_func::get(dll_func::QueryPerformanceCounter);
QueryPerformanceCounter_t pQueryPerformanceCounter = reinterpret_cast<QueryPerformanceCounter_t>
(dll_func::get(dll_func::QueryPerformanceCounter));
return 0 != pQueryPerformanceCounter(lpPerformanceCount);
}
inline bool query_performance_frequency(__int64 *lpFrequency)
{
QueryPerformanceCounter_t pQueryPerformanceFrequency = (QueryPerformanceFrequency_t)
dll_func::get(dll_func::QueryPerformanceFrequency);
QueryPerformanceCounter_t pQueryPerformanceFrequency = reinterpret_cast<QueryPerformanceFrequency_t>
(dll_func::get(dll_func::QueryPerformanceFrequency));
return 0 != pQueryPerformanceFrequency(lpFrequency);
}
Expand Down
15 changes: 8 additions & 7 deletions include/boost/interprocess/sync/shm/named_condition_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,25 @@ class shm_named_condition_any
//!If there is a thread waiting on *this, change that
//!thread's state to ready. Otherwise there is no effect.*/
void notify_one()
{ m_cond.notify_one(); }
{ this->internal_cond().notify_one(); }

//!Change the state of all threads waiting on *this to ready.
//!If there are no waiting threads, notify_all() has no effect.
void notify_all()
{ m_cond.notify_all(); }
{ this->internal_cond().notify_all(); }

//!Releases the lock on the named_mutex object associated with lock, blocks
//!the current thread of execution until readied by a call to
//!this->notify_one() or this->notify_all(), and then reacquires the lock.
template <typename L>
void wait(L& lock)
{ m_cond.wait(lock); }
{ this->internal_cond().wait(lock); }

//!The same as:
//!while (!pred()) wait(lock)
template <typename L, typename Pr>
void wait(L& lock, Pr pred)
{ m_cond.wait(lock, pred); }
{ this->internal_cond().wait(lock, pred); }

//!Releases the lock on the named_mutex object associated with lock, blocks
//!the current thread of execution until readied by a call to
Expand All @@ -139,14 +139,14 @@ class shm_named_condition_any
//!Returns: false if time abs_time is reached, otherwise true.
template <typename L>
bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time)
{ return m_cond.timed_wait(lock, abs_time); }
{ return this->internal_cond().timed_wait(lock, abs_time); }

//!The same as: while (!pred()) {
//! if (!timed_wait(lock, abs_time)) return pred();
//! } return true;
template <typename L, typename Pr>
bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
{ return m_cond.timed_wait(lock, abs_time, pred); }
{ return this->internal_cond().timed_wait(lock, abs_time, pred); }

//!Erases a named condition from the system.
//!Returns false on error. Never throws.
Expand All @@ -172,7 +172,8 @@ class shm_named_condition_any

typedef ipcdetail::condition_any_wrapper<internal_condition_members> internal_condition;

internal_condition m_cond;
internal_condition &internal_cond()
{ return *static_cast<internal_condition*>(m_shmem.get_user_address()); }

friend class boost::interprocess::ipcdetail::interprocess_tester;
void dont_close_on_destruction()
Expand Down
8 changes: 4 additions & 4 deletions test/expand_bwd_test_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ class expand_bwd_test_allocator

//!Equality test for same type of expand_bwd_test_allocator
template<class T> inline
bool operator==(const expand_bwd_test_allocator<T> &alloc1,
const expand_bwd_test_allocator<T> &alloc2)
bool operator==(const expand_bwd_test_allocator<T> &,
const expand_bwd_test_allocator<T> &)
{ return false; }

//!Inequality test for same type of expand_bwd_test_allocator
template<class T> inline
bool operator!=(const expand_bwd_test_allocator<T> &alloc1,
const expand_bwd_test_allocator<T> &alloc2)
bool operator!=(const expand_bwd_test_allocator<T> &,
const expand_bwd_test_allocator<T> &)
{ return true; }

} //namespace test {
Expand Down
5 changes: 4 additions & 1 deletion test/heap_allocator_v1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ class heap_allocator_v1

//!Deallocates memory previously allocated. Never throws
void deallocate(const pointer &ptr, size_type)
{ return ::delete[] ipcdetail::to_raw_pointer(ptr) ; }
{
char *ptr_raw = (char*)ipcdetail::to_raw_pointer(ptr);
::delete[] ptr_raw;
}

//!Construct object, calling constructor.
//!Throws if T(const T&) throws
Expand Down

0 comments on commit 2dc189b

Please sign in to comment.