mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Sync from upstream.
This commit is contained in:
108
.github/workflows/ci.yml
vendored
108
.github/workflows/ci.yml
vendored
@@ -128,9 +128,16 @@ jobs:
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
install: g++-13-multilib
|
||||
address-model: 32,64
|
||||
# Linux, gcc-14
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
install: g++-14-multilib
|
||||
address-model: 32,64
|
||||
# Linux, gcc-12 UBSAN
|
||||
- name: UBSAN
|
||||
toolset: gcc-12
|
||||
@@ -285,16 +292,23 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
# Linux, clang-17
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
container: ubuntu:23.10
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
# Linux, clang-18
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
# Linux, clang-15 libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
@@ -304,10 +318,17 @@ jobs:
|
||||
- clang-15
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
# Linux, clang-18 libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-18
|
||||
- libc++-18-dev
|
||||
- libc++abi-18-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
# Linux, clang-14 libc++, ubsan
|
||||
@@ -323,13 +344,22 @@ jobs:
|
||||
- clang-14
|
||||
- libc++-14-dev
|
||||
- libc++abi-14-dev
|
||||
# Linux, clang-18 libc++, ubsan
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
ubsan: 1
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-18
|
||||
- libc++-18-dev
|
||||
- libc++abi-18-dev
|
||||
#------------------
|
||||
# MacOS, clang
|
||||
#------------------
|
||||
# Macos 11, clang
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: macos-11
|
||||
# Macos 12, clang
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
@@ -338,6 +368,10 @@ jobs:
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
# Macos 17, clang
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
|
||||
timeout-minutes: 180
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -357,7 +391,6 @@ jobs:
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT dist-upgrade -y
|
||||
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||
then
|
||||
PYTHON_PACKAGE="python-is-python3"
|
||||
@@ -368,7 +401,6 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
git config --global pack.threads 0
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -425,8 +457,8 @@ jobs:
|
||||
done
|
||||
fi
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT dist-upgrade -y
|
||||
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
|
||||
|
||||
- name: Setup GCC Toolchain
|
||||
if: matrix.gcc_toolchain
|
||||
run: |
|
||||
@@ -438,6 +470,7 @@ jobs:
|
||||
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
|
||||
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
|
||||
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
@@ -452,7 +485,6 @@ jobs:
|
||||
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
|
||||
echo BUILD_JOBS: $BUILD_JOBS
|
||||
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
|
||||
DEPINST_ARGS=()
|
||||
@@ -484,11 +516,25 @@ jobs:
|
||||
then
|
||||
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
|
||||
fi
|
||||
mkdir -p snapshot
|
||||
cd snapshot
|
||||
echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
curl -L --retry "$NET_RETRY_COUNT" -o "${LIBRARY}-${GITHUB_SHA}.tar.gz" "https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||
tar -xf "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
if [ ! -d "${LIBRARY}-${GITHUB_SHA}" ]
|
||||
then
|
||||
echo "Library snapshot does not contain the library directory ${LIBRARY}-${GITHUB_SHA}:"
|
||||
ls -la
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${LIBRARY}-${GITHUB_SHA}.tar.gz"
|
||||
cd ..
|
||||
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
|
||||
cd boost-root
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
mkdir -p libs
|
||||
rm -rf "libs/$LIBRARY"
|
||||
mv -f "../snapshot/${LIBRARY}-${GITHUB_SHA}" "libs/$LIBRARY"
|
||||
rm -rf "../snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
DEPINST_ARGS+=("$LIBRARY")
|
||||
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
|
||||
@@ -503,10 +549,11 @@ jobs:
|
||||
fi
|
||||
echo " ;" >> ~/user-config.jam
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
if: matrix.cmake_tests == ''
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
|
||||
if [ -n "${{matrix.build_variant}}" ]
|
||||
then
|
||||
@@ -537,6 +584,7 @@ jobs:
|
||||
fi
|
||||
B2_ARGS+=("libs/$LIBRARY/test")
|
||||
./b2 "${B2_ARGS[@]}"
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -563,11 +611,10 @@ jobs:
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
timeout-minutes: 180
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
@@ -581,17 +628,32 @@ jobs:
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
echo NUMBER_OF_PROCESSORS: %NUMBER_OF_PROCESSORS%
|
||||
mkdir snapshot
|
||||
cd snapshot
|
||||
echo Downloading library snapshot: https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip
|
||||
curl -L --retry %NET_RETRY_COUNT% -o "%LIBRARY%-%GITHUB_SHA%.zip" "https://github.com/%GITHUB_REPOSITORY%/archive/%GITHUB_SHA%.zip"
|
||||
tar -xf "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
if not exist "%LIBRARY%-%GITHUB_SHA%\" (
|
||||
echo Library snapshot does not contain the library directory %LIBRARY%-%GITHUB_SHA%:
|
||||
dir
|
||||
exit /b 1
|
||||
)
|
||||
del /f "%LIBRARY%-%GITHUB_SHA%.zip"
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
if not exist "libs\" mkdir libs
|
||||
if exist "libs\%LIBRARY%\" rmdir /s /q "libs\%LIBRARY%"
|
||||
move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%"
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
cd boost-root
|
||||
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@ target_link_libraries(boost_interprocess
|
||||
Boost::winapi
|
||||
)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(boost_interprocess INTERFACE rt)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_link_libraries(boost_interprocess INTERFACE ole32 oleaut32 psapi advapi32)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
@@ -6822,6 +6822,17 @@ thank them:
|
||||
|
||||
[section:release_notes Release Notes]
|
||||
|
||||
[section:release_notes_boost_1_86_00 Boost 1.86 Release]
|
||||
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/191 GitHub #191 (['"vectorstream: support file sizes larger than INT_MAX "])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/198 GitHub #198 (['"Minor fixes for documentation of offset_ptr"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/202 GitHub #202 (['"Allow to map message_queue in anonymous memory"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/207 GitHub #207 (['"cmake: link system libraries"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/214 GitHub #214 (['"Doc: Fix github links"])].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:release_notes_boost_1_85_00 Boost 1.85 Release]
|
||||
|
||||
* Remove broken `unordered_map_index` class.
|
||||
@@ -6886,9 +6897,9 @@ thank them:
|
||||
can be defined by the user before including Boost.Interprocess headers to tune the default values.
|
||||
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/65 GitHub #65 (['"Robustness of the interprocess mutex"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/65 GitHub #65 (['"Robustness of the interprocess mutex"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/67 GitHub #67 (['"Changed to use posix robust mutex"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/103 GitHub #103 (['"Use interprocess headers without exception handling"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/103 GitHub #103 (['"Use interprocess headers without exception handling"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/128 GitHub #128 (['"Infinite loop in managed_open_or_create_impl.hpp"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/130 GitHub #130 (['"infinite loop in managed_open_or_create_impl.hpp if filesize is 0"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/142 GitHub #142 (['"File lock documentation about advisory locking is inaccurate on Windows"])].
|
||||
@@ -6972,8 +6983,8 @@ thank them:
|
||||
[section:release_notes_boost_1_71_00 Boost 1.71 Release]
|
||||
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/85 GitHub #85 (['"warning: Implicit conversion loses integer precision"])].
|
||||
* [@https://github.com/boostorg/interprocess/pull/86 GitHub #86 (['"warning: Possible misuse of comma operator"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/85 GitHub #85 (['"warning: Implicit conversion loses integer precision"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/86 GitHub #86 (['"warning: Possible misuse of comma operator"])].
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -7015,7 +7026,7 @@ thank them:
|
||||
|
||||
[section:release_notes_boost_1_66_00 Boost 1.66 Release]
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/interprocess/pull/41 GitHub Pull #41 (['"Data race in boost::interprocess::rbtree_best_fit"])].
|
||||
* [@https://github.com/boostorg/interprocess/issues/41 GitHub Issue #41 (['"Data race in boost::interprocess::rbtree_best_fit"])].
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ipcdetail{
|
||||
//!The function returns a mapped_region holding that segment or throws
|
||||
//!interprocess_exception if the function fails.
|
||||
//static mapped_region
|
||||
static mapped_region
|
||||
inline mapped_region
|
||||
anonymous_shared_memory(std::size_t size, void *address = 0)
|
||||
#if (!defined(BOOST_INTERPROCESS_WINDOWS))
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <boost/interprocess/detail/type_traits.hpp>
|
||||
#include <boost/interprocess/detail/atomic.hpp>
|
||||
#include <boost/interprocess/detail/interprocess_tester.hpp>
|
||||
#include <boost/interprocess/anonymous_shared_memory.hpp>
|
||||
#include <boost/interprocess/creation_tags.hpp>
|
||||
#include <boost/interprocess/detail/mpl.hpp>
|
||||
#include <boost/interprocess/permissions.hpp>
|
||||
@@ -205,6 +206,15 @@ class managed_open_or_create_impl
|
||||
, construct_func);
|
||||
}
|
||||
|
||||
template <class ConstructFunc>
|
||||
managed_open_or_create_impl(std::size_t size, void *addr, const ConstructFunc &construct_func)
|
||||
{
|
||||
priv_map_anonymous
|
||||
( size
|
||||
, addr
|
||||
, construct_func);
|
||||
}
|
||||
|
||||
managed_open_or_create_impl(BOOST_RV_REF(managed_open_or_create_impl) moved)
|
||||
{ this->swap(moved); }
|
||||
|
||||
@@ -510,6 +520,37 @@ class managed_open_or_create_impl
|
||||
}
|
||||
}
|
||||
|
||||
template <class ConstructFunc> inline
|
||||
void priv_map_anonymous
|
||||
(std::size_t size,
|
||||
void *addr,
|
||||
ConstructFunc construct_func)
|
||||
{
|
||||
mapped_region region = anonymous_shared_memory(size, addr);
|
||||
|
||||
boost::uint32_t *patomic_word = 0; //avoid gcc warning
|
||||
patomic_word = static_cast<boost::uint32_t*>(region.get_address());
|
||||
boost::uint32_t previous = atomic_cas32(patomic_word, InitializingSegment, UninitializedSegment);
|
||||
|
||||
if(previous == UninitializedSegment){
|
||||
BOOST_TRY{
|
||||
construct_func( static_cast<char*>(region.get_address()) + ManagedOpenOrCreateUserOffset
|
||||
, size - ManagedOpenOrCreateUserOffset, true);
|
||||
//All ok, just move resources to the external mapped region
|
||||
m_mapped_region.swap(region);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
atomic_write32(patomic_word, CorruptedSegment);
|
||||
BOOST_RETHROW
|
||||
} BOOST_CATCH_END
|
||||
atomic_write32(patomic_word, InitializedSegment);
|
||||
}
|
||||
else{
|
||||
atomic_write32(patomic_word, CorruptedSegment);
|
||||
throw interprocess_exception(error_info(corrupted_error));
|
||||
}
|
||||
}
|
||||
|
||||
friend void swap(managed_open_or_create_impl &left, managed_open_or_create_impl &right)
|
||||
{
|
||||
left.swap(right);
|
||||
|
||||
@@ -143,6 +143,12 @@ class message_queue_t
|
||||
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
||||
|
||||
//!Creates a process shared message queue in anonymous memory. For this message queue,
|
||||
//!the maximum number of messages will be "max_num_msg" and the maximum message size
|
||||
//!will be "max_msg_size". Throws on error.
|
||||
message_queue_t(size_type max_num_msg,
|
||||
size_type max_msg_size);
|
||||
|
||||
//!Destroys *this and indicates that the calling process is finished using
|
||||
//!the resource. All opened message queues are still
|
||||
//!valid after destruction. The destructor function will deallocate
|
||||
@@ -804,6 +810,15 @@ inline message_queue_t<VoidPointer>::message_queue_t(open_only_t, const wchar_t
|
||||
|
||||
#endif //defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
||||
|
||||
template <class VoidPointer>
|
||||
inline message_queue_t<VoidPointer>::message_queue_t(size_type max_num_msg,
|
||||
size_type max_msg_size)
|
||||
: m_shmem(get_mem_size(max_msg_size, max_num_msg),
|
||||
static_cast<void*>(0),
|
||||
//Prepare initialization functor
|
||||
ipcdetail::msg_queue_initialization_func_t<VoidPointer> (max_num_msg, max_msg_size))
|
||||
{}
|
||||
|
||||
template<class VoidPointer>
|
||||
inline void message_queue_t<VoidPointer>::send
|
||||
(const void *buffer, size_type buffer_size, unsigned int priority)
|
||||
|
||||
@@ -211,12 +211,12 @@ namespace ipcdetail {
|
||||
} //namespace ipcdetail {
|
||||
#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
||||
|
||||
//!A smart pointer that stores the offset between between the pointer and the
|
||||
//!the object it points. This allows offset allows special properties, since
|
||||
//!A smart pointer that stores the offset between the pointer and the
|
||||
//!object it points to. This allows special properties, since
|
||||
//!the pointer is independent from the address of the pointee, if the
|
||||
//!pointer and the pointee are still separated by the same offset. This feature
|
||||
//!converts offset_ptr in a smart pointer that can be placed in shared memory and
|
||||
//!memory mapped files mapped in different addresses in every process.
|
||||
//!memory mapped files mapped at different addresses in every process.
|
||||
//!
|
||||
//! \tparam PointedType The type of the pointee.
|
||||
//! \tparam DifferenceType A signed integer type that can represent the arithmetic operations on the pointer
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <string> // char traits
|
||||
#include <climits> // INT_MAX
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <boost/interprocess/interprocess_fwd.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
@@ -138,9 +139,9 @@ class basic_vectorbuf
|
||||
if(m_vect.size() > high_pos){
|
||||
m_vect.resize(high_pos);
|
||||
//But we must update end write pointer because vector size is now shorter
|
||||
int old_pos = (int)(base_t::pptr() - base_t::pbase());
|
||||
off_type old_pos = base_t::pptr() - base_t::pbase();
|
||||
const_cast<basic_vectorbuf*>(this)->base_t::setp(old_ptr, old_ptr + high_pos);
|
||||
const_cast<basic_vectorbuf*>(this)->base_t::pbump(old_pos);
|
||||
const_cast<basic_vectorbuf*>(this)->pbump(old_pos);
|
||||
}
|
||||
}
|
||||
return m_vect;
|
||||
@@ -152,14 +153,14 @@ class basic_vectorbuf
|
||||
void reserve(typename vector_type::size_type size)
|
||||
{
|
||||
if (this->m_mode & std::ios_base::out && size > m_vect.size()){
|
||||
typename vector_type::difference_type write_pos = base_t::pptr() - base_t::pbase();
|
||||
typename vector_type::difference_type read_pos = base_t::gptr() - base_t::eback();
|
||||
off_type write_pos = base_t::pptr() - base_t::pbase();
|
||||
off_type read_pos = base_t::gptr() - base_t::eback();
|
||||
//Now update pointer data
|
||||
m_vect.reserve(size);
|
||||
this->initialize_pointers();
|
||||
base_t::pbump((int)write_pos);
|
||||
this->pbump(write_pos);
|
||||
if(this->m_mode & std::ios_base::in){
|
||||
base_t::gbump((int)read_pos);
|
||||
base_t::setg(base_t::eback(), base_t::eback() + read_pos, base_t::egptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +190,7 @@ class basic_vectorbuf
|
||||
// The initial write position is the beginning of the vector.
|
||||
if(m_mode & std::ios_base::out){
|
||||
//First get real size
|
||||
int real_size = (int)m_vect.size();
|
||||
off_type real_size = m_vect.size();
|
||||
//Then maximize size for high watermarking
|
||||
m_vect.resize(m_vect.capacity());
|
||||
BOOST_ASSERT(m_vect.size() == m_vect.capacity());
|
||||
@@ -208,11 +209,21 @@ class basic_vectorbuf
|
||||
this->setg(p, p, p + real_size);
|
||||
}
|
||||
if (m_mode & (std::ios_base::app | std::ios_base::ate)){
|
||||
base_t::pbump((int)real_size);
|
||||
this->pbump(real_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LWG255-inspired variant of base_t::pbump that takes a streamoff instead of an int.
|
||||
void pbump(off_type delta) {
|
||||
if (delta > INT_MAX) {
|
||||
for (off_type d = delta / INT_MAX; d > 0; d--)
|
||||
base_t::pbump(INT_MAX);
|
||||
delta %= INT_MAX;
|
||||
}
|
||||
base_t::pbump((int)delta);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual int_type underflow() BOOST_OVERRIDE
|
||||
{
|
||||
@@ -277,7 +288,7 @@ class basic_vectorbuf
|
||||
if (m_mode & std::ios_base::in)
|
||||
base_t::setg(p, p + (base_t::gptr() - base_t::eback()), mp_high_water);
|
||||
//Update write position to the old position + 1
|
||||
base_t::pbump((int)new_outpos);
|
||||
this->pbump((off_type)new_outpos);
|
||||
return c;
|
||||
}
|
||||
else // c is EOF, so we don't have to do anything
|
||||
@@ -351,7 +362,7 @@ class basic_vectorbuf
|
||||
base_t::setg(base_t::eback(), base_t::eback() + newoff, base_t::egptr());
|
||||
if (out){
|
||||
base_t::setp(base_t::pbase(), base_t::epptr());
|
||||
base_t::pbump(static_cast<int>(newoff));
|
||||
this->pbump(newoff);
|
||||
}
|
||||
return pos_type(newoff);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user