From 02a7e7ecf2a387362c5b7bfff98b66aada9573e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 25 May 2014 20:50:39 +0200 Subject: [PATCH] More interprocess_exception fixes & #ifdef rephrasings --- doc/interprocess.qbk | 1 + include/boost/interprocess/detail/atomic.hpp | 2 +- .../boost/interprocess/detail/file_wrapper.hpp | 2 +- .../detail/managed_open_or_create_impl.hpp | 3 ++- .../interprocess/detail/os_file_functions.hpp | 8 ++++---- .../interprocess/detail/os_thread_functions.hpp | 6 +++--- .../detail/portable_intermodule_singleton.hpp | 3 ++- include/boost/interprocess/detail/workaround.hpp | 16 ++++++++-------- include/boost/interprocess/errors.hpp | 12 ++++++------ include/boost/interprocess/mapped_region.hpp | 8 ++++---- .../sync/posix/semaphore_wrapper.hpp | 16 ++++++++++------ test/allocator_v1.hpp | 2 +- test/dummy_test_allocator.hpp | 2 +- test/expand_bwd_test_allocator.hpp | 2 +- test/heap_allocator_v1.hpp | 2 +- 15 files changed, 46 insertions(+), 39 deletions(-) diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index f5ced5f..c74a9af 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6746,6 +6746,7 @@ thank them: * [@https://svn.boost.org/trac/boost/ticket/9911 Trac #9911 (['"get_tmp_base_dir(...) failure"])]. * [@https://svn.boost.org/trac/boost/ticket/9946 Trac #9946 (['"ret_ptr uninitialized in init_atomic_func, fini_atomic_func"])]. * [@https://github.com/boostorg/interprocess/pull/2 GitHub #2] (['"Provide support for the Cray C++ compiler. The Cray compiler defines __GNUC__"]]). + * [@https://github.com/boostorg/interprocess/pull/3 GitHub #3] (['"Fix/mingw interprocess_exception throw in file_wrapper::priv_open_or_create"]]). * [*ABI breaking]: [@https://svn.boost.org/trac/boost/ticket/9221 #9221] showed that `BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX` option of message queue, diff --git a/include/boost/interprocess/detail/atomic.hpp b/include/boost/interprocess/detail/atomic.hpp index badaeb0..11992d1 100644 --- a/include/boost/interprocess/detail/atomic.hpp +++ b/include/boost/interprocess/detail/atomic.hpp @@ -49,7 +49,7 @@ inline boost::uint32_t atomic_cas32 } //namespace interprocess{ } //namespace boost{ -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) #include diff --git a/include/boost/interprocess/detail/file_wrapper.hpp b/include/boost/interprocess/detail/file_wrapper.hpp index 6589ecb..06031a6 100644 --- a/include/boost/interprocess/detail/file_wrapper.hpp +++ b/include/boost/interprocess/detail/file_wrapper.hpp @@ -167,7 +167,7 @@ inline bool file_wrapper::priv_open_or_create //Check for error if(m_handle == invalid_file()){ - error_info err(system_error_code()); + error_info err = system_error_code(); throw interprocess_exception(err); } diff --git a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp index 948b4f4..596a14a 100644 --- a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp +++ b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp @@ -436,7 +436,8 @@ class managed_open_or_create_impl spin_wait swait; while(filesize == 0){ if(!get_file_size(file_handle_from_mapping_handle(dev.get_mapping_handle()), filesize)){ - throw interprocess_exception(error_info(system_error_code())); + error_info err = system_error_code(); + throw interprocess_exception(err); } swait.yield(); } diff --git a/include/boost/interprocess/detail/os_file_functions.hpp b/include/boost/interprocess/detail/os_file_functions.hpp index de1b3ef..f4d4149 100644 --- a/include/boost/interprocess/detail/os_file_functions.hpp +++ b/include/boost/interprocess/detail/os_file_functions.hpp @@ -21,7 +21,7 @@ #include #include -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) # include #else # ifdef BOOST_HAS_UNISTD_H @@ -46,7 +46,7 @@ namespace boost { namespace interprocess { -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) typedef void * file_handle_t; typedef long long offset_t; @@ -371,7 +371,7 @@ inline bool for_each_file_in_dir(const char *dir, Function f) } -#else //#if (defined BOOST_INTERPROCESS_WINDOWS) +#else //#if defined (BOOST_INTERPROCESS_WINDOWS) typedef int file_handle_t; typedef off_t offset_t; @@ -691,7 +691,7 @@ inline bool delete_subdirectories(const std::string &refcstrRootDirectory, const return delete_subdirectories_recursive(refcstrRootDirectory, dont_delete_this ); } -#endif //#if (defined BOOST_INTERPROCESS_WINDOWS) +#endif //#if defined (BOOST_INTERPROCESS_WINDOWS) inline bool open_or_create_directory(const char *dir_name) { diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index adbad24..7ee0046 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -65,7 +65,7 @@ namespace boost { namespace interprocess { namespace ipcdetail{ -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) typedef unsigned long OS_process_id_t; typedef unsigned long OS_thread_id_t; @@ -210,7 +210,7 @@ inline unsigned int get_num_cores() return static_cast(sysinfo.dwNumberOfProcessors); } -#else //#if (defined BOOST_INTERPROCESS_WINDOWS) +#else //#if defined (BOOST_INTERPROCESS_WINDOWS) typedef pthread_t OS_thread_t; typedef pthread_t OS_thread_id_t; @@ -467,7 +467,7 @@ inline int thread_create(OS_thread_t * thread, void *(*start_routine)(void*), vo inline void thread_join(OS_thread_t thread) { (void)pthread_join(thread, 0); } -#endif //#if (defined BOOST_INTERPROCESS_WINDOWS) +#endif //#if defined (BOOST_INTERPROCESS_WINDOWS) typedef char pid_str_t[sizeof(OS_process_id_t)*3+1]; diff --git a/include/boost/interprocess/detail/portable_intermodule_singleton.hpp b/include/boost/interprocess/detail/portable_intermodule_singleton.hpp index 3c8c10e..5a62b42 100644 --- a/include/boost/interprocess/detail/portable_intermodule_singleton.hpp +++ b/include/boost/interprocess/detail/portable_intermodule_singleton.hpp @@ -49,7 +49,8 @@ static void create_tmp_subdir_and_get_pid_based_filepath s += "/"; s += subdir_name; if(!open_or_create_directory(s.c_str())){ - throw interprocess_exception(error_info(system_error_code())); + error_info err = system_error_code(); + throw interprocess_exception(err); } s += "/"; s += file_prefix; diff --git a/include/boost/interprocess/detail/workaround.hpp b/include/boost/interprocess/detail/workaround.hpp index 946f171..cb95611 100644 --- a/include/boost/interprocess/detail/workaround.hpp +++ b/include/boost/interprocess/detail/workaround.hpp @@ -61,14 +61,14 @@ #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES #endif - #if ((defined _V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\ - ((defined _V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\ - ((defined _V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\ - ((defined _XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\ - ((defined _XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\ - ((defined _XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\ - ((defined _FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\ - ((defined _FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64)) + #if (defined (_V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\ + (defined (_V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\ + (defined (_V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\ + (defined (_XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\ + (defined (_XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\ + (defined (_XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\ + (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\ + (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64)) #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T #endif diff --git a/include/boost/interprocess/errors.hpp b/include/boost/interprocess/errors.hpp index 324cb88..d829c81 100644 --- a/include/boost/interprocess/errors.hpp +++ b/include/boost/interprocess/errors.hpp @@ -33,7 +33,7 @@ #include #include -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) # include #else # ifdef BOOST_HAS_UNISTD_H @@ -42,7 +42,7 @@ # else //ifdef BOOST_HAS_UNISTD_H # error Unknown platform # endif //ifdef BOOST_HAS_UNISTD_H -#endif //#if (defined BOOST_INTERPROCESS_WINDOWS) +#endif //#if defined (BOOST_INTERPROCESS_WINDOWS) //!\file //!Describes the error numbering of interprocess classes @@ -60,7 +60,7 @@ inline int system_error_code() // artifact of POSIX and WINDOWS error reporting } -#if (defined BOOST_INTERPROCESS_WINDOWS) +#if defined (BOOST_INTERPROCESS_WINDOWS) inline void fill_system_message(int sys_err_code, std::string &str) { void *lpMsgBuf; @@ -129,7 +129,7 @@ struct ec_xlate static const ec_xlate ec_table[] = { - #if (defined BOOST_INTERPROCESS_WINDOWS) + #if defined (BOOST_INTERPROCESS_WINDOWS) { /*ERROR_ACCESS_DENIED*/5L, security_error }, { /*ERROR_INVALID_ACCESS*/12L, security_error }, { /*ERROR_SHARING_VIOLATION*/32L, security_error }, @@ -162,7 +162,7 @@ static const ec_xlate ec_table[] = { /*ERROR_NOT_ENOUGH_MEMORY*/8L, out_of_memory_error }, { /*ERROR_TOO_MANY_OPEN_FILES*/4L, out_of_resource_error }, { /*ERROR_INVALID_ADDRESS*/487L, busy_error } - #else //#if (defined BOOST_INTERPROCESS_WINDOWS) + #else //#if defined (BOOST_INTERPROCESS_WINDOWS) { EACCES, security_error }, { EROFS, read_only_error }, { EIO, io_error }, @@ -180,7 +180,7 @@ static const ec_xlate ec_table[] = { EMFILE, out_of_resource_error }, { ENOENT, not_such_file_or_directory }, { EINVAL, invalid_argument } - #endif //#if (defined BOOST_INTERPROCESS_WINDOWS) + #endif //#if defined (BOOST_INTERPROCESS_WINDOWS) }; inline error_code_t lookup_error(native_error_t err) diff --git a/include/boost/interprocess/mapped_region.hpp b/include/boost/interprocess/mapped_region.hpp index f08f9f6..bc3bdb4 100644 --- a/include/boost/interprocess/mapped_region.hpp +++ b/include/boost/interprocess/mapped_region.hpp @@ -53,7 +53,7 @@ # error Unknown platform # endif -#endif //#if (defined BOOST_INTERPROCESS_WINDOWS) +#endif //#if defined (BOOST_INTERPROCESS_WINDOWS) //!\file //!Describes mapped region class @@ -561,7 +561,7 @@ inline void mapped_region::priv_close() inline void mapped_region::dont_close_on_destruction() {} -#else //#if (defined BOOST_INTERPROCESS_WINDOWS) +#else //#if defined (BOOST_INTERPROCESS_WINDOWS) inline mapped_region::mapped_region() : m_base(0), m_size(0), m_page_offset(0), m_mode(read_only), m_is_xsi(false) @@ -833,7 +833,7 @@ inline void mapped_region::priv_close() inline void mapped_region::dont_close_on_destruction() { m_base = 0; } -#endif //##if (defined BOOST_INTERPROCESS_WINDOWS) +#endif //#if defined (BOOST_INTERPROCESS_WINDOWS) template const std::size_t mapped_region::page_size_holder::PageSize @@ -853,7 +853,7 @@ inline void mapped_region::swap(mapped_region &other) ipcdetail::do_swap(this->m_size, other.m_size); ipcdetail::do_swap(this->m_page_offset, other.m_page_offset); ipcdetail::do_swap(this->m_mode, other.m_mode); - #if (defined BOOST_INTERPROCESS_WINDOWS) + #if defined (BOOST_INTERPROCESS_WINDOWS) ipcdetail::do_swap(this->m_file_or_mapping_hnd, other.m_file_or_mapping_hnd); #else ipcdetail::do_swap(this->m_is_xsi, other.m_is_xsi); diff --git a/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp b/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp index eacbbc0..b4fd79c 100644 --- a/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp +++ b/include/boost/interprocess/sync/posix/semaphore_wrapper.hpp @@ -133,7 +133,8 @@ inline void semaphore_init(sem_t *handle, unsigned int initialCount) //sem_init call is not defined, but -1 is returned on failure. //In the future, a successful call might be required to return 0. if(ret == -1){ - throw interprocess_exception(system_error_code()); + error_info err = system_error_code(); + throw interprocess_exception(err); } } @@ -149,7 +150,8 @@ inline void semaphore_post(sem_t *handle) { int ret = sem_post(handle); if(ret != 0){ - throw interprocess_exception(system_error_code()); + error_info err = system_error_code(); + throw interprocess_exception(err); } } @@ -157,7 +159,8 @@ inline void semaphore_wait(sem_t *handle) { int ret = sem_wait(handle); if(ret != 0){ - throw interprocess_exception(system_error_code()); + error_info err = system_error_code(); + throw interprocess_exception(err); } } @@ -169,8 +172,8 @@ inline bool semaphore_try_wait(sem_t *handle) if(system_error_code() == EAGAIN){ return false; } - throw interprocess_exception(system_error_code()); - return false; + error_info err = system_error_code(); + throw interprocess_exception(err); } #ifndef BOOST_INTERPROCESS_POSIX_TIMEOUTS @@ -214,7 +217,8 @@ inline bool semaphore_timed_wait(sem_t *handle, const boost::posix_time::ptime & if(system_error_code() == ETIMEDOUT){ return false; } - throw interprocess_exception(system_error_code()); + error_info err = system_error_code(); + throw interprocess_exception(err); } return false; #else //#ifdef BOOST_INTERPROCESS_POSIX_TIMEOUTS diff --git a/test/allocator_v1.hpp b/test/allocator_v1.hpp index 5c1e648..e073aef 100644 --- a/test/allocator_v1.hpp +++ b/test/allocator_v1.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_INTERPROCESS_ALLOCATOR_V1_HPP #define BOOST_INTERPROCESS_ALLOCATOR_V1_HPP -#if (defined _MSC_VER) +#if defined (_MSC_VER) # pragma once #endif diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index 284d261..56cae66 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_INTERPROCESS_DUMMY_TEST_ALLOCATOR_HPP #define BOOST_INTERPROCESS_DUMMY_TEST_ALLOCATOR_HPP -#if (defined _MSC_VER) +#if defined (_MSC_VER) # pragma once #endif diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index 7cf7a89..371a31f 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_INTERPROCESS_EXPAND_BWD_TEST_ALLOCATOR_HPP #define BOOST_INTERPROCESS_EXPAND_BWD_TEST_ALLOCATOR_HPP -#if (defined _MSC_VER) +#if defined (_MSC_VER) # pragma once #endif diff --git a/test/heap_allocator_v1.hpp b/test/heap_allocator_v1.hpp index c8b53d6..58f604a 100644 --- a/test/heap_allocator_v1.hpp +++ b/test/heap_allocator_v1.hpp @@ -11,7 +11,7 @@ #ifndef BOOST_INTERPROCESS_HEAP_ALLOCATOR_V1_HPP #define BOOST_INTERPROCESS_HEAP_ALLOCATOR_V1_HPP -#if (defined _MSC_VER) +#if defined (_MSC_VER) # pragma once #endif