From e8dd175c09da6456041e56ff52fd78122834e479 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 27 Oct 2019 19:47:06 +0100 Subject: [PATCH] 64-bit mingw port: size_t may be larger than 'unsigned long'. --- include/cln/GV.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/cln/SV.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/include/cln/GV.h b/include/cln/GV.h index 338edfa..3e45090 100644 --- a/include/cln/GV.h +++ b/include/cln/GV.h @@ -38,6 +38,12 @@ public: const cl_GV_constindex operator[] (unsigned int index) const; const cl_GV_index operator[] (int index); const cl_GV_constindex operator[] (int index) const; + #if long_bitsize < pointer_bitsize + const cl_GV_index operator[] (unsigned long long index); + const cl_GV_constindex operator[] (unsigned long long index) const; + const cl_GV_index operator[] (long long index); + const cl_GV_constindex operator[] (long long index) const; + #endif public: /* ugh */ // Constructor. cl_GV_inner (std::size_t l, cl_GV_vectorops* ops) : len (l), vectorops (ops) {} @@ -163,6 +169,34 @@ inline const cl_GV_constindex cl_GV_inner::operator[] (int index) const return operator[]((unsigned long)index); } +#if long_bitsize < pointer_bitsize + +template +inline const cl_GV_index cl_GV_inner::operator[] (unsigned long long index) +{ + return cl_GV_index(this,index); +} + +template +inline const cl_GV_constindex cl_GV_inner::operator[] (unsigned long long index) const +{ + return cl_GV_constindex(this,index); +} + +template +inline const cl_GV_index cl_GV_inner::operator[] (long long index) +{ + return operator[]((unsigned long)index); +} + +template +inline const cl_GV_constindex cl_GV_inner::operator[] (long long index) const +{ + return operator[]((unsigned long)index); +} + +#endif + template inline cl_GV_inner::~cl_GV_inner () { @@ -245,6 +279,20 @@ public: { return operator[]((unsigned long)index); } const cl_GV_index operator[] (int index) { return operator[]((unsigned long)index); } + #if long_bitsize < pointer_bitsize + const cl_GV_constindex operator[] (unsigned long long index) const + { + return ((const cl_heap_GV *) this->pointer)->v[index]; + } + const cl_GV_index operator[] (unsigned long long index) + { + return ((cl_heap_GV *) this->pointer)->v[index]; + } + const cl_GV_constindex operator[] (long long index) const + { return operator[]((unsigned long long)index); } + const cl_GV_index operator[] (long long index) + { return operator[]((unsigned long long)index); } + #endif // Copy constructor. cl_GV (const cl_GV&); // Assignment operator. diff --git a/include/cln/SV.h b/include/cln/SV.h index 7c57614..e4e785e 100644 --- a/include/cln/SV.h +++ b/include/cln/SV.h @@ -75,6 +75,26 @@ public: { return operator[]((unsigned long)index); } T & operator[] (int index) { return operator[]((unsigned long)index); } + #if long_bitsize < pointer_bitsize + const T & operator[] (unsigned long long index) const + { + #ifndef CL_SV_NO_RANGECHECKS + if (!(index < size())) throw runtime_exception(); + #endif + return data()[index]; + } + T & operator[] (unsigned long long index) + { + #ifndef CL_SV_NO_RANGECHECKS + if (!(index < size())) throw runtime_exception(); + #endif + return data()[index]; + } + const T & operator[] (long long index) const + { return operator[]((unsigned long long)index); } + T & operator[] (long long index) + { return operator[]((unsigned long long)index); } + #endif public: /* ugh */ // Constructor. cl_SV_inner (std::size_t l) : len (l) {} @@ -142,6 +162,20 @@ public: { return operator[]((unsigned long)index); } T & operator[] (int index) { return operator[]((unsigned long)index); } + #if long_bitsize < pointer_bitsize + const T & operator[] (unsigned long long index) const + { + return ((const cl_heap_SV *) this->pointer)->v[index]; + } + T & operator[] (unsigned long long index) + { + return ((cl_heap_SV *) this->pointer)->v[index]; + } + const T & operator[] (long long index) const + { return operator[]((unsigned long long)index); } + T & operator[] (long long index) + { return operator[]((unsigned long long)index); } + #endif // Constructors. cl_SV (const cl_SV&); // Assignment operators. -- 2.49.0