|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77909 - trunk/libs/interprocess/test
From: igaztanaga_at_[hidden]
Date: 2012-04-11 02:25:05
Author: igaztanaga
Date: 2012-04-11 02:25:04 EDT (Wed, 11 Apr 2012)
New Revision: 77909
URL: http://svn.boost.org/trac/boost/changeset/77909
Log:
Error correction for Visual and Clang
Text files modified:
trunk/libs/interprocess/test/heap_allocator_v1.hpp | 10 +++++++---
trunk/libs/interprocess/test/named_semaphore_test.cpp | 25 +++++++++++++++++++++++++
trunk/libs/interprocess/test/vectorstream_test.cpp | 7 ++++++-
3 files changed, 38 insertions(+), 4 deletions(-)
Modified: trunk/libs/interprocess/test/heap_allocator_v1.hpp
==============================================================================
--- trunk/libs/interprocess/test/heap_allocator_v1.hpp (original)
+++ trunk/libs/interprocess/test/heap_allocator_v1.hpp 2012-04-11 02:25:04 EDT (Wed, 11 Apr 2012)
@@ -90,7 +90,7 @@
//!Returns the segment manager. Never throws
segment_manager* get_segment_manager()const
{ return ipcdetail::to_raw_pointer(mp_mngr); }
-/*
+
//!Returns address of mutable object. Never throws
pointer address(reference value) const
{ return pointer(addressof(value)); }
@@ -98,7 +98,7 @@
//!Returns address of non mutable object. Never throws
const_pointer address(const_reference value) const
{ return const_pointer(addressof(value)); }
-*/
+
//!Constructor from the segment manager. Never throws
heap_allocator_v1(segment_manager *segment_mngr)
: mp_mngr(segment_mngr) { }
@@ -115,7 +115,11 @@
//!Allocates memory for an array of count elements.
//!Throws boost::interprocess::bad_alloc if there is no enough memory
pointer allocate(size_type count, cvoid_ptr hint = 0)
- { (void)hint; return ::new value_type[count]; }
+ {
+ (void)hint;
+ char *raw_mem = ::new char[sizeof(value_type)*count];
+ return boost::intrusive::pointer_traits<pointer>::pointer_to(reinterpret_cast<value_type &>(*raw_mem));
+ }
//!Deallocates memory previously allocated. Never throws
void deallocate(const pointer &ptr, size_type)
Modified: trunk/libs/interprocess/test/named_semaphore_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_semaphore_test.cpp (original)
+++ trunk/libs/interprocess/test/named_semaphore_test.cpp 2012-04-11 02:25:04 EDT (Wed, 11 Apr 2012)
@@ -97,6 +97,30 @@
int recursive_named_semaphore_test_wrapper::count_ = 0;
+bool test_named_semaphore_specific()
+{
+ //Test persistance
+ {
+ named_semaphore sem(create_only, SemName, 3);
+ }
+ {
+ named_semaphore sem(open_only, SemName);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == true);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == true);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == true);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == false);
+ sem.post();
+ }
+ {
+ named_semaphore sem(open_only, SemName);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == true);
+ BOOST_INTERPROCES_CHECK(sem.try_wait() == false);
+ }
+
+ named_semaphore::remove(SemName);
+ return true;
+}
+
int main ()
{
try{
@@ -105,6 +129,7 @@
test::test_all_lock<named_semaphore_test_wrapper>();
test::test_all_recursive_lock<recursive_named_semaphore_test_wrapper>();
test::test_all_mutex<false, named_semaphore_test_wrapper>();
+ test_named_semaphore_specific();
}
catch(std::exception &ex){
named_semaphore::remove(SemName);
Modified: trunk/libs/interprocess/test/vectorstream_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/vectorstream_test.cpp (original)
+++ trunk/libs/interprocess/test/vectorstream_test.cpp 2012-04-11 02:25:04 EDT (Wed, 11 Apr 2012)
@@ -20,7 +20,8 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <stdio.h>
-using namespace boost::interprocess;
+namespace boost {
+namespace interprocess {
//Force instantiations to catch compile-time errors
typedef basic_string<char> my_string;
@@ -30,6 +31,10 @@
template class basic_vectorstream<my_string>;
template class basic_vectorstream<std::vector<char> >;
+}}
+
+using namespace boost::interprocess;
+
static int vectorstream_test()
{
{ //Test high watermarking initialization
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk