Jackalope / jlib (public) (License: GPLv3 or later) (since 2019-11-18) (hash sha1)
jlib C++ template library
Used to replace std functionality without exception handling.
- data structures
- filesystem routines
- crossplatform threads interface (currently only pthreads implementation)
- thread pool
- crossplatform dynamic memory functions interface (allocate, reallocate, deallocate) with alignment support
- high percision timer routines based on timespec
List of commits:
Subject Hash Author Date (UTC)
Rename rarray data member p_end_allocated to p_end. 12d598a7f9dd79c28d13ee23238bcf91f7e84d3a Jackalope 2020-06-04 04:19:40
Better config, solving some issues with linking to jlib. 1c3e98b020fad28c1c5ad5ba9237e08494ec24f5 Jackalope 2020-06-01 16:22:42
Version 0.4.2 4d923f27553a9c12ac24f0060039160975c25f7f Jackalope 2020-06-01 12:44:08
darray_mods GCC compilation fix. c8608b53bde33aa15fee76a03139521696c2d0ce Jackalope 2020-06-01 12:42:38
Make jassert constexpr again (yeah, again). 973c1f47663af054fc7680b87e76b951d40e603b Jackalope 2020-06-01 12:20:33
Version 0.4.1 64f005bfab2e8febf82bd381fc135bdfff61ca71 Jackalope 2020-05-31 23:47:41
CMake: build both shared and static with JLIB_SHARED and JLIB_STATIC options. When is subdirectory, select only one instead. Doxygen target renamed from documentation to jlib-doxygen. 20910577a262b43a373f5b8f4a9b444fcdaf56bb Jackalope 2020-05-31 21:37:04
Wide line fix. e6f02dfd80996cf18285fa2cc2e3cbffe3854d11 Jackalope 2020-05-31 18:43:06
fs::stream: discard input function, constructor from FILE. fbe72ec086b44821ea93a61dba7f869b043769e9 Jackalope 2020-05-31 18:42:12
Version 0.4.0 9e5059b4af323e37f4ad0f4f7eb20f562d07c857 Jackalope 2020-05-31 11:17:38
FS limits function fix. 813a0a8aaae122b7b4a4d158cf029aff1733308c Jackalope 2020-05-31 11:05:07
New option JLIB_ALLOCATE_DEBUG fa66e03cd2ea7102bab8a6de3415898c114a27e4 Jackalope 2020-05-31 10:44:49
Changed version config to match versioning compatibility. 393953edfa42b24e43ba027c5d52d7c2df6cf861 Jackalope 2020-05-31 10:43:09
Thread pool wrong doxygen tag fix. 8392eb800adc01d587d9f6ce962ad403f1e5c80c Jackalope 2020-05-29 16:51:33
jassert macro compatibility in if statement without braces. 5c749b8c1cb2cb51c8ddf6ccedef8d72554d6c68 Jackalope 2020-05-29 15:54:53
Version 0.3.0 616c945f21a8da901facc7363c3b204216776a1d Jackalope 2020-05-26 14:37:18
Removing deprecated threads and old thread pool. b2ce1a8eb5b4a1b9c5d6a19fe75e7a52738e6866 Jackalope 2020-05-26 14:31:57
Resolved issues and warnings with GCC. c9ee73408a660c723dd51b74311d572ec4ef2320 Jackalope 2020-05-26 14:19:43
Thread result can be only pointer now. 645f6ce75c773fd2fad543bfd542202d02925288 Jackalope 2020-05-26 14:19:11
Option JLIB_STATIC to select static or shared library. 08b3a60286a7487ce445f66852f0afdd0f99be69 Jackalope 2020-05-26 14:17:11
Commit 12d598a7f9dd79c28d13ee23238bcf91f7e84d3a - Rename rarray data member p_end_allocated to p_end.
Author: Jackalope
Author date (UTC): 2020-06-04 04:19
Committer name: Jackalope
Committer date (UTC): 2020-06-04 04:19
Parent(s): 1c3e98b020fad28c1c5ad5ba9237e08494ec24f5
Signing key:
Tree: c430bd51c05ab0592909a0cd14f6e3a3af312a8c
File Lines added Lines deleted
include/jlib/rarray.h 23 13
File include/jlib/rarray.h changed (mode: 100644) (index e430e04..ceb383e)
... ... struct jl::rarray
58 58 rarray() = default; rarray() = default;
59 59 /// @brief Initialize read-only rarray as array with single value. /// @brief Initialize read-only rarray as array with single value.
60 60 /// @param value Single item to be pointed to. /// @param value Single item to be pointed to.
61 rarray(T &value) : p_begin(&value), p_end_allocated(p_begin+1) {
61 rarray(T &value) : p_begin(&value), p_end(p_begin+1) {
62 62 static_assert (std::is_const<T>::value, "only for read-only rarray"); static_assert (std::is_const<T>::value, "only for read-only rarray");
63 63 } }
64 64 /** /**
 
... ... struct jl::rarray
87 87 * first byte after an allocation. * first byte after an allocation.
88 88 */ */
89 89 rarray(T* p_allocated_mem, T* p_end_alocated_mem) rarray(T* p_allocated_mem, T* p_end_alocated_mem)
90 : p_begin(p_allocated_mem), p_end_allocated(p_end_alocated_mem) {
91 jassert(p_end_allocated >= p_begin, "wrong pointers order");
90 : p_begin(p_allocated_mem), p_end(p_end_alocated_mem) {
91 jassert(p_end >= p_begin, "wrong pointers order");
92 92 } }
93 93 /** /**
94 94 * @brief Initialize with already allocated memory. * @brief Initialize with already allocated memory.
 
... ... struct jl::rarray
101 101 */ */
102 102 rarray(T *p_allocated_mem, size_t allocated_count) rarray(T *p_allocated_mem, size_t allocated_count)
103 103 : p_begin(p_allocated_mem), : p_begin(p_allocated_mem),
104 p_end_allocated(p_allocated_mem + allocated_count) {}
104 p_end(p_allocated_mem + allocated_count) {}
105 105 /** /**
106 106 * @brief Initialize with already allocated pointers to range of values. * @brief Initialize with already allocated pointers to range of values.
107 107 * @tparam R Type with support of begin and end functions. * @tparam R Type with support of begin and end functions.
 
... ... struct jl::rarray
124 124 jassert(count, "must not be 0, use init() instead"); jassert(count, "must not be 0, use init() instead");
125 125 if (not jl::allocate(&p_begin, count)) if (not jl::allocate(&p_begin, count))
126 126 return false; return false;
127 p_end_allocated = p_begin + count;
127 p_end = p_begin + count;
128 128 return true; return true;
129 129 } }
130 130 /** /**
 
... ... struct jl::rarray
166 166 jassert(new_item_count, "cannot be 0"); jassert(new_item_count, "cannot be 0");
167 167 return resize_bytes(sizeof(T) * new_item_count); return resize_bytes(sizeof(T) * new_item_count);
168 168 } }
169
170 /**
171 * @brief Reduce item count without freeing memory.
172 * @param new_item_count New item count in range (0;count].
173 */
174 void forget(size_t new_item_count) {
175 jassert(new_item_count > 0 and new_item_count <= count(),
176 "cannot be 0 and cannot be larger");
177 p_end = p_begin + new_item_count;
178 }
169 179 /** /**
170 180 * @brief Get pointer to item, which is equal to value_to_search. * @brief Get pointer to item, which is equal to value_to_search.
171 181 * @tparam T_CMP T type must have overloaded "==" operator * @tparam T_CMP T type must have overloaded "==" operator
 
... ... struct jl::rarray
194 204 } }
195 205 ///@brief Size of all items (allocated memory) in bytes. ///@brief Size of all items (allocated memory) in bytes.
196 206 [[nodiscard]] size_t size() const { [[nodiscard]] size_t size() const {
197 return size_t(p_end_allocated - p_begin) * sizeof(T);
207 return size_t(p_end - p_begin) * sizeof(T);
198 208 } }
199 209 ///@brief Item count. ///@brief Item count.
200 210 [[nodiscard]] size_t count() const { return size_t(end() - begin()); } [[nodiscard]] size_t count() const { return size_t(end() - begin()); }
 
... ... struct jl::rarray
210 220 [[nodiscard]] const T* begin() const { return reinterpret_cast<T*>(p_begin); } [[nodiscard]] const T* begin() const { return reinterpret_cast<T*>(p_begin); }
211 221 /// @brief Get pointer to the first byte after allocated memory pool. /// @brief Get pointer to the first byte after allocated memory pool.
212 222 [[nodiscard]] T* end() { [[nodiscard]] T* end() {
213 return reinterpret_cast<T*>(p_end_allocated);
223 return reinterpret_cast<T*>(p_end);
214 224 } }
215 225 /// @brief Get pointer with read-only access to the first byte after allocation /// @brief Get pointer with read-only access to the first byte after allocation
216 226 [[nodiscard]] const T* end() const { [[nodiscard]] const T* end() const {
217 return reinterpret_cast<T*>(p_end_allocated);
227 return reinterpret_cast<T*>(p_end);
218 228 } }
219 229 /// @brief Get read-only refference to an item by index /// @brief Get read-only refference to an item by index
220 230 [[nodiscard]] const T& operator[](size_t i) const { [[nodiscard]] const T& operator[](size_t i) const {
 
... ... struct jl::rarray
237 247 template<typename> friend struct rarray; template<typename> friend struct rarray;
238 248 /// @brief Convert to read-only version without issues /// @brief Convert to read-only version without issues
239 249 operator rarray<const T> () const { operator rarray<const T> () const {
240 jassert(p_end_allocated >= p_begin, "corruption detected");
241 return rarray<const T> { p_begin, p_end_allocated };
250 jassert(p_end >= p_begin, "corruption detected");
251 return rarray<const T> { p_begin, p_end };
242 252 } }
243 253 /// @brief Get index of iterator. /// @brief Get index of iterator.
244 254 /// @param p pointer in range [begin;end). /// @param p pointer in range [begin;end).
245 255 /// @return Index of an item on iterator position. /// @return Index of an item on iterator position.
246 256 [[nodiscard]] size_t iterator_index(T *p) { [[nodiscard]] size_t iterator_index(T *p) {
247 jassert(p >= p_begin and p < p_end_allocated,
257 jassert(p >= p_begin and p < p_end,
248 258 "iterator must be in the range [begin,end)"); "iterator must be in the range [begin,end)");
249 259 return size_t(p - p_begin); return size_t(p - p_begin);
250 260 } }
 
... ... protected:
253 263 jassert(new_size, "cannot be 0"); jassert(new_size, "cannot be 0");
254 264 if (not reallocate_bytes(&p_begin, new_size)) if (not reallocate_bytes(&p_begin, new_size))
255 265 return false; return false;
256 p_end_allocated = p_begin + new_size;
266 p_end = p_begin + new_size;
257 267 return true; return true;
258 268 } }
259 269 T *p_begin; T *p_begin;
260 T *p_end_allocated;
270 T *p_end;
261 271 }; };
262 272
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Jackalope/jlib

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jlib

Clone this repository using git:
git clone git://git.rocketgit.com/user/Jackalope/jlib

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main