commit c23cba1e954a1ff21e5229b04cb7dd3e62cdb04b parent 701dcd26c847e003cccb6ce8410a5dfd9fb532ad Author: vaplv <vaplv@free.fr> Date: Mon, 14 Jun 2021 22:06:58 +0200 Merge branch 'release_0.12' Diffstat:
123 files changed, 675 insertions(+), 194 deletions(-)
diff --git a/README.md b/README.md @@ -17,6 +17,17 @@ project can be now edited, built, tested and installed as any CMake project. ## Release notes +### Version 0.12 + +- Add the `cstr_parse_list` function that parses a string as a tuple. The + function used to parse each element is defined by the caller. +- Add functions to encode/decode 2D and 3D morton indices. +- Add the `BIT_<U|I>16` macros that set a bit on a 16-bit integer. +- Add the FMADD macro defining wether the FMA instruction is supported by the + COMPILer. +- Fix the `time_dump` function: the returned `real_dump_size` was wrongly + evaluated. + ### Version 0.11 - Add the `find_iterator` function to the hash table data structure. This @@ -135,7 +146,7 @@ project can be now edited, built, tested and installed as any CMake project. ## License -Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr). RSys is a free software +Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr). RSys is a free software released under LGPL v3+ license. You are welcome to redistribute it under certain conditions; refer to the COPYING files for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +# Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) # # This CMake script is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ include(rcmake) # Configure and define targets ################################################################################ set(VERSION_MAJOR 0) -set(VERSION_MINOR 11) +set(VERSION_MINOR 12) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) @@ -107,6 +107,7 @@ set(RSYS_FILES_INC_API logger.h math.h mem_allocator.h + morton.h mutex.h quaternion.h real2.h @@ -230,6 +231,7 @@ if(NOT NO_TEST) new_test(test_math ${MATH_LIB}) new_test(test_mem_allocator rsys) new_test(test_misc) + new_test(test_morton) new_test(test_quaternion rsys) new_test(test_ref) new_test(test_signal rsys) diff --git a/src/algorithm.h b/src/algorithm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/binary_heap.h b/src/binary_heap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/clock_time.c b/src/clock_time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -167,7 +167,7 @@ time_dump "%li %s", (long)Time, Time > 1 ? Suffix "s ": Suffix " "); \ ASSERT(len >= 0); \ if(real_dump_len) { \ - real_dump_len += len; \ + *real_dump_len += (size_t)len; \ } \ if((size_t)len < available_dump_space) { \ dst += len; \ @@ -213,6 +213,9 @@ time_dump if(time_nsec) DUMP(time_nsec, "nsec"); } + /* Remove last space */ + if(real_dump_len) *real_dump_len -= 1; + if(dump) { size_t dump_len = strlen(dump); if(!dump_len && flag) { @@ -225,6 +228,7 @@ time_dump } dump_len = strlen(dump); } + /* Remove last space */ if(dump[dump_len-1] == ' ') { dump[dump_len-1] = '\0'; } diff --git a/src/clock_time.h b/src/clock_time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/condition.h b/src/condition.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/cstr.c b/src/cstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -13,7 +13,10 @@ * You should have received a copy of the GNU Lesser General Public License * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 200112L /* strtok_r support */ + #include "cstr_to_list.h" +#include "str.h" #define CSTR_LIST_TYPE double #include "cstr_to_list.h" @@ -24,3 +27,44 @@ #define CSTR_LIST_TYPE unsigned #define CSTR_LIST_SUFFIX uint #include "cstr_to_list.h" + +RSYS_API res_T +cstr_parse_list + (const char* str, + const char delimiter, + res_T (*parse_element)(const char* elmt, void* ctx), + void* ctx) /* User defined data sent to 'parse_element' */ +{ + struct str buf; + char delim[2] = {'\0', '\0'}; + char* tk; + char* tk_ctx; + res_T res = RES_OK; + + str_init(NULL, &buf); + + if(!str || !parse_element) { + res = RES_BAD_ARG; + goto error; + } + + /* Copy str in a temporary buffer to parse */ + res = str_set(&buf, str); + if(res != RES_OK) goto error; + + /* Parse the list */ + delim[0] = delimiter; + tk = strtok_r(str_get(&buf), delim, &tk_ctx); + while(tk) { + res = parse_element(tk, ctx); + if(res != RES_OK) goto error; + tk = strtok_r(NULL, delim, &tk_ctx); + } + +exit: + str_release(&buf); + return res; +error: + goto exit; +} + diff --git a/src/cstr.h b/src/cstr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -150,6 +150,18 @@ res_to_cstr(const res_T res) BEGIN_DECLS +/* Parse a string representing a list whose its elements are separated by the + * 'delimeter' char. The functor 'parse_element' is invoked on each element of + * the list. If it notifies an error, i.e. if the parsing of an element failed, + * the overall parsing is instantly stopped and the error is returned to the + * caller */ +RSYS_API res_T +cstr_parse_list + (const char* str, + const char delimiter, + res_T (*parse_element)(const char* elmt, void* ctx), + void* ctx); /* User defined data sent to 'parse_element' */ + /* Convert a string "A:B:C:D:E:F" in a list of { A, B, C, D, E, F }. ':' can be * any user defined character */ RSYS_API res_T diff --git a/src/cstr_to_list.h b/src/cstr_to_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -23,7 +23,7 @@ #define CSTR_TO_LIST_H #include "cstr.h" -#include "dynamic_array_char.h" +#include "str.h" #endif /* CSTR_TO_LIST_H */ #else /* defined(CSTR_LIST_TYPE) */ @@ -43,35 +43,32 @@ CONCAT(cstr_to_list_, CSTR_LIST_SUFFIX) CSTR_LIST_TYPE dst[], size_t* length, const size_t max_length) /* Maximum size of dst */ - { - struct darray_char buf; + struct str buf; char delim[2] = {'\0', '\0'}; - size_t str_len; size_t i; char* tk; + char* tk_ctx; res_T res = RES_OK; + str_init(NULL, &buf); + if(!str) { - /* Avoid exit block since buf is not initialised */ - return RES_BAD_ARG; + res = RES_BAD_ARG; + goto error; } if(!dst && !length) { /* Useless invocation */ - /* Avoid exit block since buf is not initialised */ - return RES_OK; + goto exit; } /* Copy str in a temporary buffer to parse */ - darray_char_init(NULL, &buf); - str_len = strlen(str); - res = darray_char_resize(&buf, str_len + 1/*null char*/); + res = str_set(&buf, str); if(res != RES_OK) goto error; - strncpy(darray_char_data_get(&buf), str, str_len + 1/*null char*/); /* Parse the string */ delim[0] = delimiter; - tk = strtok(darray_char_data_get(&buf), delim); - for(i=0; tk; tk = strtok(NULL, delim), ++i) { + tk = strtok_r(str_get(&buf), delim, &tk_ctx); + for(i=0; tk; tk = strtok_r(NULL, delim, &tk_ctx), ++i) { if(dst) { if(i >= max_length) { res = RES_BAD_ARG; @@ -89,7 +86,7 @@ CONCAT(cstr_to_list_, CSTR_LIST_SUFFIX) *length = i; exit: - darray_char_release(&buf); + str_release(&buf); return res; error: goto exit; diff --git a/src/double2.h b/src/double2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/double22.h b/src/double22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/double3.h b/src/double3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/double33.h b/src/double33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/double4.h b/src/double4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/double44.h b/src/double44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array.h b/src/dynamic_array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_char.h b/src/dynamic_array_char.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_double.h b/src/dynamic_array_double.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_float.h b/src/dynamic_array_float.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_int.h b/src/dynamic_array_int.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_size_t.h b/src/dynamic_array_size_t.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_str.h b/src/dynamic_array_str.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_u32.h b/src/dynamic_array_u32.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_u64.h b/src/dynamic_array_u64.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_uchar.h b/src/dynamic_array_uchar.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/dynamic_array_uint.h b/src/dynamic_array_uint.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/endianness.h b/src/endianness.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float2.h b/src/float2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float22.h b/src/float22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float3.h b/src/float3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float33.h b/src/float33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float4.h b/src/float4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/float44.h b/src/float44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/free_list.h b/src/free_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/hash.c b/src/hash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -17,10 +17,16 @@ #include "endianness.h" #include "hash.h" +#include "math.h" #include "mem_allocator.h" #include <string.h> +struct buffer { + const char* mem; + size_t len; +}; + /* Array of round constants: first 32 bits of the fractional parts of the cube * roots of the first 64 primes 2..311 */ static const uint32_t k[64] = { @@ -48,56 +54,60 @@ rrot(const uint32_t ui, const unsigned int count) return ui >> count | ui << (32 - count); } -static size_t -create_msg - (struct mem_allocator* allocator, - const void* data, - const size_t len, - char** out_msg) +static void +get_chunk512(char dst[64], const size_t ichunk512, void* ctx) { - char* msg = NULL; - size_t msg_sz = 0; - ASSERT(allocator && out_msg); - - msg_sz = ALIGN_SIZE(len + 1/*Byte of the '1' bit*/ + 8/*message len*/, 64u); - msg = MEM_ALLOC(allocator, msg_sz); - if(!msg) goto error; - - memcpy(msg, data, len); - - /* Setup the '1' bit that marks the end of the msg */ - msg[len] = (char)0x80u; - /* Clean up the bytes after the msg up to the last 8 bytes */ - memset(msg+len+1, 0, msg_sz - len - 1 - 8); - /* Store the message 8*len in big endian */ - *(uint64_t*)(msg+msg_sz-8) = big_endian_64(len*8); - -exit: - *out_msg = msg; - return msg_sz; - -error: - msg_sz = 0; - if(msg) { MEM_RM(allocator, msg); msg = NULL; } - goto exit; + struct buffer* buf = ctx; + const char* chunk = NULL; + size_t chunk_sz = 0; + const size_t offset = ichunk512*(sizeof(char[64])); + ASSERT(buf && offset < buf->len); + + chunk = buf->mem + offset; + chunk_sz = MMIN(buf->len - offset, sizeof(char[64])); + memcpy(dst, chunk, chunk_sz); } /******************************************************************************* * Exported functions ******************************************************************************/ -res_T +void hash_sha256 - (struct mem_allocator* mem_allocator, - const void* data, + (const void* data, const size_t len, hash256_T hash) { - struct mem_allocator* allocator = NULL; - char* msg = NULL; + struct chunked_data_desc desc = CHUNKED_DATA_DESC_NULL; + struct buffer buf; + + buf.mem = data; + buf.len = len; + + desc.get_chunk512 = get_chunk512; + desc.size = len; + desc.context = &buf; + + hash_sha256_chunked_data(&desc, hash); +} + +void +hash_sha256_chunked_data + (struct chunked_data_desc* data, + hash256_T hash) +{ + /* Actually, the size of one chunk is 64 bytes. Anyway, note that after the + * last byte of the data to digest, one has to store 9 additionnal bytes: 1 + * to mark the end of the data and 8 used to save the effective data length. + * Such tailing bytes can exceed the 64 bytes length of the chunk. Since the + * overall message length must be aligned on 64 bytes we thus pre-allocate an + * array whose size is 2 times the chunk size */ + char buffer[64*2]; + size_t msg_sz = 0; size_t ichunk = 0; size_t nchunks = 0; - res_T res = RES_OK; + size_t ichunk_last_byte = 0; /* Chunk id the last data byte */ + size_t remaining_data_sz = 0; /* Initial hash values: first 32 bits of the fractional parts of the square * roots of the first 8 primes 2..19 */ @@ -109,22 +119,60 @@ hash_sha256 uint32_t h5 = 0x9b05688c; uint32_t h6 = 0x1f83d9ab; uint32_t h7 = 0x5be0cd19; - ASSERT(hash); + ASSERT(data && hash); - allocator = mem_allocator ? mem_allocator : &mem_default_allocator; + remaining_data_sz = data->size; - msg_sz = create_msg(allocator, data, len, &msg); - if(!msg) { res = RES_MEM_ERR; goto error; } + /* Compute the overall size of the message */ + msg_sz = ALIGN_SIZE + (data->size + 1/*Byte of the '1' bit*/ + 8/*message len*/, 64u); ASSERT((msg_sz % 64) == 0); nchunks = msg_sz / 64; /* #chunks of 512 bits */ + /* Index of the chunk containing the last data byte */ + ichunk_last_byte = data->size / 64; + FOR_EACH(ichunk, 0, nchunks) { - const char* chunk = msg + ichunk*64; + char* chunk = NULL; uint32_t w[64] = {0}; uint32_t a=h0, b=h1, c=h2, d=h3, e=h4, f=h5, g=h6, h=h7; int i; + if(ichunk > ichunk_last_byte) { + chunk = buffer + 64; + } else { + chunk = buffer; + + /* Fetch the user data if any */ + if(remaining_data_sz) { + ASSERT(data->get_chunk512); + data->get_chunk512(buffer, ichunk, data->context); + remaining_data_sz = remaining_data_sz > 64 + ? remaining_data_sz - 64 : 0; + } + + /* Setup the tailing bytes of the message */ + if(ichunk == ichunk_last_byte) { + char* remaining_msg = buffer; + const size_t remaining_msg_sz = ichunk_last_byte==nchunks-1 ? 64 : 128; + + /* Id after the last data byte */ + const size_t ibyte_len = data->size % 64; + + /* Setup the '1' bit that marks the end of the data */ + remaining_msg[ibyte_len] = (char)0x80u; + + /* Clean up the bytes after the data up to the last 8 bytes */ + memset(remaining_msg + ibyte_len + 1, 0, + remaining_msg_sz - ibyte_len - 1 - 8); + + /* Store the message 8*len in big endian */ + *(uint64_t*)(remaining_msg + remaining_msg_sz-8) = + big_endian_64(data->size*8); + } + } + FOR_EACH(i, 0, 16) { w[i] = big_endian_32(((uint32_t*)chunk)[i]); } @@ -166,12 +214,6 @@ hash_sha256 ((uint32_t*)hash)[5] = big_endian_32(h5); ((uint32_t*)hash)[6] = big_endian_32(h6); ((uint32_t*)hash)[7] = big_endian_32(h7); - -exit: - if(msg) MEM_RM(allocator, msg); - return res; -error: - goto exit; } void diff --git a/src/hash.h b/src/hash.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -22,6 +22,20 @@ struct mem_allocator; typedef char hash256_T[32]; +struct chunked_data_desc { + /* Get the data per chunk of 512 bits. The last chunk length can be lesser + * than 512 bits */ + void (*get_chunk512) + (char dst[64], /* Destination */ + const size_t ichunk512, /* Indices of the chunck of 512 bits to fetch */ + void* ctx); /* User defined variable */ + size_t size; /* Size in bytes of the data */ + void* context; /* User defined variable */ +}; +#define CHUNKED_DATA_DESC_NULL__ {NULL, 0, NULL} +static const struct chunked_data_desc CHUNKED_DATA_DESC_NULL = + CHUNKED_DATA_DESC_NULL__; + /* 32-bits Fowler/Noll/Vo hash function */ static INLINE uint32_t hash_fnv32(const void* data, const size_t len) @@ -62,14 +76,18 @@ hash_fnv64(const void* data, const size_t len) BEGIN_DECLS -RSYS_API res_T +RSYS_API void hash_sha256 - (struct mem_allocator* allocator, - const void* data, + (const void* data, const size_t len, hash256_T hash); RSYS_API void +hash_sha256_chunked_data + (struct chunked_data_desc* data, + hash256_T hash); + +RSYS_API void hash256_to_cstr (const hash256_T hash, char cstr[65]); diff --git a/src/hash_table.h b/src/hash_table.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/image.c b/src/image.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/image.h b/src/image.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/io_c99.h b/src/io_c99.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/library.c b/src/library.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/library.h b/src/library.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/list.h b/src/list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/logger.c b/src/logger.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/logger.h b/src/logger.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/math.h b/src/math.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/mem_allocator.c b/src/mem_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/mem_allocator.h b/src/mem_allocator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/mem_lifo_allocator.c b/src/mem_lifo_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/mem_proxy_allocator.c b/src/mem_proxy_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/morton.h b/src/morton.h @@ -0,0 +1,104 @@ +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) + * + * The RSys library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The RSys library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef MORTON_H +#define MORTON_H + +#include "rsys.h" + +static FINLINE uint32_t +morton2D_encode_u16(const uint16_t u16) +{ + uint32_t u32 = u16; + u32 = (u32 | (u32 << 8)) & 0x00FF00FF; + u32 = (u32 | (u32 << 4)) & 0X0F0F0F0F; + u32 = (u32 | (u32 << 2)) & 0x33333333; + u32 = (u32 | (u32 << 1)) & 0x55555555; + return u32; +} + +static FINLINE uint16_t +morton2D_decode_u16(const uint32_t u32) +{ + uint32_t x = u32 & 0x55555555; + x = (x | (x >> 1)) & 0x33333333; + x = (x | (x >> 2)) & 0x0F0F0F0F; + x = (x | (x >> 4)) & 0x00FF00FF; + x = (x | (x >> 8)) & 0x0000FFFF; + return (uint16_t)x; +} + +static INLINE uint64_t +morton3D_encode_u21(const uint32_t u21) +{ + uint64_t u64 = u21 & ((1<<21) - 1); + ASSERT(u21 <= ((1 << 21) - 1)); + u64 = (u64 | (u64 << 32)) & 0xFFFF00000000FFFF; + u64 = (u64 | (u64 << 16)) & 0x00FF0000FF0000FF; + u64 = (u64 | (u64 << 8)) & 0xF00F00F00F00F00F; + u64 = (u64 | (u64 << 4)) & 0x30C30C30C30C30C3; + u64 = (u64 | (u64 << 2)) & 0x9249249249249249; + return u64; +} + +static INLINE uint32_t +morton3D_decode_u21(const uint64_t u64) +{ + uint64_t tmp = (u64 & 0x9249249249249249); + tmp = (tmp | (tmp >> 2)) & 0x30C30C30C30C30C3; + tmp = (tmp | (tmp >> 4)) & 0xF00F00F00F00F00F; + tmp = (tmp | (tmp >> 8)) & 0x00FF0000FF0000FF; + tmp = (tmp | (tmp >> 16)) & 0xFFFF00000000FFFF; + tmp = (tmp | (tmp >> 32)) & 0x00000000FFFFFFFF; + ASSERT(tmp <= ((1<<21)-1)); + return (uint32_t)tmp; +} + +static INLINE uint32_t +morton_xy_encode_u16(const uint16_t xy[2]) +{ + ASSERT(xy); + return (morton2D_encode_u16(xy[0]) << 1) + | (morton2D_encode_u16(xy[1]) << 0); +} + +static INLINE void +morton_xy_decode_u16(const uint32_t code, uint16_t xy[2]) +{ + ASSERT(xy); + xy[0] = (uint16_t)morton2D_decode_u16(code >> 1); + xy[1] = (uint16_t)morton2D_decode_u16(code >> 0); +} + +static INLINE uint64_t +morton_xyz_encode_u21(const uint32_t xyz[3]) +{ + ASSERT(xyz); + return (morton3D_encode_u21(xyz[0]) << 2) + | (morton3D_encode_u21(xyz[1]) << 1) + | (morton3D_encode_u21(xyz[2]) << 0); +} + +static INLINE void +morton_xyz_decode_u21(const uint64_t code, uint32_t xyz[3]) +{ + ASSERT(xyz && code < ((1ull << 63)-1)); + xyz[0] = (uint32_t)morton3D_decode_u21(code >> 2); + xyz[1] = (uint32_t)morton3D_decode_u21(code >> 1); + xyz[2] = (uint32_t)morton3D_decode_u21(code >> 0); +} + +#endif /* MORTON_H */ + diff --git a/src/mutex.h b/src/mutex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/pthread/pthread_condition.c b/src/pthread/pthread_condition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/pthread/pthread_mutex.c b/src/pthread/pthread_mutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/quaternion.c b/src/quaternion.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/quaternion.h b/src/quaternion.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/real2.h b/src/real2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/real22.h b/src/real22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/real3.h b/src/real3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/real33.h b/src/real33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/real44.h b/src/real44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realX.h b/src/realX.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realXY.h b/src/realXY.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realXY_begin.h b/src/realXY_begin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realXY_end.h b/src/realXY_end.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realX_begin.h b/src/realX_begin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/realX_end.h b/src/realX_end.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/ref_count.h b/src/ref_count.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/rsys.h b/src/rsys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -263,7 +263,7 @@ static INLINE DEPRECATED void macro_NCHECK(void) { (void)0; } for((Id) = (Start); (Id) > (End); --(Id)) /******************************************************************************* - * SIMD instruction sets + * Instruction sets ******************************************************************************/ #if defined(COMPILER_GCC) #ifdef __SSE__ @@ -287,6 +287,9 @@ static INLINE DEPRECATED void macro_NCHECK(void) { (void)0; } #ifdef __AVX__ #define SIMD_AVX #endif + #ifdef __FMA__ + #define FMADD + #endif #elif defined(COMPILER_CL) #ifdef ARCH_64BITS #define SIMD_SSE @@ -366,6 +369,13 @@ typedef int res_T; #endif #define BIT(Num) (1 << (Num)) +#define BIT_I16(Num) (int16_t)((int16_t)1 << (Num)) +#define BIT_I32(Num) (int32_t)((int32_t)1 << (Num)) +#define BIT_I64(Num) (int64_t)((int64_t)1 << (Num)) +#define BIT_U16(Num) (uint16_t)((uint16_t)1 << (Num)) +#define BIT_U32(Num) (uint32_t)((uint32_t)1 << (Num)) +#define BIT_U64(Num) (uint64_t)((uint64_t)1 << (Num)) + #define CONCAT__(A, B) A ## B #define CONCAT(A, B) CONCAT__(A, B) #define SPLIT2(A) (A)[0], (A)[1] diff --git a/src/signal.h b/src/signal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/str.c b/src/str.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/str.h b/src/str.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/stretchy_array.h b/src/stretchy_array.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_algorithm.c b/src/test_algorithm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_atomic.c b/src/test_atomic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_binary_heap.c b/src/test_binary_heap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_condition.c b/src/test_condition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_cstr.c b/src/test_cstr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -13,9 +13,13 @@ * You should have received a copy of the GNU Lesser General Public License * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 200112L /* strtok_r support */ + #include "cstr.h" #include "math.h" +#include <string.h> + static void test_double(void) { @@ -152,6 +156,75 @@ test_ulong(void) CHK(cstr_to_ulong(buf, &ul) == RES_BAD_ARG); } +static res_T +count_elements(const char* str, void* ptr) +{ + int* counter = ptr; + *counter += 1; + CHK(str && str[0] != '\0'); + return RES_OK; +} + +static res_T +parse_elmt(const char* str, void* ptr) +{ + char buf[32]; + char* key = NULL; + char* val = NULL; + char* tk_ctx = NULL; + int i; + (void)ptr; + + CHK(str && str[0] != '\0'); + CHK(strlen(str)+1/*Null char*/ < sizeof(buf)); + + strncpy(buf, str, sizeof(buf)); + key = strtok_r(buf, "=", &tk_ctx); + val = strtok_r(NULL, "=", &tk_ctx); + CHK(key); + CHK(val); + + if(!strcmp(key, "good")) { + CHK(cstr_to_int(val, &i) == RES_OK); + } else if(!strcmp(key, "bad")) { + CHK(cstr_to_int(val, &i) == RES_OK); + i = !i; + } else { + FATAL("Unreachable code.\n"); + } + return i ? RES_OK : RES_BAD_ARG; +} + +static void +test_list(void) +{ + int n = 0; + CHK(cstr_parse_list(NULL, ':', count_elements, &n) == RES_BAD_ARG); + CHK(cstr_parse_list("", ':', NULL, NULL) == RES_BAD_ARG); + CHK(cstr_parse_list("", ':', count_elements, &n) == RES_OK); + CHK(n == 0); + CHK(cstr_parse_list("Hello", ':', count_elements, &n) == RES_OK); + CHK(n == 1); + n = 0; + CHK(cstr_parse_list("Hello, world!", ':', count_elements, &n) == RES_OK); + CHK(n == 1); + n = 0; + CHK(cstr_parse_list("Hello, world!", ' ', count_elements, &n) == RES_OK); + CHK(n == 2); + n = 0; + CHK(cstr_parse_list("1;2;3;1e-7;abcdef;0x32;key=value", ';', count_elements, &n) == RES_OK); + CHK(n == 7); + + CHK(cstr_parse_list("good=1", ',', parse_elmt, NULL) == RES_OK); + CHK(cstr_parse_list("bad=0", ',', parse_elmt, NULL) == RES_OK); + CHK(cstr_parse_list("good=1,bad=0", ',', parse_elmt, NULL) == RES_OK); + CHK(cstr_parse_list("good=0,bad=0", ',', parse_elmt, NULL) == RES_BAD_ARG); + CHK(cstr_parse_list("good=1,bad=1", ',', parse_elmt, NULL) == RES_BAD_ARG); + CHK(cstr_parse_list("good=0,bad=1", ',', parse_elmt, NULL) == RES_BAD_ARG); + CHK(cstr_parse_list("bad=0,good=0", ',', parse_elmt, NULL) == RES_BAD_ARG); + CHK(cstr_parse_list("bad=0,good=1", ',', parse_elmt, NULL) == RES_OK); +} + static void test_list_double(void) { @@ -280,6 +353,7 @@ main(int argc, char** argv) test_int(); test_uint(); test_ulong(); + test_list(); test_list_double(); test_list_float(); test_list_uint(); diff --git a/src/test_double2.c b/src/test_double2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_double22.c b/src/test_double22.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_double3.c b/src/test_double3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_double33.c b/src/test_double33.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_double4.c b/src/test_double4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_double44.c b/src/test_double44.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_dynamic_array.c b/src/test_dynamic_array.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_endianness.c b/src/test_endianness.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float2.c b/src/test_float2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float22.c b/src/test_float22.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float3.c b/src/test_float3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float33.c b/src/test_float33.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float4.c b/src/test_float4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_float44.c b/src/test_float44.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_free_list.c b/src/test_free_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_func_name.c b/src/test_func_name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_hash_sha256.c b/src/test_hash_sha256.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -15,6 +15,7 @@ #include "endianness.h" #include "hash.h" +#include "math.h" #include "mem_allocator.h" #include <string.h> @@ -28,13 +29,19 @@ struct test_data { const char* sha256sum; }; +struct buf { + const char* mem; + size_t len; +}; + static void chk_hash(const void* data, const size_t data_len, const char* sha256sum) { hash256_T hash; char hash_str[65]; ASSERT(sha256sum); - CHK(hash_sha256(NULL, data, data_len, hash) == RES_OK); + + hash_sha256(data, data_len, hash); hash256_to_cstr(hash, hash_str); CHK(!strcmp(hash_str, sha256sum)); } @@ -53,7 +60,7 @@ main(int argc, char** argv) chk_hash(data, 0, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); - CHK(hash_sha256(&mem_default_allocator, data, 0, hash0) == RES_OK); + hash_sha256(data, 0, hash0); ((uint32_t*)hash1)[0] = big_endian_32(0xe3b0c442); ((uint32_t*)hash1)[1] = big_endian_32(0x98fc1c14); ((uint32_t*)hash1)[2] = big_endian_32(0x9afbf4c8); diff --git a/src/test_hash_table.c b/src/test_hash_table.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_image.c b/src/test_image.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_library.c b/src/test_library.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_list.c b/src/test_list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_logger.c b/src/test_logger.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_math.c b/src/test_math.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_mem_allocator.c b/src/test_mem_allocator.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_misc.c b/src/test_misc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_morton.c b/src/test_morton.c @@ -0,0 +1,148 @@ +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) + * + * The RSys library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The RSys library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ + +#include "math.h" +#include "morton.h" + +#include <stdlib.h> + +static INLINE uint16_t +rand_u16() +{ + return (uint16_t)(rand() & (BIT(16)-1)); +} + +static INLINE uint32_t +rand_u21() +{ + return (uint32_t)(rand() & (BIT(21)-1)); +} + +static INLINE uint64_t +encode_u21(uint32_t u21) +{ + uint64_t mcode = 0; + uint64_t i; + for(i = (uint64_t)round_up_pow2(u21); i != 0; i >>= 1) { + if(i <= (uint64_t)u21) { + mcode |= morton3D_encode_u21((uint32_t)i); + u21 -= (uint32_t)i; + } + } + return mcode; +} + +static INLINE uint32_t +encode_u16(uint32_t u16) +{ + uint32_t mcode = 0; + uint32_t i; + for(i = (uint32_t)round_up_pow2(u16); i != 0; i >>= 1) { + if(i <= (uint32_t)u16) { + mcode |= morton2D_encode_u16((uint16_t)i); + u16 -= (uint16_t)i; + } + } + return mcode; +} + +static void +test_morton2D(void) +{ + int bit = 0; + int i = 0; + + FOR_EACH(bit, 0, 16) { + CHK(morton2D_encode_u16(BIT_U16(bit)) == BIT_U32(2*bit)); + CHK(morton2D_decode_u16(BIT_U32(2*bit)) == BIT_U16(bit)); + } + + FOR_EACH(i, 0, 10000) { + const uint16_t u16 = rand_u16(); + const uint32_t u32 = morton2D_encode_u16(u16); + CHK(u32 == encode_u16(u16)); + CHK(u16 == morton2D_decode_u16(u32)); + } + + FOR_EACH(i, 0, 10000) { + uint16_t xy[2]; + uint16_t xy2[2]; + uint32_t xy_mcode[2]; + uint32_t mcode; + + xy[0] = rand_u16(); + xy[1] = rand_u16(); + mcode = morton_xy_encode_u16(xy); + + xy_mcode[0] = morton2D_encode_u16(xy[0]); + xy_mcode[1] = morton2D_encode_u16(xy[1]); + CHK(mcode == ((xy_mcode[0]<<1) | (xy_mcode[1]<<0))); + + morton_xy_decode_u16(mcode, xy2); + CHK(xy[0] == xy2[0]); + CHK(xy[1] == xy2[1]); + } + +} + +static void +test_morton3D(void) +{ + int bit = 0; + int i = 0; + + FOR_EACH(bit, 0, 21) { + CHK(morton3D_encode_u21(BIT_U32(bit)) == BIT_U64(3*bit)); + CHK(morton3D_decode_u21(BIT_U64(3*bit)) == BIT_U32(bit)); + } + + FOR_EACH(i, 0, 10000) { + const uint32_t u21 = rand_u21(); + const uint64_t u64 = morton3D_encode_u21(u21); + CHK(u64 == encode_u21(u21)); + CHK(u21 == morton3D_decode_u21(u64)); + } + + FOR_EACH(i, 0, 10000) { + uint32_t xyz[3]; + uint32_t xyz2[3]; + uint64_t xyz_mcode[3]; + uint64_t mcode; + + xyz[0] = rand_u21(); + xyz[1] = rand_u21(); + xyz[2] = rand_u21(); + mcode = morton_xyz_encode_u21(xyz); + + xyz_mcode[0] = morton3D_encode_u21(xyz[0]); + xyz_mcode[1] = morton3D_encode_u21(xyz[1]); + xyz_mcode[2] = morton3D_encode_u21(xyz[2]); + CHK(mcode == ((xyz_mcode[0]<<2) | (xyz_mcode[1]<<1) | (xyz_mcode[2]<<0))); + + morton_xyz_decode_u21(mcode, xyz2); + CHK(xyz[0] == xyz2[0]); + CHK(xyz[1] == xyz2[1]); + CHK(xyz[2] == xyz2[2]); + } +} + +int +main(int argc, char** argv) +{ + (void)argc, (void)argv; + test_morton2D(); + test_morton3D(); + return 0; +} diff --git a/src/test_mutex.c b/src/test_mutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_quaternion.c b/src/test_quaternion.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real2.h b/src/test_real2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real22.h b/src/test_real22.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real3.h b/src/test_real3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real33.h b/src/test_real33.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real4.h b/src/test_real4.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_real44.h b/src/test_real44.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_ref.c b/src/test_ref.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_signal.c b/src/test_signal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_str.c b/src/test_str.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_text_reader.c b/src/test_text_reader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/test_time.c b/src/test_time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -15,6 +15,7 @@ #include "clock_time.h" #include <stdlib.h> +#include <string.h> int main(int argc, char** argv) @@ -24,6 +25,7 @@ main(int argc, char** argv) char buf[32]; int64_t time = 0; int64_t i = 0; + size_t dump_len; (void)argc, (void)argv; CHK(time_current(&start) == &start); @@ -38,7 +40,8 @@ main(int argc, char** argv) CHK(time_val(&res, TIME_SEC) == time / 1000000000); time_dump - (&res, TIME_SEC|TIME_MSEC|TIME_USEC, NULL, dump, sizeof(dump)); + (&res, TIME_SEC|TIME_MSEC|TIME_USEC, &dump_len, dump, sizeof(dump)); + CHK(dump_len == strlen(dump)); printf(">>> %s.\n", dump); time_dump(&res, TIME_ALL, NULL, dump, sizeof(dump)); printf(">>> %s.\n", dump); @@ -67,8 +70,13 @@ main(int argc, char** argv) res.sec = 5; res.nsec = 524198207; - time_dump(&res, TIME_ALL, NULL, buf, sizeof(buf)); + time_dump(&res, TIME_ALL, &dump_len, buf, sizeof(buf)); + CHK(dump_len >= strlen(buf)); printf(">>> %s.\n", buf); + time_dump(&res, TIME_ALL, &dump_len, dump, sizeof(dump)); + CHK(dump_len >= strlen(dump)); + printf(">>> %s.\n", dump); + return 0; } diff --git a/src/test_vmacros.c b/src/test_vmacros.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/text_reader.c b/src/text_reader.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/text_reader.h b/src/text_reader.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/win32/win32_condition.c b/src/win32/win32_condition.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published diff --git a/src/win32/win32_mutex.c b/src/win32/win32_mutex.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2020 Vincent Forest (vaplv@free.fr) +/* Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) * * The RSys library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published