More interprocess_exception fixes & #ifdef rephrasings

This commit is contained in:
Ion Gaztañaga
2014-05-25 20:50:39 +02:00
parent d0a647b129
commit 02a7e7ecf2
15 changed files with 46 additions and 39 deletions

View File

@@ -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,

View File

@@ -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 <boost/interprocess/detail/win32_api.hpp>

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -21,7 +21,7 @@
#include <climits>
#include <boost/type_traits/make_unsigned.hpp>
#if (defined BOOST_INTERPROCESS_WINDOWS)
#if defined (BOOST_INTERPROCESS_WINDOWS)
# include <boost/interprocess/detail/win32_api.hpp>
#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)
{

View File

@@ -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<unsigned>(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];

View File

@@ -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;

View File

@@ -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

View File

@@ -33,7 +33,7 @@
#include <stdarg.h>
#include <string>
#if (defined BOOST_INTERPROCESS_WINDOWS)
#if defined (BOOST_INTERPROCESS_WINDOWS)
# include <boost/interprocess/detail/win32_api.hpp>
#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)

View File

@@ -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<int dummy>
const std::size_t mapped_region::page_size_holder<dummy>::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);

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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