[med-svn] [Git][med-team/readerwriterqueue][master] 4 commits: New upstream version 1.0.4

Nilesh Patra gitlab at salsa.debian.org
Wed Apr 21 15:22:59 BST 2021



Nilesh Patra pushed to branch master at Debian Med / readerwriterqueue


Commits:
5b2ef895 by Nilesh Patra at 2021-04-21T19:45:25+05:30
New upstream version 1.0.4
- - - - -
21de88d0 by Nilesh Patra at 2021-04-21T19:45:26+05:30
Update upstream source from tag 'upstream/1.0.4'

Update to upstream version '1.0.4'
with Debian dir f42c26daf61b21511cf790899f831d418a5d6c52
- - - - -
789cbb9a by Nilesh Patra at 2021-04-21T19:49:23+05:30
Declare compliance with policy 4.5.1

- - - - -
1d07c680 by Nilesh Patra at 2021-04-21T19:52:24+05:30
Interim changelog entry

- - - - -


8 changed files:

- CMakeLists.txt
- atomicops.h
- debian/changelog
- debian/control
- readerwriterqueue.h
- tests/stabtest/makefile
- tests/unittests/makefile
- tests/unittests/unittests.cpp


Changes:

=====================================
CMakeLists.txt
=====================================
@@ -5,5 +5,7 @@ include(GNUInstallDirs)
 
 add_library(${PROJECT_NAME} INTERFACE)
 
+target_include_directories(readerwriterqueue INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
 install(FILES atomicops.h readerwriterqueue.h LICENSE.md
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})


=====================================
atomicops.h
=====================================
@@ -460,11 +460,11 @@ namespace moodycamel
 				return timed_wait(0);
 			}
 
-			bool timed_wait(std::int64_t timeout_usecs) AE_NO_TSAN
+			bool timed_wait(std::uint64_t timeout_usecs) AE_NO_TSAN
 			{
 				mach_timespec_t ts;
 				ts.tv_sec = static_cast<unsigned int>(timeout_usecs / 1000000);
-				ts.tv_nsec = (timeout_usecs % 1000000) * 1000;
+				ts.tv_nsec = static_cast<int>((timeout_usecs % 1000000) * 1000);
 
 				// added in OSX 10.10: https://developer.apple.com/library/prerelease/mac/documentation/General/Reference/APIDiffsMacOSX10_10SeedDiff/modules/Darwin.html
 				kern_return_t rc = semaphore_timedwait(m_sema, ts);
@@ -500,7 +500,7 @@ namespace moodycamel
 		    AE_NO_TSAN Semaphore(int initialCount = 0)
 		    {
 		        assert(initialCount >= 0);
-		        int rc = sem_init(&m_sema, 0, initialCount);
+		        int rc = sem_init(&m_sema, 0, static_cast<unsigned int>(initialCount));
 		        assert(rc == 0);
 		        AE_UNUSED(rc);
 		    }
@@ -537,8 +537,8 @@ namespace moodycamel
 				const int usecs_in_1_sec = 1000000;
 				const int nsecs_in_1_sec = 1000000000;
 				clock_gettime(CLOCK_REALTIME, &ts);
-				ts.tv_sec += (time_t)(usecs / usecs_in_1_sec);
-				ts.tv_nsec += (long)(usecs % usecs_in_1_sec) * 1000;
+				ts.tv_sec += static_cast<time_t>(usecs / usecs_in_1_sec);
+				ts.tv_nsec += static_cast<long>(usecs % usecs_in_1_sec) * 1000;
 				// sem_timedwait bombs if you have more than 1e9 in tv_nsec
 				// so we have to clean things up before passing it in
 				if (ts.tv_nsec >= nsecs_in_1_sec) {
@@ -606,7 +606,7 @@ namespace moodycamel
 					if (m_sema.wait())
 						return true;
 				}
-				if (timeout_usecs > 0 && m_sema.timed_wait(timeout_usecs))
+				if (timeout_usecs > 0 && m_sema.timed_wait(static_cast<uint64_t>(timeout_usecs)))
 					return true;
 				// At this point, we've timed out waiting for the semaphore, but the
 				// count is still decremented indicating we may still be waiting on
@@ -662,10 +662,10 @@ namespace moodycamel
 		        }
 		    }
 		    
-		    ssize_t availableApprox() const AE_NO_TSAN
+		    std::size_t availableApprox() const AE_NO_TSAN
 		    {
 		    	ssize_t count = m_count.load();
-		    	return count > 0 ? count : 0;
+		    	return count > 0 ? static_cast<std::size_t>(count) : 0;
 		    }
 		};
 	}	// end namespace spsc_sema


=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+readerwriterqueue (1.0.4-1) UNRELEASED; urgency=medium
+
+  * Team Upload.
+  * New upstream version 1.0.4
+  * Declare compliance with policy 4.5.1
+
+ -- Nilesh Patra <nilesh at debian.org>  Wed, 21 Apr 2021 19:49:39 +0530
+
 readerwriterqueue (1.0.3-1) unstable; urgency=medium
 
   * Team Upload.


=====================================
debian/control
=====================================
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
 Uploaders: Steffen Moeller <moeller at debian.org>
 Build-Depends: debhelper-compat (= 13), cmake
-Standards-Version: 4.5.0
+Standards-Version: 4.5.1
 Homepage: https://github.com/cameron314/readerwriterqueue
 Vcs-Browser: https://salsa.debian.org/med-team/readerwriterqueue
 Vcs-Git: https://salsa.debian.org/med-team/readerwriterqueue.git


=====================================
readerwriterqueue.h
=====================================
@@ -48,6 +48,21 @@
 #endif
 #endif
 
+#ifndef MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE
+#if defined (__APPLE__) && defined (__MACH__) && __cplusplus >= 201703L
+// This is required to find out what deployment target we are using
+#include <CoreFoundation/CoreFoundation.h>
+#if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
+// C++17 new(size_t, align_val_t) is not backwards-compatible with older versions of macOS, so we can't support over-alignment in this case
+#define MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE
+#endif
+#endif
+#endif
+
+#ifndef MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE
+#define MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE AE_ALIGN(MOODYCAMEL_CACHE_LINE_SIZE)
+#endif
+
 #ifdef AE_VCPP
 #pragma warning(push)
 #pragma warning(disable: 4324)	// structure was padded due to __declspec(align())
@@ -58,7 +73,7 @@
 namespace moodycamel {
 
 template<typename T, size_t MAX_BLOCK_SIZE = 512>
-class AE_ALIGN(MOODYCAMEL_CACHE_LINE_SIZE) ReaderWriterQueue
+class MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE ReaderWriterQueue
 {
 	// Design: Based on a queue-of-queues. The low-level queues are just
 	// circular buffers with front and tail indices indicating where the
@@ -93,7 +108,6 @@ public:
 		,dequeuing(false)
 #endif
 	{
-		assert(size > 0);
 		assert(MAX_BLOCK_SIZE == ceilToPow2(MAX_BLOCK_SIZE) && "MAX_BLOCK_SIZE must be a power of 2");
 		assert(MAX_BLOCK_SIZE >= 2 && "MAX_BLOCK_SIZE must be at least 2");
 		
@@ -661,7 +675,7 @@ private:
 #ifndef NDEBUG
 	struct ReentrantGuard
 	{
-		AE_NO_TSAN ReentrantGuard(bool& _inSection)
+		AE_NO_TSAN ReentrantGuard(weak_atomic<bool>& _inSection)
 			: inSection(_inSection)
 		{
 			assert(!inSection && "Concurrent (or re-entrant) enqueue or dequeue operation detected (only one thread at a time may hold the producer or consumer role)");
@@ -674,7 +688,7 @@ private:
 		ReentrantGuard& operator=(ReentrantGuard const&);
 
 	private:
-		bool& inSection;
+		weak_atomic<bool>& inSection;
 	};
 #endif
 
@@ -698,7 +712,7 @@ private:
 
 		// size must be a power of two (and greater than 0)
 		AE_NO_TSAN Block(size_t const& _size, char* _rawThis, char* _data)
-			: front(0), localTail(0), tail(0), localFront(0), next(nullptr), data(_data), sizeMask(_size - 1), rawThis(_rawThis)
+			: front(0UL), localTail(0), tail(0UL), localFront(0), next(nullptr), data(_data), sizeMask(_size - 1), rawThis(_rawThis)
 		{
 		}
 
@@ -735,8 +749,8 @@ private:
 	size_t largestBlockSize;
 
 #ifndef NDEBUG
-	bool enqueuing;
-	mutable bool dequeuing;
+	weak_atomic<bool> enqueuing;
+	mutable weak_atomic<bool> dequeuing;
 #endif
 };
 


=====================================
tests/stabtest/makefile
=====================================
@@ -18,7 +18,7 @@ endif
 default: stabtest$(EXT)
 
 stabtest$(EXT): stabtest.cpp ../../readerwriterqueue.h ../../atomicops.h ../common/simplethread.h ../common/simplethread.cpp makefile
-	g++ $(PLATFORM_OPTS) -std=c++11 -Wpedantic -Wall -DNDEBUG -O3 stabtest.cpp ../common/simplethread.cpp -o stabtest$(EXT) -pthread $(PLATFORM_LD_OPTS)
+	g++ $(PLATFORM_OPTS) -std=c++11 -Wsign-conversion -Wpedantic -Wall -DNDEBUG -O3 stabtest.cpp ../common/simplethread.cpp -o stabtest$(EXT) -pthread $(PLATFORM_LD_OPTS)
 
 run: stabtest$(EXT)
 	./stabtest$(EXT)


=====================================
tests/unittests/makefile
=====================================
@@ -21,7 +21,7 @@ endif
 default: unittests$(EXT)
 
 unittests$(EXT): unittests.cpp ../../readerwriterqueue.h ../../atomicops.h ../common/simplethread.h ../common/simplethread.cpp minitest.h makefile
-	g++ $(PLATFORM_OPTS) -std=c++11 -Wpedantic -Wall -DNDEBUG -O3 -g unittests.cpp ../common/simplethread.cpp -o unittests$(EXT) -pthread $(PLATFORM_LD_OPTS)
+	g++ $(PLATFORM_OPTS) -std=c++11 -Wsign-conversion -Wpedantic -Wall -DNDEBUG -O3 -g unittests.cpp ../common/simplethread.cpp -o unittests$(EXT) -pthread $(PLATFORM_LD_OPTS)
 
 run: unittests$(EXT)
 	./unittests$(EXT)


=====================================
tests/unittests/unittests.cpp
=====================================
@@ -19,7 +19,18 @@ struct Foo
 {
 	Foo() : copied(false) { id = _id()++; }
 	Foo(Foo const& other) : id(other.id), copied(true) { }
-	~Foo()
+	Foo(Foo&& other) : id(other.id), copied(other.copied) { other.copied = true; }
+	Foo& operator=(Foo&& other)
+	{
+		verify();
+		id = other.id, copied = other.copied;
+		other.copied = true;
+		return *this;
+	}
+	~Foo() { verify(); }
+
+private:
+	void verify()
 	{
 		if (copied) return;
 		if (id != _last_destroyed_id() + 1) {
@@ -28,6 +39,8 @@ struct Foo
 		_last_destroyed_id() = id;
 		++_destroy_count();
 	}
+
+public:
 	static void reset() { _destroy_count() = 0; _id() = 0; _destroyed_in_order() = true; _last_destroyed_id() = -1; }
 	static int destroy_count() { return _destroy_count(); }
 	static bool destroyed_in_order() { return _destroyed_in_order(); }
@@ -166,8 +179,6 @@ public:
 	
 	bool nonempty_destroy()
 	{
-		Foo item;
-		
 		// Some elements at beginning
 		Foo::reset();
 		{
@@ -175,6 +186,7 @@ public:
 			for (int i = 0; i != 10; ++i) {
 				q.enqueue(Foo());
 			}
+			ASSERT_OR_FAIL(Foo::destroy_count() == 0);
 		}
 		ASSERT_OR_FAIL(Foo::destroy_count() == 10);
 		ASSERT_OR_FAIL(Foo::destroyed_in_order());
@@ -186,6 +198,7 @@ public:
 			for (int i = 0; i != 31; ++i) {
 				q.enqueue(Foo());
 			}
+			ASSERT_OR_FAIL(Foo::destroy_count() == 0);
 		}
 		ASSERT_OR_FAIL(Foo::destroy_count() == 31);
 		ASSERT_OR_FAIL(Foo::destroyed_in_order());
@@ -197,6 +210,7 @@ public:
 			for (int i = 0; i != 94; ++i) {
 				q.enqueue(Foo());
 			}
+			ASSERT_OR_FAIL(Foo::destroy_count() == 0);
 		}
 		ASSERT_OR_FAIL(Foo::destroy_count() == 94);
 		ASSERT_OR_FAIL(Foo::destroyed_in_order());
@@ -205,20 +219,24 @@ public:
 		Foo::reset();
 		{
 			ReaderWriterQueue<Foo> q(31);
+			Foo item;
 			for (int i = 0; i != 42; ++i) {
 				q.enqueue(Foo());
 			}
+			ASSERT_OR_FAIL(Foo::destroy_count() == 0);
 			for (int i = 0; i != 31; ++i) {
 				ASSERT_OR_FAIL(q.try_dequeue(item));
 			}
+			ASSERT_OR_FAIL(Foo::destroy_count() == 31);
 		}
-		ASSERT_OR_FAIL(Foo::destroy_count() == 42);
+		ASSERT_OR_FAIL(Foo::destroy_count() == 43);
 		ASSERT_OR_FAIL(Foo::destroyed_in_order());
 		
 		// Some elements in multiple blocks
 		Foo::reset();
 		{
 			ReaderWriterQueue<Foo> q(31);
+			Foo item;
 			for (int i = 0; i != 123; ++i) {
 				q.enqueue(Foo());
 			}
@@ -241,7 +259,7 @@ public:
 				q.enqueue(Foo());
 			}
 		}
-		ASSERT_OR_FAIL(Foo::destroy_count() == 500);
+		ASSERT_OR_FAIL(Foo::destroy_count() == 501);
 		ASSERT_OR_FAIL(Foo::destroyed_in_order());
 		
 		return true;
@@ -434,7 +452,7 @@ public:
 					fence(memory_order_release);
 					front = front.load() + 1;
 				}
-				int size = (int)q.size_approx();
+				int size = static_cast<int>(q.size_approx());
 				fence(memory_order_acquire);
 				int tail_ = tail.load();
 				int front_ = front.load();
@@ -451,7 +469,7 @@ public:
 				int tail_ = tail.load();
 				int front_ = front.load();
 				fence(memory_order_acquire);
-				int size = (int)q.size_approx();
+				int size = static_cast<int>(q.size_approx());
 				if (size > tail_ - front_ || size < 0) {
 					result = 0;
 				}
@@ -469,7 +487,7 @@ public:
 		{
 			// this math for queue size estimation is only valid for q_size <= 256
 			for (size_t q_size = 2; q_size < 256; ++q_size) {
-				ReaderWriterQueue<int> q(q_size);
+				ReaderWriterQueue<size_t> q(q_size);
 				ASSERT_OR_FAIL(q.max_capacity() == ceilToPow2(q_size+1)-1);
 
 				const size_t start_cap = q.max_capacity();



View it on GitLab: https://salsa.debian.org/med-team/readerwriterqueue/-/compare/4ae49b82646a7af260f3fb88889c932a3e8f23f0...1d07c68060520741ae85b4bd1b90c6b1a6f01779

-- 
View it on GitLab: https://salsa.debian.org/med-team/readerwriterqueue/-/compare/4ae49b82646a7af260f3fb88889c932a3e8f23f0...1d07c68060520741ae85b4bd1b90c6b1a6f01779
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210421/e43acced/attachment-0001.htm>


More information about the debian-med-commit mailing list