From 204f544869f89eb19c2a645d6740888862a97ef6 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 29 May 2023 11:15:36 -0400 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 2083425b027404ef97fe95be426fad1e059adcc4 Author: Dan Smith Date: Mon May 29 11:14:26 2023 -0400 latest from coda-oss commit 977324f93b82d22282605029e93437c12d524596 Merge: 6fad67b8f 9fbf2b7b8 Author: Dan Smith Date: Mon May 29 11:13:16 2023 -0400 Merge branch 'main' into develop/sync_externals commit 9fbf2b7b8390d3717ea09f98908682c4c8790bc1 Author: JosephBlegen1 <124076042+JosephBlegen1@users.noreply.github.com> Date: Mon May 29 09:25:47 2023 -0400 Fill out adapter free block which is used for nitf decompression (#549) * Add missing function used in VLCC * Remove unneeded cast --------- Co-authored-by: Joseph Blegen commit 6fad67b8ffcf0bcc1961b73e3a2dc7e042aaca93 Author: Dan Smith Date: Wed May 17 09:26:01 2023 -0400 latest from coda-oss commit 9ce84ff3a76e27aebffc17c737027825d0fe6000 Merge: ec465ea55 089ba0b5b Author: Dan Smith Date: Wed May 17 09:25:26 2023 -0400 Merge branch 'main' into develop/sync_externals commit ec465ea55847db2e1ca58a5f0802c0557adc23f5 Merge: af44d7666 3b52f0025 Author: Dan Smith Date: Mon May 15 15:37:16 2023 -0400 Merge branch 'main' into develop/sync_externals commit af44d7666ba60075d78a5df01e689e072aca9d8c Merge: 7f8a4558a fbab2e55e Author: Dan Smith Date: Mon May 15 15:35:24 2023 -0400 Merge commit 'fbab2e55ee4bef4cf0dc81164d10a0cceef713b5' into develop/sync_externals commit fbab2e55ee4bef4cf0dc81164d10a0cceef713b5 Author: Dan Smith Date: Mon May 15 15:35:24 2023 -0400 Squashed 'externals/coda-oss/' changes from c120e3255d..d156370d36 d156370d36 swapping a single-byte value makes no sense git-subtree-dir: externals/coda-oss git-subtree-split: d156370d36087f633f5f5148c3582bc14e6ce5a3 commit 7f8a4558a775a88f448318567273b2d5a79b3a6b Author: Dan Smith Date: Mon May 15 15:23:41 2023 -0400 latest from coda-oss commit 17db6b29da6915908fa85d5a872245db66cb3bca Author: Dan Smith Date: Mon May 15 14:12:44 2023 -0400 Squashed 'externals/coda-oss/' changes from f6489b6bef..c120e3255d c120e3255d be sure parameter is used to avoid compiler warning e85ec93317 --output-on-failure for CTest (#666) e80376197b turn off "there is no warning number" warning c5f0a5d154 A C-string may not be NULL-terminated (#665) 0c5eb29ae7 use platform-specific routines for byteSwap() (#664) 0b7d581fa6 remove transform_async() (#663) git-subtree-dir: externals/coda-oss git-subtree-split: c120e3255d38337020b65b193509abef14c1429c commit 090e65ed38552567a042d8e5fa3300fd04bc1648 Merge: 8b5096d69 17db6b29d Author: Dan Smith Date: Mon May 15 14:12:44 2023 -0400 Merge commit '17db6b29da6915908fa85d5a872245db66cb3bca' into develop/sync_externals commit 8b5096d697db7e0dd2b715292faa96e4c20c6881 Author: Dan Smith Date: Mon May 15 13:56:34 2023 -0400 latest from coda-oss commit a1c7a47e94c1cdd4a80b4a173225d46aae25bb15 Author: Dan Smith Date: Mon May 15 13:42:59 2023 -0400 latest from coda-oss commit 3e932d65137a46f88fe95e3ad2f51938d31fc27b Author: Dan Smith Date: Mon May 15 13:34:39 2023 -0400 update from coda-oss enabled more compiler warnings commit e5a06704580def3f286942dedbed207e35218002 Author: Dan Smith Date: Mon May 15 13:09:30 2023 -0400 latest from coda-oss commit 07084ab35b5433b8500333ead3e3e20a7a324905 Merge: afdbfb7c9 90c6263e2 Author: Dan Smith Date: Mon May 15 13:09:10 2023 -0400 Merge branch 'main' into develop/sync_externals commit 7c57010b4b7fa82a72c7b4bf6594634ef5c97d9d Author: Dan Smith Date: Tue Apr 18 17:05:57 2023 -0400 Squashed 'externals/coda-oss/' changes from 857ff0af32..f6489b6bef f6489b6bef Merge branch 'main' into feature/xml.lite_tweaks 836c426a2b use function-pointers so that isConsoleOutput is only checked once 56e3c45b1b move depthPrint() functionality into non-member function in preparation for future changes ddcd26d972 Merge branch 'main' into feature/xml.lite_tweaks 69cc0e5063 use the more rigorous create_and_check_datatype() 9efb875584 Merge branch 'main' into feature/hdf5 4d2f2f4173 more HighFive unittests (#662) 14191a844a HighFive::create_datatype() goes from C++ to HighFive 98583473fb utility routines to read string attributes 1fa75ce81e use the C API to read a string attribute 71e7b69f54 still can't figure out how to read a string attribute :-( e96f37a69b test reading the file attributes a25244519c getAttribute() unittest 8f12a3000b getDataType() unittest 1d687db57b writeDataSet() utility overload 106aa68945 sigh ... H5Easy::dump() fill fails on Windows/WAF :-( 2641b60b2b Merge branch 'main' into feature/hdf5 212bbd3a36 works on local machine, but not build server ... ? 7125118b09 dump of 1D vector doesn't work :-( c704db4352 sigh ... WAF build still failing :-( 01aae46163 does dump() of a 1D vector work? 76a53c8134 comment-out H5 writing :-( 0f0e19affe test_highfive_dump() cb8f737957 trying to get highfive_dump() unittest working w/Windows-WAF 6584a264af does test_highfive_create() work? 3165668545 Revert "trying HighFive "write" unittests again" a9ec24ca4d trying HighFive "write" unittests again 585ad49a56 tweak names of utility routines 4c91a4d97a make it easier to read a std::vector and std::vecotr 0217ffa26c readDataSet() now works for 1D data 95e8973f29 trying to get hdf5::lite::load() working 4d294611d4 "const" correctness 5e6305c3f7 fix load_complex() 4a134dc5f1 start work on utility routines to read complex data from HDF5 9d76a7f41e Merge branch 'main' into feature/hdf5 8f9667a240 whitepsace ebd3fc99ea Merge branch 'main' into feature/hdf5 40091b069c comment-out writing tests for now ... need to figure our WAF bulid failure 935aa34592 be sure the dataset has real data 114b9bf33c update release notes bd9c0b26c5 tweak HighFive utility routines acda1ef577 turn off diagnostics around expected failures 22a7488402 readDataSet() utility routine for HighFive bd88a8c256 HighFive writeDataSet() utility to work with our SpanRC 6142f5b339 use HighFive routines to write a HDF5 file 5bbf1abaff Use HiveFive routines to get info about the file 84fbc83789 duplicate unittests with H5Easy f1f054c03a Merge branch 'main' into feature/hdf5 9b63ca470c fix directory names f6f826689a fix directory names 7aeb82c336 Merge branch 'main' into feature/hdf5 d028baaebd hook up HighFive header-only library (#653) 3083b0a313 Revert "HighFive 2.6.2" 246985a7f0 Revert ""build" HighFive HDF5 library" a8b75a5865 Revert "turn off HighFive Boost support" ec68d5f830 Revert "Add HighFive unittests" f1f85b9e7f Revert "get test_high_five_base more-or-less compiling" 5ea634ee15 Revert "more work on getting HighFive unittests to build" ecc45433c7 more work on getting HighFive unittests to build bb194788ab get test_high_five_base more-or-less compiling d42bde0004 Add HighFive unittests ddc86bb328 turn off HighFive Boost support b255122d4f "build" HighFive HDF5 library 396cc3ef2a HighFive 2.6.2 5e5f9d9c0f Merge branch 'main' into feature/hdf5 ee938b4a52 changes from SIX bb764df90b Merge branch 'main' into feature/xml.lite_tweaks de2a243800 make derived classes 'final' if possible 14e19bcd21 Change xml lite function to virtual (#645) 8f42ac8e9e Merge branch 'main' into feature/xml.lite_tweaks 18ad90645f hdf5Write unittest 3462e11792 createFile() and writeFile() overloads ecee81d532 fix typos 197eecfa62 sketch-out hdf5::lite::writeFile() bd2311795e use SpanRC for writeFile(), not yet implemented ea9af75109 simple SpanRC to hold a 2D-size and pointer 027c19ee8a createFile() unittest 1f9d07ecbc hook up createFile() 8c7e4473f0 start hooking up HDF5 writing 146e0bea3b Merge branch 'main' into feature/hdf5 88ca9fcb7f Merge branch 'main' into feature/hdf5 42b604b463 Squashed commit of the following: 10ee602c25 Merge branch 'main' into feature/hdf5 67aa42b69d restore changes from "main" 8bbfcbfbfe unittests can be simplified to match fewer "view" classes 126bb802ea Merge branch 'main' into feature/hdf5 3f8ba7a423 again, don't need a class just to convert from std::vector<> to std::span<> 24c2b489c8 Squashed commit of the following: 2703c119d4 Squashed commit of the following: 9d5228a2be don't need an entire class just to convert a std::vector<> into std::span<> 51bc931dcd Merge branch 'main' into feature/hdf5 a84f258160 Squashed commit of the following: c4d2ed696e add missing #include guards, fix type in existing #include guard d541525a01 use a single ComplexViewConstIterator for all views 86e6a459fe CODA_OSS_disable_warning causes GCC errors :-( 5d4b9c2cb6 only need an custom iterator for ComplexSpansView d9f0fb1286 hook up iterators b9329e4db0 initial pass at a ComplexViewConstIterator 6352388739 remove compiler warning about unused "constexpr" variables b39f6096fb use the casing from H5 to make copy/pasting code slightly easier 0887b13eb4 Merge branch 'main' into feature/hdf5 bd07df1cae Consistent casing for Dataset, Datatype, Dataspace 7acd30ee23 tweak hdf5.lite dependencies 38ab914dfd Jupyter notebook for creating H5 files 95a040e0bf _small.h5 is now (correctly) FLOAT32 107e7c4876 make a simple values() member function to avoid template magic e1feca9194 use TEST_SPECIFIC_EXCEPTION macro instead of try/catch 7383336888 readDatasetT() now throws for the wrong buffer type 6b2cc25294 Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 310f8fd3d5 can't get template magic right for copy_axis() 86b306d596 stepping through copy ctors in the debugger is annoying f243e92d68 trying to make wrong type of buffer fail 2b10d96529 read in new sample file a28e59d8c5 help the compiler with type deduction 49bf5e9bc2 nested_complex_float_data_small.h5 e029325fc0 utility routines to "deconstruct" and array of std::complex dede3bd393 Merge branch 'main' into feature/hdf5 904b1ef5ec tweak class names, make_() and copy() utility routines 8237b9efbf make it harder to pass the wrong types to ComplexViews 4d9aeda2cd ComplexArrayView and ComplexParallelView utility classes f5e367dfa6 test std::span> a4a2844f26 read in the nested "i" and "r" data 1156152650 sample file has subgroups 8e1b7869aa Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 9f4232a1dd update sample H5 file 8c55db73ae walk through HDF5 sub-groups 7775ed9c43 Update 123_barfoo_catdog_cx.h5 677975d7ca Matlab code to create sample H5 file a0e7dfe07b Update test_hdf5info.cpp 0b67e1602f pass __FILE__ and __LINE__ from calling site for a more accurate exception message 86a6773213 skeleton for more sample data 85f79b0999 Merge branch 'main' into feature/hdf5 18088e9421 Merge branch 'main' into feature/hdf5 3a1d17692f Merge branch 'main' into feature/hdf5 1755c69d70 Merge branch 'main' into feature/hdf5 9ad015432d No more "11" suffix on exception names c20d962511 Squashed commit of the following: c88cee999b other values to be filled-in bca4a4ecd8 incorporation NamedObject from HDF5 docs 61fa68f72e groupInfo() 460e7d7665 datasetInfo() 14eb9b764b start filling in DatasetInfo afe5f1c3a0 start to fill in DatasetInfo 77a968c72d start filling in GroupInfo d81bcdfd92 openGroup() to open groups (loc) a0cd294697 comment-out "dataset" unittest for now 86e0060245 begin filling in FileInfo 366dda6ab6 a return_type_of utility is needed to deduce the return type e219282638 explicitly pass return type to template 4937ccd11d template to reduce boilerplate when calling try_catch_H5Exceptions b3b5ebde78 use new exception utility routines ea1c03ef0c put exception handling/conversion in a utility routine 819a99d397 utility routine for exception handling 6f34eea979 put utilities in a separate file for easier reuse fcbde4f241 break utility routines into smaller pieces for easier reuse 52358ea8a9 WIN32 no longer automatically defined? 5a42864722 Revert "build HDF5 with C89" 680e599e9d build HDF5 with C89 a87a071218 Merge branch 'main' into feature/hdf5 8447c1a900 Revert "sym-links instead of copying files" db3b5e12b4 Merge branch 'main' into feature/xml.lite_tweaks fb60b5696f Merge branch 'main' into feature/hdf5 5110a5cc81 Comments about _u and _q 1a937d32cf Merge branch 'main' into feature/xml.lite_tweaks fa06f04d7e get ready for hdf5.lite enhancdements b040c7c437 sym-links instead of copying files aa431bb477 use _u for xml::lite::Uri 3d0c6d58ce fix case-sensitive #include filename 93dcd0e527 operator() for getElementByName() 75a93af859 more operator[] overloads to make attribute management easier 4ab8216f87 user-defined string literals to remove some noise around xml::lite::QName f82f0b0fc6 Merge branch 'main' into feature/xml.lite_tweaks ae30e36443 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks ffdd9beb0b simplify attribute creation 9bf5414f5d simplify attribute creation 82d7a4e959 SWIG gets confused about namespaces 7a61d0741f fix bug on Element ctor uncovered by unittest fdd7e58c1a QName is also in the xerces namespace which confuses SWIG bindings a325b7053b operator+=() overload for addChild daf30e6c0e Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks b887d2b476 provide overloads for Element& rather than creating new "reference" types 1fa6bba388 rename test_xmleasy.cpp 7c8c9e0f1c += overload 850da6f63d overload for std::string 4547fc5a75 use UIT-8 strings for characterData 4723462a3b convenient addChild() overloads e48720753a copy over ElementReference from xml.easy a4ca30a0d6 Merge branch 'main' into feature/xml.lite_tweaks 6ae9f0b715 Revert "check-in of new xml.easy (to move code between computers)" f7466a6d75 Revert "simple routines for single element" a5490230d6 Revert "make some operators simplier ways of calling functions" c9a25630a6 Revert "get document creation working" 8af8710b05 Revert "free functions instead of member functions" 16c3847cb2 Revert "ElementReference distinct from Element" 7d68e156ff Revert "ElementMutableReference" 00eb2a2826 Merge branch 'main' into feature/xml.lite_tweaks a42969c1f4 ElementMutableReference a20ae9355e ElementReference distinct from Element 14eeeea0b5 free functions instead of member functions 4aae014b39 get document creation working 8835692699 make some operators simplier ways of calling functions 053bd1212a simple routines for single element 8bf701a2ea check-in of new xml.easy (to move code between computers) 41f959051c unittests for creating XML documents from scratch 9752d50ae2 Merge branch 'main' into feature/xml.lite_tweaks 1531d57095 by default, don't validate strings passed to Uri() 46d13d4bf7 Merge branch 'master' into feature/xml.lite_tweaks 39b547d321 remove more vestiges of Expat and LibXML ec8274d524 remove LibXML and Expat as they're no longer used/supported. 20eeefeef6 Merge branch 'master' into feature/xml.lite_tweaks 95074b9b1a update for newer Intel compiler 7024f71e1b Merge branch 'master' into feature/xml.lite_tweaks 57b1cbc83d Merge branch 'master' into feature/xml.lite_tweaks 4b67561c3d remove validate() overload that nobody is using fa15f1e5dc Squashed commit of the following: 1484a90909 test the new validate() API 470da70fb8 hookup StringStreamT routines 2cddf25047 begin hooking up validate() overloads 1b5d910f38 overload validate() for UTF-8 and Windows-1252 03309b8c9f Squashed commit of the following: b72c6c5bf2 older compiler doesn't like our make_unique af8f00307f validate UTF-8 XML on Linux 211188613e unit-test for LEGACY XML validation 3c1169d2b5 Squashed commit of the following: 3afff19cad std::filesystem::path for FileInputStreamOS 908d452f8f WIP: validate all of our sample XML files 00f9bb16bc validate against a XML schema 243d8c356c Merge branch 'master' into feature/xml.lite_tweaks 2815d707d9 fix to work with SWIG bindings. :-( 4608621326 trying (again) to remove vestiages of old code e3c83a8587 Revert "new code should use UTF-8" 811207c920 new code should use UTF-8 0ffd835f96 Squashed commit of the following: 1e7e03ded0 Merge branch 'master' into feature/xml.lite_tweaks c1d806affa Merge branch 'master' into feature/xml.lite_tweaks 850d3c811d str::strip() that can be easier to use than str::trim() 580ba9c8c3 explicitly =delete move 2b39831a80 Squashed commit of the following: 39eebdc23f Merge branch 'master' into feature/xml.lite_tweaks 9adf86cbaf force calling new UTF-8 write() routines ea61b62045 Merge branch 'master' into feature/xml.lite_tweaks 8a34583fa0 overload to take schemaPaths as filesystem::path 8671b442f7 parse XML embedded in a binary file ec4a902f14 updates from xerces.lite 80dc4d9635 updates from xerces.lite 549766d6c1 Attributes::contains() no longer catches an exception 8a645ceac3 need "sys/" when building in other environments 36af082690 super-simple URI validation 78ef28a3e2 SWIG bindings are a PITA! :-( e9cba8491e SWIG needs help with Uri 8a8d8dc072 another routines used by pre-build SWIG bindings 818e1ec5d3 pre-build SWIG bindings use getElementByTagName() member function 067cac5d85 old compiler gets confused on unadorned QName ba92c0ae7e more use of Uri and QName 446c7d17a7 use QName in new code d6f8b0c836 more direct use of QName 90fff1c737 use xml::lite::QName instead of tuple 646cbb5ed4 more direct use of QName and Uri ba589ea3b3 make QName more robust bab0ee8b5e createElement() -> addNewElement() e3a145747a grab changes from six-library 32285e95c4 Merge branch 'master' into feature/xml.lite_tweaks 9f79f0bf62 Merge branch 'master' into feature/xml.lite_tweaks a12bbc32c6 make it easier to create new Elements with a value fc9967f986 make it easy for callers to addChild() keep a reference to the Element 4627766b7d be sure test_xmlparser works in "externals" of other projects bf22763961 "private" is part of the name-mangling fad92bcc8f making sure copy-ctor is implemented f90fdcead0 consolidate common XML test code 9fc53f2d51 use str:: utility for casting 6da6f794bb still trying to find the right macro for SWIG 0c1b86c566 still trying to fix SWIG fdc6fc9bd6 trying to fix SWIG build error 7835e8c270 SWIG needs copy-ctor 585695942d disable copy/assignment for Element, it's probably almost always wrong 391fed6135 fix double-delete caused by copying 61790fe695 retry parsing XML with Windows-1252 if first parse() fails 63cffac59e change string_encoding to match coda-oss style of PascalCase 010479bbec read an XML file we know is wrongly encoded as Windows-1252 9a05050621 more references instead of pointers 2d44b69519 Reading Windows-1252 w/o "encoding" fails 63dc7b0762 read Windows-1252 too c9434c9cbe test as UIT-8 too f310ccf0cf get reading from UTF-8 XML working on Windows 1fa39c2be0 get testReadUtf8XmlFile working on Linux 1a83cd8157 sys::Path is too much trouble right now ed60aa22c9 unit-test to read XML from a file a9336db7c6 Squashed commit of the following: 0825beb0d3 Merge branch 'master' into feature/xml.lite_tweaks c618489be7 Merge branch 'master' into feature/xml.lite_tweaks e8e4b8fe1d determine string_encoding based on platform 1f43bcfc26 create a new Element by using the platform to determine "characterData" encoding 961bef66b4 Merge branch 'master' into feature/xml.lite_tweaks e9798a5cba fix static_assert() 6f77728748 Merge branch 'master' into feature/xml.lite_tweaks b98d4f5a91 Merge branch 'master' into feature/xml.lite_tweaks 1b5abba2a6 The (old) version of SWIG we're using doesn't like certain C++11 features. 53bdeabaf7 Merge branch 'master' into feature/xml.lite_tweaks 60cf8ae80f "" doesn't work with decltype() in older C++ 97e72477a5 reduce getValue() overloads by making "key" a template argument 5e6373e557 reduce code duplication f9e7cfeee5 provide castValue instead of getValue(T&) cbd0bd8f24 castValue throws instead of returning a bool like getValue(T&) 87c7514fce Merge branch 'master' into feature/xml.lite_tweaks 10cc61223a make getElement*() consistent for zero or >1 results f5b137e3cd Merge branch 'master' into feature/xml.lite_tweaks 1765efc622 allow clients to specify toType() and toString() for getValue() and setValue() df8b746e12 allow clients to specify their own toType/toString routines 66702726ad Merge branch 'master' into feature/xml.lite_tweaks 6956311f14 Merge branch 'master' into feature/xml.lite_tweaks d505f3593a Merge branch 'master' into feature/xml.lite_tweaks fbd106115f catch a BadCastException and return false from getValue() 3a78377b55 use a template to reduce duplicated code 0ad4b86062 Merge branch 'master' into feature/xml.lite_tweaks a848aa3a20 get & set the characer data as a type f3ee1ee12a utility routines to set an attribute value 5952276839 templates to get an attribute value convert to a specific type 06639227b3 miised a change in last commit 1aa458ef8b add getValue() overloads that return true/false rather than throwing faa6d30752 added getElementByTagName() overloads as that's a very common use-case git-subtree-dir: externals/coda-oss git-subtree-split: f6489b6bef104d78dacf427901c6a5415a00baec commit afdbfb7c9a6300a9e9ba2a282a04e7975919352a Merge: 6c73d1ed5 7c57010b4 Author: Dan Smith Date: Tue Apr 18 17:05:57 2023 -0400 Merge commit '7c57010b4b7fa82a72c7b4bf6594634ef5c97d9d' into develop/sync_externals commit 6c73d1ed5321c1bbd7f3ebeb917492da5312b75a Author: Dan Smith Date: Tue Apr 18 17:05:49 2023 -0400 latest from coda-oss commit c185cac62f00ba596a6de671ada1036a32e46e08 Merge: d8b20d40a 90d513ac5 Author: Dan Smith Date: Tue Apr 18 17:05:06 2023 -0400 Merge branch 'main' into develop/sync_externals commit a602cdddedba762a26def51fa3507b7c83475441 Author: Dan Smith Date: Mon Mar 20 14:31:20 2023 -0400 Squashed 'externals/coda-oss/' changes from e87c32b4de..857ff0af32 857ff0af32 HighFive utility routines (#661) 35c19e7e81 change actions to @v3 (#660) cde6147ced tweak HighFive wrappers (#659) git-subtree-dir: externals/coda-oss git-subtree-split: 857ff0af32ebe20a6f1d7059f1f12edf904a2ec0 commit d8b20d40a28fb67ca6dc39225ed27c466e7004e6 Merge: 86b0208fc a602cddde Author: Dan Smith Date: Mon Mar 20 14:31:20 2023 -0400 Merge commit 'a602cdddedba762a26def51fa3507b7c83475441' into develop/sync_externals commit 86b0208fcee16ac231f1a58b8ed2140444c7e9d7 Author: Dan Smith Date: Mon Mar 20 14:31:16 2023 -0400 copy_externals commit 1d94739918e0cc10207ad9c68b068c17e26cde07 Merge: 5cde06021 c8ecbe9ae Author: Dan Smith Date: Mon Mar 20 14:30:55 2023 -0400 Merge branch 'main' into develop/sync_externals commit 5cde06021f98850dea855f64b5f2b7286b0863a1 Merge: c34a8a817 fa991cfdc Author: Dan Smith Date: Mon Mar 13 12:54:16 2023 -0400 Merge commit 'fa991cfdcbcfe692891106f537f51202566d7772' into develop/sync_externals commit fa991cfdcbcfe692891106f537f51202566d7772 Author: Dan Smith Date: Mon Mar 13 12:54:16 2023 -0400 Squashed 'externals/coda-oss/' changes from cbfb20ce2e..e87c32b4de e87c32b4de Merge branch 'master' 605d248984 duplicate existing HDF5 unittests using HighFive (#657) 1342332795 add 'override'; fix ASAN-detected memory leaks (#656) 4c68fa0d34 fix directory names 5ee2f039a9 poor-man's version of "import module std;" (#655) fad02842cd Add HighFive library (#654) b31f5b6ab3 have Python 3.6 on a build server ba8547621a don't put 'struct' in the macro bd79aa11f2 require Python 3.7, do MD5 check ecfa687c55 use std::filesystem (instead of sys::filesystem) where possible (#652) 243bc99912 add 'override' c0fd2124dc wrap common "file open" routines to support sys::expandEnviromentVariables() (#651) 0657f3297a adjust compiler flags for clean CMake builds (#650) 81285872ff build cleanly with all G++ warnings enabled (#649) b9ea37bbf3 xml::lite::Validator can be moved (#648) 9cfe9a4a8b Merge branch 'master' e989b09101 createElement() needs to be virtual (#646) d17b57a545 Merge branch 'master' fa00a54309 move debug -g flags to be turned on only if debugging (#644) 44ab728544 routines for simple writing to HDF5 files (#643) aabc5818e6 remove more C++11 work-arounds (#642) b04ccca174 remove more C++11 work-arounds (#641) e460970a7c increase GCC warnings (#640) 91284249b5 provide ComplexView iterator support (#639) 453b7ec68b try to get std::make_unique working with old Intel compiler (#638) 5736cfd4db is_trivially_copyable for old Intel compiler (#637) 7c2aea38f7 use H5 SDK naming conventions (#636) fc3008b8d4 use 'modern' C pre-processor b44709a950 added ComplexSpansView utility (#635) 986307c9c0 Merge branch 'master' 3fd5ddae52 Merge branch 'main' into develop/remove-cpp11-workarounds 37d7ec76ef restore C++14 workarounds for older compilers (#632) 244dfdb3d3 Merge branch 'develop/main' into develop/remove-cpp11-workarounds 714ca4ed77 restore C++14 workarounds for older compilers 640f2247c2 Delete hdf5-hdf5-1_13_2.tar.gz eb365cbfba Merge branch 'master' into develop/remove-cpp11-workarounds 57b938eeb4 don't need __INTEL_COMPILER work-around with C++14 65779f3b1a build C code with -std=gnu99 94dc9280fa C++14 work-arounds for an old version of the Intel compiler 3744d05e2f slam-in "main" 82b2fd63b6 restore some C++14 work-arounds for old compilers that only have partial C++14 support 94f6950a27 Merge branch 'main' into develop/remove-cpp11-workarounds 1582c6ac9e further progress on implementing hdf5::lite (#631) 0622af1fe9 rename "11" exception classes to "Ex" (#630) 1384b8a5e2 Merge pull request #629 from mdaus/zlib-update ebbd57247c ZIP APIs use std::string in this branch 9cc19fe822 ZIP unittests b8d25d3642 Update zlib to 1.2.13 c53304a907 using std::auto_ptr can cause 'deprecated' warnings 418130d4d1 trying to fix build error on github 59d2f678e3 Release 2022-12-14 (#628) 1e82442914 new --with-optz=fastest-possible option (#627) 6ae81142d9 new --optz=faster option for WAF builds (#626) 11206c1798 sym-links don't work on Windows filesystems edd3e8fb9c overloads to make simplify routine XML processing (#625) dfece6106c use sym-links rather than copying files (#624) 22f1f07767 build hdf5.lite with WAF (#623) 5665970439 Conan versioning, hdf5, and pcre2 fixes (#622) 61aa5e4303 Squashed commit of the following: 6557ee34cd Yet another attempt at finding test files for unittests (#621) 501add035a -march=native for fastest optimization level (#620) f1dd0a5b4f overloads to make creating XML documents easier (#619) ab45464820 remove C++17 workarounds (#618) 3d5daf702e unittests for creating XML from scratch (#617) 8241dfe7e6 remove last vestiges of std::auto_ptr (#616) d06dc6534d mem::AutoPtr for C++17 (#615) 83443602a6 mem::AutoPtr class to aid C++17 transition (#614) f10fa2009c Release 2022-11-04 (#613) 8ab9828204 Squashed commit of the following: 31781a14a0 remove C++17 work-arounds c15f6930cf Revert " is in C++17" 0fe38c16f3 restore recent buld.py changes 0c75411ee0 is in C++17 bbbcd562ac remove C++11 work-arounds c1e15e9d9a Merge branch 'main' into main-cpp17 a32e697044 remove exception specifications (#609) bea818fb03 must use C++17 in this branch 91653a0963 another place where C++17 is set 7d555f2be6 back to C++17 b1969d9962 merge main 084f19126a utilities to find files/directories for unittests (#608) a3cedada96 Merge branch 'master' af7229bd83 utilities to find files from a build (#605) 264ae49dd7 be sure downstream projects build w/C++14 (#604) 0792c77bf0 Merge branch 'main' into develop/remove-cpp11-workarounds 7a7b13cbd5 "hello world" for HDF5 (#602) 33cff0ff43 more C++14 7b5e71a006 add HDF5 source code (#603) ec26f703e7 build in NITRO and SIX (#601) f4361a9730 make it easier to write cli unit-tests (#600) 34b6fdeee1 tweak toString() to reduce specialization (#599) e49f273c15 Merge branch 'main' into develop/remove-cpp11-workarounds 240b610448 allow sys::Mutex references, instead of pointers, to be passed to sys::ConditionVar 5907b3ed60 remove C++11 workarounds (#598) 9500d6f4bd Merge branch 'main' into develop/remove-cpp11-workarounds f1529942f4 std::make_unique instead of new be9b6a71ca Squashed commit of the following: 62a2ec4e13 Revert "remove our GSL work-around for C++11" 1db082c21f Revert "try the current "main" of GSL" 44b70edde1 try the current "main" of GSL 4edbf6badf Revert ""There is no warning 4814"" bcd7458be4 "There is no warning 4814" c185bf3f14 starting working on MutexCpp11 313bdd1d98 AtomicCounter* files have been removed c1c4480519 remove our GSL work-around for C++11 37ae1193e2 remove our mem::SharedPtr, it's now always std::shared_ptr 71f3c12990 remove no-longer-used NSPR code 8e77cb210c removed no-longer-used Irix and Solaris files fabef69661 use std::atomic for all AtomicCounter implementations ace5b6d5a6 TEST_FAIL -> TEST_FAIL_MSG 30076c1d16 turns out there was already a TEST_FAIL macro d73ee16fb4 need "::" to find global test ba01c48df7 remove C++11 workarounds for C++14 features cbd4a31aef Squashed commit of the following: caed59480d Release 2022-08-30_cpp14 (#597) 2630d41e08 get rid of merge conflict 652bce3854 Merge branch 'master' 838c323d6a Merge branch 'master' 4189c429e8 Merge branch 'master' 903ee7ffff Merge branch 'master' a1c0a1eea6 Merge branch 'master' 1bfe5fc402 Merge branch 'master' b21c203b8d Squashed commit of the following: 6c2df8bb62 "main" is now C++14 (not C++20) 2ce4161080 Squashed commit of the following: 3a0f7fd14d Merge branch 'master' 142fd7185e Merge branch 'master' d442e5be0f Merge branch 'master' 32f08a9e40 Squashed commit of the following: ee15ba3172 Merge branch 'master' bede753547 fix unit-test with C++20 61a8033f62 consistent use of coda_oss:: and std:: 5d3bf9eb83 Merge branch 'master' 34c40bd397 Merge branch 'master' a9b9d2a9fa Merge branch 'master' 24a3f01afe Merge branch 'master' f92811a53b Merge branch 'master' 5b542c60fd Squashed commit of the following: cb0cf94ff6 ByteStream.cpp is now warning-free f5daa37fc7 cast to DWORD; "const" correctness bfaf644ff6 #pragma-away compiler warnings from standard headers 72d202dbe3 Merge branch 'master' into develop/reduce-compiler-warnings 414c25c551 build with C++20 in VS 1a99a29da3 Merge branch 'master' 5cca863d7e Merge branch 'master' 6d4776235e Merge branch 'master' 8f1173f4a6 fix build errors f21af35b0b Merge branch 'master' 4db8ada411 restore changes clobbered with merge from "master" a1f36e1839 Merge branch 'master' 80fe8e9f8a Merge branch 'master' 33b0f3f6eb Merge branch 'master' 8bd0c8cf4a Merge branch 'main' of github.com:mdaus/coda-oss 7e41b4b5e4 Merge branch 'feature/use-cpp11-code' fc99e4b3e6 recreate from "master" 510317c07a use std::filesystem to "implement" sys::filesystem 895f6c77cd always implement sys::filesystem 0d83ae22fc "units" changes from master b58173b781 latest from "master" (not quite) 793e3442c8 Squashed commit of the following: 91a729f5a2 re-create from "master" b076580cdc trying to fix GCC compiler warning 1687dc7fca Merge branch 'master' into develop/reduce-compiler-warnings 2c5db86dbe Merge branch 'master' into develop/reduce-compiler-warnings 6f76c2e3e1 Update CMakeLists.txt c3ca4a5388 do in-line initialization 8e67336183 remove G++ compiler warning a0eff51cf8 Merge branch 'master' into develop/reduce-compiler-warnings af19d88a65 Merge branch 'master' into develop/reduce-compiler-warnings ba31cbaa9b use "void*" to avoid reinterpret_cast<> 08da1f8a1d Merge branch 'master' into develop/reduce-compiler-warnings d1d453a2e2 Merge branch 'master' into develop/reduce-compiler-warnings f5074a996a CODA_OSS_NDEBUG is extra gunk and not used; omit for now. 22de488585 don't even bother compiling our own versions of localtime_s() and gmtime_s() if we're not going to use them (compiler warning about "unused static funtion.") 0c92eba58a tweak NDEBUG/CODA_OSS_NDEBUG; update comments 544604775f Don't need to expose our own versions of localtime_s() and gmtime_s() a050796c1b Merge branch 'develop/reduce-compiler-warnings' of github.com:mdaus/coda-oss into develop/reduce-compiler-warnings fed6046170 older compilers want std::string() as argument to std::logic_error() cf2c502a64 do more debug & release builds on GitHub d4aa99256f build some debug targets on Gitlab 3682452586 tweak CODA_OSS_DEBUG again for G++ 24ba64f71f tweak how CODA_OSS_DEBUG is set 9680e8f0e1 add check for _GLIBCXX_DEBUG 943218f83a Merge branch 'master' into develop/reduce-compiler-warnings 01c68e7056 %#@*@%)*%@ fix RowCol::cast() again! :-( b8472b4576 oops ... gsl::narrow<> should be gsl::narrow_cast<> so that int/double conversion doesn't throw 109255ca83 "final" breaks SWIG; wrap RowCol use of gsl::narrow e51e4c2ad2 no need to create local just to return e546f2510c Merge branch 'master' into develop/reduce-compiler-warnings d1391f9898 use template for to_std_string() overloading 566942680a fix std::char8_t when building with C++20 cf604b1abf fix C++17 build errors 48a0fbedbf get rid of coda_oss namespace; use CODA_OSS_cpp17 instead 9706a43365 remove code-analysis diagnostics 50592e4f84 G++ complains about an unneeded call to std::move() 9c7643c3f7 Merge branch 'master' into develop/reduce-compiler-warnings ecfe1f8a75 more "noexcept" b7ac50fb9b Merge branch 'master' into develop/reduce-compiler-warnings eaecf46ed2 tweak CODA_OSS_cplusplus from "main" 5773b1ec15 trying to get C++17 WAF build working on Windows a048a00a1c unique names for waf & CMake 7a5a0d5b28 do a better job of setting CODA_OSS_DEBUG 4355aae923 Merge branch 'master' into develop/reduce-compiler-warnings 1fd8cede23 cleanup for VS 2019 16.10 4dffa13949 explicitly =delete copy/assignment df8f8920a0 Merge branch 'master' into develop/reduce-compiler-warnings 42b4e99b62 remove code-analysis diagnostics 70ce322c94 reduce compiler warnings/code-analysis diagnostics when building six 20eac2f495 Merge branch 'master' into develop/reduce-compiler-warnings ff3ded56d7 get rid of more compiler warnings/code-analysis diagnostics 669dd51ffe Merge branch 'master' into develop/reduce-compiler-warnings 623b65ab93 Merge branch 'master' into develop/reduce-compiler-warnings 11c75df53f fix release build errors 66f048b92d turn on more compiler warnings where possible eb615e315e consolidate calls to mem::make::unique a6f5eb690d reduce use of explicit new 84d5e1b011 use mem::make::unique instead of explicit new 019d726eac = default for default constructors 86ab5d8f37 use std::unique_ptr and "const noexcept" b071972d76 another batch of =default for default constructors 98276da943 more =default for default .ctor()s ceb7bc596e do default constructors with =default 7bed517508 more code-analysis cleanup f9c04b1177 "noexcept" code-analysis warnings 6586ae3908 need gsl::make_span from gsl/span_ext 722089774f remove gsl/mem dependency cycle d741a07611 use gsl::narrow<> instead of static_cast 99eb4b36e2 get rid of signed/unsigned mismatch compiler warning 814450522d remove more code-analysis diagnostics c8441b309a Merge branch 'master' into develop/reduce-compiler-warnings e6d70a9ffb last of "const" from code-analysis b8445814a4 mark a few more things as "const" per code-analysis d18544ec7e don't need to create temporary std::strings ee7faa9790 still more code-analysis cleanup 5cd6f864d8 cleanup more code-analysis diagnostics 492fb0a866 one more compiler warning about implicitly deleted copy/assignment b8f782c880 remove compiler warnings about implicitly deleted copy/assignment/move 14d1d1cb82 #pragma-away warnings from GSL 86c40ea6c2 assert() to prevent some code-analysis diagnostics 7204517a96 make copy/assignment explicit 3ce8240797 reduce code-analysis diagnostics 01e367a56e Merge branch 'master' into develop/reduce-compiler-warnings 03f3ddde91 proper printf format 877d7dc93a Merge branch 'master' into develop/reduce-compiler-warnings 5a4a3d5751 code-analysis doesn't like C-style casts a3fdae4165 code-analysis doesn't like NULL 6309baedce Merge branch 'master' into develop/reduce-compiler-warnings d1194a2fed Merge branch 'master' into develop/reduce-compiler-warnings 535b4757d3 Merge branch 'develop/reduce-compiler-warnings' of github.com:mdaus/coda-oss into develop/reduce-compiler-warnings a60b95d60d "constexpr" can be hard to get right with older C++11 compilers; don't even try c07b5303ec Merge branch 'master' into develop/reduce-compiler-warnings 04306bbee0 need at least VS2017 to use the real GSL 796ad820b5 Merge branch 'master' into develop/reduce-compiler-warnings 16c240cd66 Merge branch 'master' into develop/reduce-compiler-warnings e07e89f0cf turn on "warnings as errors" for CMAKE builds 5c019f8917 complex "constexpr" functions not available with our version of g++ 4ab074a584 fix a few more compiler warnings ... nearing the end! :-) dea7ea41bd And still more compiler warnings ... almost done 🤞🏻 fbe3bbb205 remove assorted compiler warnings e60b7fd3c1 Merge branch 'master' into develop/reduce-compiler-warnings e9df212c62 Arguments should be "const&" to prevent C4866 94e75cbeda Merge branch 'master' into develop/reduce-compiler-warnings d3130414af Merge branch 'master' into develop/reduce-compiler-warnings 9a5e71f314 Merge branch 'master' into develop/reduce-compiler-warnings bd27c0232a Merge branch 'master' into develop/reduce-compiler-warnings c053362d2c remove still more compiler warnings 9f133b85a3 remove some more compiler warnings 0883c729c1 Merge branch 'master' into develop/reduce-compiler-warnings f4b7668800 avoid comparision between signed/unsigned to prevent compiler warning 1e6564a6eb eliminate more compiler warnings 85a7b8ad0f remove a few compiler warnings 09c82049fe Merge branch 'master' into develop/reduce-compiler-warnings 31f1662fa4 Merge branch 'master' into develop/reduce-compiler-warnings a313562a3c Merge branch 'feature/fix-compiler-warnings' into develop/reduce-compiler-warnings 8547cdd247 eliminiate GCC warnings from Filesystem.h b5044b2a2f fix several compiler warnings/code-analysis diagnostics 9d2f90b8c8 GetEnvironmentVariable() and getenv() aren't quite the same 6faa3666f6 remove more compiler warnings git-subtree-dir: externals/coda-oss git-subtree-split: e87c32b4def7c535b57acd69d18ee3b2c8128207 commit c34a8a817968dfadc1632e2b1dcd520a576431dd Author: Dan Smith Date: Mon Mar 13 12:54:08 2023 -0400 restore 'main' commit 4d155ad54bca472841ed3a448103b52c665db087 Author: Dan Smith Date: Mon Mar 13 12:53:53 2023 -0400 restore 'main' commit 4706b3910595d2ab8d6dab2e33c062436e02d841 Merge: e4a01a0af 7d77233db Author: Dan Smith Date: Mon Mar 13 12:53:09 2023 -0400 Merge branch 'main' into develop/sync_externals commit e4a01a0afe5acfe40779f0894c2eadfd15acd1ac Merge: 13d51a6ba 342f55276 Author: Dan Smith Date: Mon Mar 13 12:53:00 2023 -0400 Merge branch 'master' into develop/sync_externals commit 13d51a6ba8f4bf58f18c3352b3feaa6fa82aa9c6 Author: Dan Smith Date: Mon Mar 13 11:42:15 2023 -0400 fix compiler erros in test_VectorN.cpp commit 50cf5d5afe7264d782f73962a2cb0f793e0ec011 Author: Dan Smith Date: Mon Mar 13 11:39:44 2023 -0400 copy_externals.csh commit 513c0189cf718030c3ad1f719bfb147c7ababb15 Merge: a6d2aadc5 383f59046 Author: Dan Smith Date: Mon Mar 13 11:38:16 2023 -0400 sync_externals.csh commit 383f590466d76803908065e342ae20c6f2f6eeb7 Author: Dan Smith Date: Mon Mar 13 11:38:08 2023 -0400 Squashed 'externals/coda-oss/' changes from 67d6362bc..cbfb20ce2 cbfb20ce2 update release notes for C++11/master release (#658) 4bdaf10d9 Change xml lite function to virtual (#645) 6be8f0a2e move debug -g flags to be turned on only if debugging (#644) e1b0fa349 commit (but not build) HDF5 source code (#634) 1ac97fe48 add HDF5 source code (not built) (#612) fde6c864f Merge pull request #607 from mdaus/bugfix/change-order-of-config-header-install c8a004401 Install the cmake-configured header after installing the xercesc source tree. Otherwise, the original config will persist in the install dda2c9acd Merge pull request #606 from mdaus/fix-xerces-config 004a00f09 Bump zlib version for conan builds 207f4dbb9 Fix Xerces config issue and install its config.h b84241767 Add support for debug optimizations. 0f6cda57d Use enhanced debug information with gcc/gdb. 5047dce1a Work around GCC avx support bug. 001ab1875 Rebuild the waf self-extractor with a fix for the FIPS error. 5a7f64fca Revert "Rebuild the waf self-extractor with a fix for the FIPS problem." 9f6f775f8 Rebuild the waf self-extractor with a fix for the FIPS problem. 963e8ff40 Revert "add HDF5 source code (#603)" ec7bb2e52 add HDF5 source code (#603) 6f41c09d7 Release 2022-08-30 (#596) f91668012 Added handler accessor to MinidomParser for inheriting modules (#594) 72d29e9c2 get unittests working when "nested" in other projects (#595) f8f18fea5 Actually look at unit test results when using waf (#593) cda679cee more overloads to take a string length (#592) b95a32bc4 by default, Uri()s aren't validated (#591) 173930a6f fix a UTF-8 conversion bug (#590) c5c221a83 CODA code inherits from xml.lite classes :-( (#589) a4c6294c3 use EncodedStringView instead of _bstr_t (#588) 83c982f0c remove work-arounds to write non-UTF-8 XML (#586) ebf6db176 is part of C++20 d3aa8aa5c std::u8string is in C++20, not C++17 03654933c changes to math.linear from coda (#587) 5a2f8e52f release 2022-08-02 (#585) e5516aba2 tweak names to match utf8:: conventions (#584) 3083ec791 move most platform-specific code to EncodedStringView (#583) 36371410c EncodedString tweaks for XML processing (#582) cf2016205 remove any vestiges of Expat and libXML (#580) 33538aa0f update for newer Intel compiler ed65e4ccc Add two patch candidates to fix FIPS problems in waf. a731ebf8e release 2022-06-29 (#579) 59387bd87 update "ReleaseNotes.md" for recent changes (#578) e4f940854 remove "boost" and "serialize" (#577) 80b70537e update to zlib-1.2.12 (#576) 202084bac Remove some compiler warnings (#575) c61232224 build most code with Visual Studio (#574) 6e4d952be some unit-tests need argc/argv (#573) 36e051d7b Add run1D method to GenerationThreadPool (#572) 0a08b8e4e build "coda-oss-lite" as a VS2022 project (#571) 6677cc38e simplify creation of encodes string (#570) ba62c610c Add the 'universal_newlines=True' flag to python Popen calls. 984e4a96c Fix a bug in waf platform detection. d2aca8d4b release 2022-05-03 (#569) ff55fed59 can't replace all TEST_ASSERT macros with functions (#568) 89a636a6a fix copy/assignment in EncodedString (#567) c3fe91d42 latest tweaks to build with C++17 (#566) a59a51b57 be sure we use a 64-bit time_t (#565) 1f79fb3dd Poly2D::atY() bugfix (#564) ac5307662 Testing to see if windows-2019 works with github actions (#563) 8d0726b37 Fix a bug in waf platform detection. c662b5aac Update ReleaseNotes.md ef4a3bbd9 Release 2022-02-22 (aka 2/22/22) (#562) 0a0e6cf14 use char16_t on Linux (#560) fe65bfddf fix units for ICC, sys::filesystem (#559) def979170 update to GSL 4.0.0 (#558) fe365e5a4 fix XML validation for UTF-8 (#557) 502e5829b support conversion to std::wstring (#556) e69422596 Delete codeql-analysis.yml 45bc6a964 Create codeql-analysis.yml 87d9a7ef5 remove CodeQL eab5ecb89 Update build_unittest.yml 8ab12d47e Delete codeql-analysis.yml 9e542092b try running CodeQL as part of build-linux-cmake de0c50651 Create codeql-analysis.yml 049608782 tweaks to build in "coda" (#554) 0ba24233b replace sys::U8string with coda_oss::u8string (#553) bcee6551f add EncodedString class (#552) c2eecd392 simplify implementation of EncodedStringView (#551) c1320ef00 fix 'typename' for other compilers (#550) ac3b93931 tweaks to make "main" build easier (#549) 78da741cf remove sys/Optional.h (#548) f31730ac7 put our std work-arounds in one place (#547) 9b7bb571a Add an EncodedStringView class (#545) c0e1da520 another batch of tweaks to cleanup compiler warnings, etc. (#546) 0f3bfd9d0 added missing "virtual", support unique_ptr (#544) ca32f99c0 Add option to specify curl installation location. (#501) 2df9c1a81 allow std::filesystem::path to be used for validation (#543) 289143576 add SinCos for units::Angle (#542) e430eddef Delete log4j as 1) it's old, 2) coda-oss doesn't use it, and 3) remove any questions about security vulnerability (#541) bb11134fd xml.lite tweaks (#540) 955b33e21 Release 2021_12_13 (#539) d73d74d5c xml.lite tweaks (#537) 3a90e25c6 use more C++11 functionality (#538) 9ca2a0e50 remove more compiler warnings (#536) 0ec9da1e9 be sure == and != are in-sync (#535) 9084be32c fix size_t compiler warnings (#534) abd6469ec fix ICC errors (#533) 09cb36fff update version number before cutting a new release (#532) c29e4d298 fix ICC warnings/errors from high-side (#531) 91f8f1c08 simplify our std:: implementations (#530) 7c633c7bb Further reduce use of std::auto_ptr (#529) d85883749 Provide support for creating simple version numbers (#528) b03582592 Merge pull request #527 from mdaus/fix-crypt-h-clash ffed3d633 Disable encryption support in minizip build and remove crypt.h header ee2b2bf8c Merge pull request #525 from mdaus/swig-fix 3c02ff289 Fix config-python prefix issue 6149053d4 Add new config-python module for SWIG compatibility workarounds 30acf5b9a mt::transform_async(), mem::SharedPtr, math::SinCos() (#526) 21efd6a6c Implement better workaround for lack of SWIG support for "final" 60837a62e Revert unneeded changes 0bc994dea Fix SWIG path issue for waf build 070f4e915 Update SWIG generated files f8472b0c4 Fix SWIG path issues and warnings e10707f75 Set minimum SWIG version to 4.0.1 b8cdba5c7 Fix waf SWIG build issue 2bd0ee39e Enable SWIG in Github waf build f2b001146 Try fixing SWIG compile issue again afafabcc2 Fix SWIG compile issue on Linux due to missing macro 7c8d4a81d Add SWIG to the CI flow 4023d721c Regenerate SWIG bindings 1d8c70109 Add some compile definitions needed by SWIG for CMake build e5cc58545 Remove some functions which return unique_ptr from SWIG bindings (incompatible). 965a2913d Remove "final" specifier from structs bound in SWIG (incompatible) f1bec5601 Merge branch 'master' of https://github.com/mdaus/coda-oss c01c4d7de do in-line initialization (#524) fb7230ea1 Update CMakeLists.txt 5dfb05689 tweaks for C++17 (#523) 1a7d3ab52 Merge pull request #515 from mdaus/security-and-conan-updates d13885df6 make it easier to create a new Element with the right encoding (#522) 3fb09e73a Merge pull request #359 from mdaus/parseArgUpdate 0d546a8f1 Tweak some ArgumentParser tests for the ignoreUnknownArguments option 14bd1f26d Merge remote-tracking branch 'origin/master' into parseArgUpdate cf398c0d3 tweak code for C++11/C++17 (#521) 2d0322b07 reduce use of std::auto_ptr (#520) 853320e90 reduce use of deprecated C++98 code (#519) 4752ba222 Replace some warning pragmas with macros 32685554f Merge remote-tracking branch 'origin/master' into security-and-conan-updates f0350c0cf Merge pull request #518 from mdaus/bugfix/python3.9-related fc01df0d8 fix typos in gcc macros 9d356f36c fix gcc impl 8124da763 remove unreachable code d034b3a84 clobber warnings from numpy innards 9941a401e macros to disable warnings around system headers 8a725bb8f Merge pull request #516 from mdaus/mbraswell-enablecpp17-windows 2e7b8165a Fixed pragma stuff on gcc 9775bb02d Fixed pragma stuff on gcc 680d3cce4 Merge branch 'master' of https://github.com/mdaus/coda-oss 8ffd6ed79 forgot to add "units" to CMakeFiles.txt 06835676e Remove Auto_ptr flag and make disable warnings cross_platform compatible d62efece5 Merge branch 'master' of https://github.com/mdaus/coda-oss into mbraswell-enablecpp17-windows d04042ee9 Merge pull request #517 from mdaus/develop/compiler-warning-helpers cf5cd16b3 Fix macro usage on gcc a88bbcd20 Macros to narrowly target disabling warnings c0d5cdf00 Formatting Changes be019b44b Formatting Changes 2eb04dc9e Fixed compiler warnings and added option to compile cpp17 with waf on windows 5d9f27fae Refactor coda-oss conan recipe ce6645714 Disable warning for MSVC2017 and earlier ecfefbfbe Merge remote-tracking branch 'origin/master' into security-and-conan-updates 8b1479881 Merge pull request #514 from mdaus/develop/fix-unused-symbol-errors 1d9a4ec71 Add conan option to use std::regex instead of pcre 6dd5d4457 add required include 4c0ae7781 add required include 1873ceeb8 parameterize build (somewhat) c9ef567a7 fix Release compile error e6b47e94e fix compiler error eff205ba2 helper macro to fix unusual targets 342098a32 Fix CMake build for modules without include files 5625706eb Enable cpp17 option for windows builds 98e12b138 Use consistent line endings for *.in template files d01fea0b7 Configure coda_add_module to install more file extension types 30823f673 Delete stray file ac7760ba2 Load dependency targets when loading coda-oss for conan build 14781cab8 Implement conan build for openjpeg and pcre2 dependencies 9d955efa5 Exclude unsupported XML backend wrappers from CMake build to remove warnings 1e8c9b264 Merge remote-tracking branch 'origin/master' into security-and-conan-updates 772d80495 Implement conan build for libjpeg dependency 98b653dea Implement conan build for xerces-c dependency 11323e8e9 Implement conan build for zlib dependency d0e6bf2c4 Improve conan test_package a03e1294e Fix uninitialized member variable warning in mt::AbstractTiedThreadPool c7bb47b5f Remove member variable duplicated in derived class io::ToggleOutputStream 0838ac2ca Use consistent line endings for conan recipes and CMake files. 2768e5f07 Update libjpeg to v9d d75f55bca Update zlib to 1.2.11 ca2f84cff Fix warning in GSL for MSVC 2015 and earlier 1babd19b5 Fix warning in thread tests for MSVC 2f1763249 Fix warning in except module for Visual Studio 2015 and earlier a485bf6bb Fix BIGENDIAN redefinition warning 59543e42b Disable warning in dbi for MSVC 2017 and earlier b4b212834 Fix warnings in numpyutils for MSVC 2017 and earlier 2b179b658 Fix integer overflow issue 898151ad7 Hook up simple "units" (#513) 4d6beeecc Merge pull request #511 from mdaus/develop/horizontal-improved-numerical-precision c1878b228 Fix for numerical precision issues surrounding horizontal lines 7d1442c66 Merge pull request #510 from mbraswell/fix-testnumelements-build 58fc85f09 Whitespace change to trigger workflow ab74026b9 Fix wscript to successfully build test_num_elements 323283cd7 Merge pull request #509 from mbraswell/develop-mbraswell-cpp17 16a550289 Added option to enable cpp17 b0625cf5a tweak debug stuff (#508) 845549487 fix RowCol casting (#507) 01fbb5f00 Get std::u8string working right with C++20 (#506) df9413efa more "noexcept" for fewer code-analysis diagnostics (#505) e6219f97f reduce compiler warnings/code-analysis diagnostics (#504) 4c9ea0ef1 tweaks for VS2019 16.10 (#503) 0d8ea070a reduce compiler warnings (#502) 625b8b59d reduce compiler warnings (#500) 3795758da get rid of more compiler warnings/code-analysis diagnostics (#499) 427f91be8 reduce compiler-warnings and code-analysis diagnostics (#498) c82dd9e37 cleanup compiler and code-analysis diagnistics (#496) b5105b54a reduce compiler warnings (#495) e0099cc26 Develop/compiler optimizations (#494) 0eeb3f963 tweaks to python wrappers made in "nitro" (#492) 5f91f7060 fix printf() format string (#491) 55b855a86 Delete codeql-analysis.yml 603c192d3 Update codeql-analysis.yml f306979e8 Update codeql-analysis.yml 4a1f78f8e Create codeql-analysis.yml 3c80a6568 add back coda_oss::filesystem::path (#490) eaea659ed tweak how std:: features are exposed (#489) 0492f0d95 simplify code exposing std:: routines (#488) e5f3d7770 remove code-analysis diagnostics (#485) 5be599e5a make HOME and USERPROFILE the same (#484) 62b22ae01 cleanup more compiler warnings (#483) c32ec7dcc add unit-tests for env-var editing (#482) 311aea462 allow an environment-variable to be "edited" during expansion (#481) bbcab1310 static_assert is C++11, don't use it when checking for C++11 (#480) 068562f58 fix glitches in expandEnviromentVariables() (#479) 30ed1d95e produce a new Path::expandEnviromentVariables() function (#478) 074a873b2 remove compiler warnings (#477) e29f65479 latest C++17 tweaks (#476) c4e681b0a tweak code when wchar_t is a built-in type (#474) 8449ac29a wchar_t might not be a built-in type on old systems (#473) a62bdb3e6 add operator= to sys::Optional (#472) 8e310a776 use compiler-provided macros to determine features (#470) 88405c8ed "constexpr" can be hard to get right with older compilers; don't even try (#471) b195ab3ef need at least VS2017 to use the real GSL (#469) 2978f9114 tweaks to build with older compilers (#468) 7235b898d The (old) version of SWIG we're using doesn't like certain C++11 features. (#464) cccde7f12 only look in the Win1252->UTF-8 map as a last resort (#467) 3db09742c get rid of more compiler warnings (#465) 5e0d2e845 get rid of "char8_t" compiler warning (#463) d710bc688 make getValue() easier to use (#462) f5a928476 make getElement*() be consistent for both 0 and >1 (#461) 88be6dba3 consistently add C++14/17/20 library features (#459) 59c3a7e2e use coda_oss:: as a drop-in replacement for std:: (#458) 35de4524c use sys::Filesystem::path rather than std::string (#457) cace66600 make sys::Filesystem::path better conform to std::filesystem::path (#456) f395edc89 remove ambiguous overloads w/C++17 (#455) eac4371f1 use newly added sys::Optional<> to manage "encoding" (#454) 243ef5e50 don't derive from std::iterator (#453) a48b01141 Arguments should be "const&" to prevent C4866 (#452) 878bff901 provide std::span (#451) 81727c485 remove newly added a new pure virtual as that's a breaking change (#450) 93cf0f03e main -> master (#449) 5af37a736 be sure code compiles with C++17 (#448) 82b5aecfb build with C++17 (#407) 6ffb888d7 reduce compiler warnings (#439) 9137dda7d GSL (Guideline Support Library) from https://github.com/Microsoft/GSL (#423) bc5552cd2 update to xerces-c-3.2.3 (#409) 6fe09e1db update to openjpeg-2.3.1 (#417) 6405c0ce5 reduce differences in #407 (#438) 2987bbf8d tweak how std::filesystem is enabled (#437) 8fd3c2f20 tweak how std::endian is enabled (#436) 138372c88 more straight-forward reduction of std::auto_ptr (#435) f13c7cec8 straight-forward reduction of std::auto_ptr (#434) d243b08e1 add mem::auto_ptr for transition to C++17 (#432) 54ed52158 allow clients to specify custom toType and toString (#431) 7f90aab25 remove trailing underscore from macro (#429) 999e49068 with C++11, several sys typedefs are the same on both Windows & *nix (#427) 6f075b1be add sys::Byte (#426) 92221bd0d allow except::Throwable to derive from std::exception (#421) a8f52d0ad reduce compiler warnings (#424) 63ea20af6 #including w/C++17 generates warnings (#408) 10ef06031 reduce compiler warnings (#405) cf233fdcf forgot Conf.cpp changes for sys::Endian (#403) cc53b1853 fix several compiler warnings/code-analysis diagnostics (#404) 1db3751a3 implmeent sys::Endian from C++20 (#402) f042cd6bb support std::filesystem if desired (#400) 4895a9f2d WIN32 is old, but existing code might still use it; _WIN32 is better (#398) e2a62f8ec make it easier to use xml.lite (#396) 1059b7da1 allow for explicit use of a UTF-8 string (#395) 27de8b8a4 Optionally record how std::string is encoded when manipulating XML (#378) e0018cea7 implement some -like routines until we can use C++17 (#388) cafb2365b Merge pull request #363 from mdaus/feature/fix-compiler-warnings 6a78bec20 use the existing sys::ubyte rather than making our own pre-C++17 std::byte 14c9fc4ca fix a couple of G++ compiler warnings via static_cast<> e596a6007 std::numeric_limits::epsilon() can be "constexpr" 78b0f6bb2 another try at removing the compiler warning from tiff::split() 8e1de21e1 fixed typo; added a few nots about why we're not using strncpy() fed3ba8cd retore previous tiff::split() code as the change got rid of the compiler warning but wasn't portable 98a589616 get rid of g++ strncpy() warning 798f84711 don't use memset(0) with C++ objects 7f697d078 casting result of system() to void doesn't get rid of compiler warning d55a849c5 remove new g++ compiler warnings in WSL d0aaa2988 Merge pull request #361 from mdaus/feature/fix-compiler-warnings cc62e866b fix compiler warnings d45c1f9a0 Updates based on peer review comments which include changing ostream to pointer, adding a couple of more tests, and updating all auto_ptr to unique_ptr in unit test. fb12ba126 Update ArgumentParser to use a stream as an argument if the ignore unknown argument flag is set to true. 536d2b0ca Added ability to ignore unknown arguments in the ArgumentParser. 27288f49b Merge pull request #358 from mdaus/conan-options fd5e1eecb Expose additional CMake options in conan recipe c97216179 Remove unneeded CMake function git-subtree-dir: externals/coda-oss git-subtree-split: cbfb20ce2e64635131ed17790d93bd54b78754d6 commit a6d2aadc53d857b2079ec0873b77c3efd2679574 Author: Dan Smith Date: Mon Mar 13 11:37:55 2023 -0400 copy_externals.csh commit 20cfa0d038521ecf4839441fe8d10d1a71518a35 Author: Dan Smith Date: Mon Mar 13 10:52:27 2023 -0400 don't do push after sync'ing externals commit b782101ab6f6bcd339df571e97dced905a797a93 Author: Dan Smith Date: Mon Mar 13 10:50:53 2023 -0400 HDF5 source code (not built) commit bbb9a45b8954094bace58bbda36eef4c171de0b9 Author: Dan Smith Date: Mon Mar 13 10:35:08 2023 -0400 trying to fix build error --- externals/coda-oss/UnitTest/UnitTest.vcxproj | 4 + .../UnitTest/UnitTest.vcxproj.filters | 3 + externals/coda-oss/UnitTest/mt.cpp | 4 + externals/coda-oss/UnitTest/pch.h | 2 + .../modules/c++/coda-oss-lite.vcxproj | 6 +- .../modules/c++/coda-oss-lite.vcxproj.filters | 12 + .../c++/coda_oss/include/coda_oss/CPlusPlus.h | 3 +- .../c++/coda_oss/include/coda_oss/bit.h | 60 +++ .../c++/coda_oss/include/coda_oss/cstddef.h | 4 + .../c++/coda_oss/include/coda_oss/span.h | 21 + .../modules/c++/mem/unittests/test_Span.cpp | 36 ++ .../c++/mt/include/mt/ThreadedByteSwap.h | 90 +++++ .../c++/mt/unittests/test_mt_byte_swap.cpp | 72 ++++ .../coda-oss/modules/c++/std/include/std/bit | 20 +- .../modules/c++/std/include/std/cstddef | 4 + .../coda-oss/modules/c++/std/include/std/span | 3 + .../modules/c++/sys/include/sys/ByteSwap.h | 118 ++++++ .../c++/sys/include/sys/ByteSwapValue.h | 196 ++++++++++ .../modules/c++/sys/include/sys/Conf.h | 208 +--------- .../modules/c++/sys/include/sys/Span.h | 188 +++++++++ .../coda-oss/modules/c++/sys/source/Conf.cpp | 261 ++++++++++--- .../c++/sys/unittests/test_byte_swap.cpp | 366 ++++++------------ .../nitf/source/DecompressionInterface.cpp | 30 ++ 23 files changed, 1202 insertions(+), 509 deletions(-) create mode 100644 externals/coda-oss/modules/c++/mt/include/mt/ThreadedByteSwap.h create mode 100644 externals/coda-oss/modules/c++/mt/unittests/test_mt_byte_swap.cpp create mode 100644 externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h create mode 100644 externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h create mode 100644 externals/coda-oss/modules/c++/sys/include/sys/Span.h diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj b/externals/coda-oss/UnitTest/UnitTest.vcxproj index 5f55f6360..064502651 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj @@ -259,6 +259,10 @@ true true + + true + true + true true diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters b/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters index e85d2fcd0..37d7c36cf 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj.filters @@ -219,6 +219,9 @@ re + + mt + diff --git a/externals/coda-oss/UnitTest/mt.cpp b/externals/coda-oss/UnitTest/mt.cpp index 2de6f17fd..6190f8aa4 100644 --- a/externals/coda-oss/UnitTest/mt.cpp +++ b/externals/coda-oss/UnitTest/mt.cpp @@ -24,4 +24,8 @@ TEST_CLASS(work_sharing_balanced_runnable_1d_test){ public: #include "mt/unittests/work_sharing_balanced_runnable_1d_test.cpp" }; +TEST_CLASS(test_mt_byte_swap){ public: +#include "mt/unittests/test_mt_byte_swap.cpp" +}; + } \ No newline at end of file diff --git a/externals/coda-oss/UnitTest/pch.h b/externals/coda-oss/UnitTest/pch.h index 8229e0b47..2396089d4 100644 --- a/externals/coda-oss/UnitTest/pch.h +++ b/externals/coda-oss/UnitTest/pch.h @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,7 @@ #include #include #include +#include #include #include #include diff --git a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj index f50ac4a19..d5e4e5cf8 100644 --- a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj @@ -149,6 +149,7 @@ + @@ -191,6 +192,8 @@ + + @@ -228,6 +231,7 @@ + @@ -421,14 +425,12 @@ DynamicLibrary true v143 - true DynamicLibrary false v143 true - true diff --git a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters index 75b551471..a8119ff83 100644 --- a/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters +++ b/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters @@ -735,6 +735,18 @@ config + + sys + + + sys + + + mt + + + sys + diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h index f28d64236..b912e9c3e 100644 --- a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/CPlusPlus.h @@ -63,11 +63,12 @@ #endif // CODA_OSS_cplusplus // Define a few macros as that's less verbose than testing against a version number +// https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros #define CODA_OSS_cpp11 (CODA_OSS_cplusplus >= 201103L) #define CODA_OSS_cpp14 (CODA_OSS_cplusplus >= 201402L) #define CODA_OSS_cpp17 (CODA_OSS_cplusplus >= 201703L) #define CODA_OSS_cpp20 (CODA_OSS_cplusplus >= 202002L) -#define CODA_OSS_cpp23 0 +#define CODA_OSS_cpp23 (CODA_OSS_cplusplus >= 202302L) #if !CODA_OSS_cpp14 #error "Must compile with C++14 or greater." diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h index 99045bba1..32ef77862 100644 --- a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h @@ -22,6 +22,14 @@ #define CODA_OSS_coda_oss_bit_h_INCLUDED_ #pragma once +#include +#include +#ifdef __GNUC__ +#include // "These functions are GNU extensions." +#endif + +#include + #include "coda_oss/namespace_.h" namespace coda_oss { @@ -38,6 +46,58 @@ namespace coda_oss native = __BYTE_ORDER__ #endif }; + + // https://en.cppreference.com/w/cpp/numeric/byteswap + namespace details + { + // Overloads for common types + inline constexpr uint8_t byteswap(uint8_t val) noexcept + { + return val; // no-op + } + #if defined(_MSC_VER) + // These routines should generate a single instruction; see + // https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/ + inline uint16_t byteswap(uint16_t val) + { + return _byteswap_ushort(val); + } + inline uint32_t byteswap(uint32_t val) + { + return _byteswap_ulong(val); + } + inline uint64_t byteswap(uint64_t val) + { + return _byteswap_uint64(val); + } + #elif defined(__GNUC__) + inline uint16_t byteswap(uint16_t val) + { + return bswap_16(val); + } + inline uint32_t byteswap(uint32_t val) + { + return bswap_32(val); + } + inline uint64_t byteswap(uint64_t val) + { + return bswap_64(val); + } + #else + #error "No platform-specific byteswap()" // TODO: do something else? + #endif + } + + template + inline T byteswap(T n) noexcept + { + // "std::byteswap participates in overload resolution only if T satisfies integral, i.e., T is an integer type. The program is + // ill-formed if T has padding bits." + static_assert(std::is_integral::value, "T must be integral"); + + using unsigned_t = std::make_unsigned_t; // "Since C++14" https://en.cppreference.com/w/cpp/types/make_unsigned + return details::byteswap(static_cast(n)); + } } #endif // CODA_OSS_coda_oss_bit_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/cstddef.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/cstddef.h index e6e19a8ad..c8c51ed42 100644 --- a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/cstddef.h +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/cstddef.h @@ -22,7 +22,10 @@ #define CODA_OSS_coda_oss_cstddef_h_INCLUDED_ #pragma once +#include + #include +#include // Need a fairly decent C++ compiler to use the real GSL. This brings in more than // we really need for span (e.g., gsl::narrow()), but it keeps things simple. @@ -37,5 +40,6 @@ namespace coda_oss enum class byte : unsigned char {}; #endif // GSL_BYTE_H } +static_assert(!std::is_same::value, "'coda_oss::byte' should be a unique type."); #endif // CODA_OSS_coda_oss_cstddef_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h index c33375c3e..b225f35fe 100644 --- a/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h +++ b/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h @@ -25,6 +25,7 @@ #include "coda_oss/namespace_.h" #include "coda_oss/span_.h" +#include "coda_oss/cstddef.h" // byte // Need a fairly decent C++ compiler to use the real GSL. This brings in more than // we really need for span (e.g., gsl::narrow()), but it keeps things simple. @@ -37,6 +38,26 @@ namespace coda_oss #else // no gsl::span, use our own using details::span; #endif // GSL_SPAN_H + +// https://en.cppreference.com/w/cpp/container/span/as_bytes +template +span as_bytes(span s) noexcept +{ + const void* const p = s.data(); + return span(static_cast(p), s.size_bytes()); +} +template +span as_bytes(span s) noexcept +{ + return as_bytes(span(s.data(), s.size())); +} +template +span as_writable_bytes(span s) noexcept +{ + void* const p = s.data(); + return span(static_cast(p), s.size_bytes()); +} + } #endif // CODA_OSS_coda_oss_span_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/mem/unittests/test_Span.cpp b/externals/coda-oss/modules/c++/mem/unittests/test_Span.cpp index 472a87992..28a76ad20 100644 --- a/externals/coda-oss/modules/c++/mem/unittests/test_Span.cpp +++ b/externals/coda-oss/modules/c++/mem/unittests/test_Span.cpp @@ -26,6 +26,7 @@ #include #include +#include #include "TestCase.h" @@ -94,8 +95,43 @@ TEST_CASE(testGslNarrow) TEST_THROWS(gsl::narrow(d)); } +TEST_CASE(test_sys_make_span) +{ + int i = 314; + int* const p = &i; + auto s = sys::make_span(p, 1); + TEST_ASSERT(s.data() == p); + TEST_ASSERT_EQ(s[0], i); + s[0] = 123; + TEST_ASSERT_EQ(i, 123); + s[0] = 314; + + const int* const q = &i; + auto cs = sys::make_span(q, 1); + TEST_ASSERT(cs.data() == q); + TEST_ASSERT_EQ(cs[0], i); + //cs[0] = 123; // cs = span + TEST_ASSERT_EQ(i, 314); + + std::vector v{314}; + s = sys::make_span(v); + TEST_ASSERT(s.data() == v.data()); + TEST_ASSERT_EQ(s[0], v[0]); + s[0] = 123; + TEST_ASSERT_EQ(v[0], 123); + s[0] = 314; + + const std::vector& u = v; + cs = sys::make_span(u); + TEST_ASSERT(cs.data() == u.data()); + TEST_ASSERT_EQ(cs[0], u[0]); + // cs[0] = 123; // cs = span + TEST_ASSERT_EQ(u[0], 314); +} + TEST_MAIN( TEST_CHECK(testSpanBuffer); TEST_CHECK(testSpanVector); TEST_CHECK(testGslNarrow); + TEST_CHECK(test_sys_make_span); ) diff --git a/externals/coda-oss/modules/c++/mt/include/mt/ThreadedByteSwap.h b/externals/coda-oss/modules/c++/mt/include/mt/ThreadedByteSwap.h new file mode 100644 index 000000000..0b97e1171 --- /dev/null +++ b/externals/coda-oss/modules/c++/mt/include/mt/ThreadedByteSwap.h @@ -0,0 +1,90 @@ +#ifndef CODA_OSS_mt_ThreadedByteSwap_h_INCLUDED_ +#define CODA_OSS_mt_ThreadedByteSwap_h_INCLUDED_ +#pragma once + +#include + +#include "sys/ByteSwap.h" + +#include "ThreadPlanner.h" +#include "ThreadGroup.h" + +namespace mt +{ +/* + * Threaded byte-swapping + * + * \param buffer Buffer to swap (contents will be overridden) + * \param elemSize Size of each element in 'buffer' + * \param numElements Number of elements in 'buffer' + * \param numThreads Number of threads to use for byte-swapping + */ +inline void threadedByteSwap(void* buffer, size_t elemSize, size_t numElements, size_t numThreads) +{ + if (numThreads <= 1) + { + sys::byteSwap(buffer, elemSize, numElements); + } + else + { + mt::ThreadGroup threads; + const mt::ThreadPlanner planner(numElements, numThreads); + + size_t threadNum(0); + size_t startElement(0); + size_t numElementsThisThread(0); + while (planner.getThreadInfo(threadNum++, startElement, numElementsThisThread)) + { + auto thread = std::make_unique( + buffer, + elemSize, + startElement, + numElementsThisThread); + + threads.createThread(thread.release()); + } + threads.joinAll(); + } +} + +/* + * Threaded byte-swapping and copy + * + * \param buffer Buffer to swap + * \param elemSize Size of each element in 'buffer' + * \param numElements Number of elements in 'buffer' + * \param numThreads Number of threads to use for byte-swapping + * \param outputBuffer buffer to write into + */ +inline void threadedByteSwap(const void* buffer, size_t elemSize, size_t numElements, size_t numThreads, void* outputBuffer) +{ + if (numThreads <= 1) + { + sys::byteSwap(buffer, elemSize, numElements, outputBuffer); + } + else + { + mt::ThreadGroup threads; + const mt::ThreadPlanner planner(numElements, numThreads); + + size_t threadNum(0); + size_t startElement(0); + size_t numElementsThisThread(0); + while (planner.getThreadInfo(threadNum++, startElement, numElementsThisThread)) + { + auto thread = std::make_unique( + buffer, + elemSize, + startElement, + numElementsThisThread, + outputBuffer); + + threads.createThread(thread.release()); + } + threads.joinAll(); + + } +} +} + +#endif // CODA_OSS_mt_ThreadedByteSwap_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/mt/unittests/test_mt_byte_swap.cpp b/externals/coda-oss/modules/c++/mt/unittests/test_mt_byte_swap.cpp new file mode 100644 index 000000000..d2099cf83 --- /dev/null +++ b/externals/coda-oss/modules/c++/mt/unittests/test_mt_byte_swap.cpp @@ -0,0 +1,72 @@ +/* ========================================================================= + * This file is part of mt-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2017, MDA Information Systems LLC + * + * sys-c++ 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. + + * This program 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 this program; If not, + * see . + * + */ + +#include "TestCase.h" + +#include + +#include +#include // std::byte +#include + +#include + +static std::vector make_origValues(size_t NUM_PIXELS) +{ + ::srand(334); + + std::vector retval(NUM_PIXELS); + for (size_t ii = 0; ii < NUM_PIXELS; ++ii) + { + const auto value = static_cast(::rand()) / RAND_MAX * + std::numeric_limits::max(); + retval[ii] = static_cast(value); + } + return retval; +} + +TEST_CASE(testThreadedByteSwap) +{ + constexpr size_t NUM_PIXELS = 10000; + const auto origValues = make_origValues(NUM_PIXELS); + + constexpr size_t numThreads = 4; + + // Byte swap the old-fashioned way + auto values1(origValues); + mt::threadedByteSwap(values1.data(), sizeof(values1[0]), NUM_PIXELS, numThreads); + + // Byte swap into output buffer + std::vector swappedValues2(origValues.size()); + mt::threadedByteSwap(origValues.data(), sizeof(origValues[0]), NUM_PIXELS, numThreads, swappedValues2.data()); + + // Everything should match + for (size_t ii = 0; ii < NUM_PIXELS; ++ii) + { + TEST_ASSERT_EQ(values1[ii], swappedValues2[ii]); + } +} + +TEST_MAIN( + TEST_CHECK(testThreadedByteSwap); + ) + \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/std/include/std/bit b/externals/coda-oss/modules/c++/std/include/std/bit index d564c0020..dbcc0b6c5 100644 --- a/externals/coda-oss/modules/c++/std/include/std/bit +++ b/externals/coda-oss/modules/c++/std/include/std/bit @@ -28,7 +28,7 @@ // Make it (too?) easy for clients to get our various std:: implementations #ifndef CODA_OSS_NO_std_endian #if CODA_OSS_cpp20 - // Some implementations cliam to be C++20 w/o + // Some implementations claim to be C++20 w/o #if __has_include() // __has_include is C++17 #include #define CODA_OSS_NO_std_endian 1 // provided by implementation, probably C++20 @@ -47,4 +47,22 @@ namespace std // This is slightly uncouth: we're not supposed to augment "std". } #endif // CODA_OSS_NO_std_endian +// Make it (too?) easy for clients to get our various std:: implementations +#ifndef CODA_OSS_NO_std_byteswap + #if CODA_OSS_cpp23 + #include + #define CODA_OSS_NO_std_byteswap 1 // provided by implementation, probably C++23 + #endif + #ifndef CODA_OSS_NO_std_byteswap + #define CODA_OSS_NO_std_byteswap 0 // <= C++20, use our own + #endif +#endif + +#if !CODA_OSS_NO_std_byteswap +namespace std // This is slightly uncouth: we're not supposed to augment "std". +{ + using coda_oss::byteswap; +} +#endif // CODA_OSS_NO_std_byteswap + #endif // CODA_OSS_std_bit_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/std/include/std/cstddef b/externals/coda-oss/modules/c++/std/include/std/cstddef index 56700ec71..10ba7deac 100644 --- a/externals/coda-oss/modules/c++/std/include/std/cstddef +++ b/externals/coda-oss/modules/c++/std/include/std/cstddef @@ -22,7 +22,10 @@ #define CODA_OSS_std_cstddef_INCLUDED_ #pragma once +#include + #include +#include #include "coda_oss/cstddef.h" #include "coda_oss/CPlusPlus.h" @@ -41,6 +44,7 @@ namespace std // This is slightly uncouth: we're not supposed to augment "std". { using coda_oss::byte; } +static_assert(!std::is_same::value, "'std::byte' should be a unique type."); #endif // !CODA_OSS_NO_std_byte #endif // CODA_OSS_std_cstddef_INCLUDED_ \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/std/include/std/span b/externals/coda-oss/modules/c++/std/include/std/span index ffa0d1df9..819befe15 100644 --- a/externals/coda-oss/modules/c++/std/include/std/span +++ b/externals/coda-oss/modules/c++/std/include/std/span @@ -39,6 +39,9 @@ namespace std // This is slightly uncouth: we're not supposed to augment "std". { using coda_oss::span; + + using coda_oss::as_bytes; + using coda_oss::as_writable_bytes; } #endif // CODA_OSS_DEFINE_std_span_ diff --git a/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h b/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h new file mode 100644 index 000000000..d8145dcce --- /dev/null +++ b/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h @@ -0,0 +1,118 @@ +/* ========================================================================= + * This file is part of sys-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * (C) Copyright 2023, Maxar Technologies, Inc. + * + * sys-c++ 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. + * + * This program 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 this program; If not, + * see . + * + */ + +#ifndef CODA_OSS_sys_ByteSwap_h_INCLUDED_ +#define CODA_OSS_sys_ByteSwap_h_INCLUDED_ +#pragma once + +#include +#include + +#include +#include + +#include "config/Exports.h" + +#include "ByteSwapValue.h" +#include "Runnable.h" + +namespace sys +{ +/*! + * Swap bytes in-place. Note that a complex pixel + * is equivalent to two floats so elemSize and numElems + * must be adjusted accordingly. + * + * \param [inout] buffer to transform + * \param elemSize + * \param numElems + */ +coda_oss::span CODA_OSS_API byteSwap(coda_oss::spanbuffer, size_t elemSize); +void CODA_OSS_API byteSwap(void* buffer, size_t elemSize, size_t numElems); + +/*! + * Swap bytes into output buffer. Note that a complex pixel + * is equivalent to two floats so elemSize and numElems + * must be adjusted accordingly. + * + * \param buffer to transform + * \param elemSize + * \param numElems + * \param[out] outputBuffer buffer to write swapped elements to + */ +coda_oss::span CODA_OSS_API byteSwap(coda_oss::span buffer, + size_t elemSize, coda_oss::span outputBuffer); +void CODA_OSS_API byteSwap(const void* buffer, size_t elemSize, size_t numElems, void* outputBuffer); + +struct ByteSwapRunnable final : public sys::Runnable +{ + ByteSwapRunnable(void* buffer, size_t elemSize, size_t startElement, size_t numElements) : + mBuffer(static_cast(buffer) + startElement * elemSize), + mElemSize(elemSize), mNumElements(numElements) + { + } + void run() override + { + byteSwap(mBuffer, mElemSize, mNumElements); + } + + virtual ~ByteSwapRunnable() = default; + ByteSwapRunnable(const ByteSwapRunnable&) = delete; + ByteSwapRunnable& operator=(const ByteSwapRunnable&) = delete; + ByteSwapRunnable(ByteSwapRunnable&&) = delete; + ByteSwapRunnable& operator=(ByteSwapRunnable&&) = delete; + +private: + void* const mBuffer; + const size_t mElemSize; + const size_t mNumElements; +}; + +struct ByteSwapCopyRunnable final : public sys::Runnable +{ + ByteSwapCopyRunnable(const void* buffer, size_t elemSize, size_t startElement, size_t numElements, void* outputBuffer) : + mBuffer(static_cast(buffer) + startElement * elemSize), + mElemSize(elemSize), mNumElements(numElements), + mOutputBuffer(static_cast(outputBuffer) + startElement * elemSize) + { + } + void run() override + { + byteSwap(mBuffer, mElemSize, mNumElements, mOutputBuffer); + } + + virtual ~ByteSwapCopyRunnable() = default; + ByteSwapCopyRunnable(const ByteSwapCopyRunnable&) = delete; + ByteSwapCopyRunnable& operator=(const ByteSwapCopyRunnable&) = delete; + ByteSwapCopyRunnable(ByteSwapCopyRunnable&&) = delete; + ByteSwapCopyRunnable& operator=(ByteSwapCopyRunnable&&) = delete; + +private: + const void* const mBuffer; + const size_t mElemSize; + const size_t mNumElements; + void* const mOutputBuffer; +}; + +} +#endif // CODA_OSS_sys_ByteSwap_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h b/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h new file mode 100644 index 000000000..57cffe3f3 --- /dev/null +++ b/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h @@ -0,0 +1,196 @@ +/* ========================================================================= + * This file is part of sys-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * (C) Copyright 2021, Maxar Technologies, Inc. + * + * sys-c++ 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. + * + * This program 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 this program; If not, + * see . + * + */ + +#ifndef CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ +#define CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ +#pragma once + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config/Exports.h" + +#include "Span.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace sys +{ + /*! + * Swap bytes for a single value into output buffer. API is `span` rather than `void*` since + * for a single value we know the size. These "low level" routines may be less efficient than + * the templates since it's not possible to specialize on a specific size. + * + * \param buffer to transform + * \param[out] outputBuffer buffer to write swapped elements to + */ + coda_oss::span CODA_OSS_API byteSwap( + coda_oss::span pIn, coda_oss::span outPtr); + + namespace details + { + template + inline auto swapUIntBytes(coda_oss::span inBytes, coda_oss::span outBytes, + std::nothrow_t) noexcept + { + static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); + assert(sizeof(TUInt) == inBytes.size()); + assert(inBytes.size() == outBytes.size()); + + const void* const pIn_ = inBytes.data(); + auto const pIn = static_cast(pIn_); + void* const pOut_ = outBytes.data(); + auto const pOut = static_cast(pOut_); + + *pOut = coda_oss::byteswap(*pIn); // at long last, swap the bytes + + // Give the raw byte-swapped bytes back to the caller for easy serialization + return as_bytes(pOut); + } + template + inline auto swapUIntBytes(coda_oss::span inBytes, coda_oss::span outBytes) + { + if (sizeof(TUInt) != inBytes.size()) + { + throw std::invalid_argument("'inBytes.size() != sizeof(TUInt)"); + } + if (inBytes.size() != outBytes.size()) + { + throw std::invalid_argument("'inBytes.size() != outBytes.size()"); + } + return swapUIntBytes(inBytes, outBytes, std::nothrow); + } + + // This is a template so that we can have specializations for different sizes. + // By specializing on `size_t`, a `float` can be "cast" to `uint32_t` (via + // `std::byte`) for byte-swapping. + template + inline auto swapBytes(coda_oss::span inBytes, coda_oss::span outBytes) + { + if (elemSize != inBytes.size()) + { + throw std::invalid_argument("'inBytes.size() != elemSize"); + } + return sys::byteSwap(inBytes, outBytes); // size that wasn't specialized + } + + // avoid copy-paste errors + #define CODA_OSS_define_swapBytes_specialization_(T) template <> inline auto swapBytes \ + (coda_oss::span inBytes, coda_oss::span outBytes) { return swapUIntBytes(inBytes, outBytes); } + CODA_OSS_define_swapBytes_specialization_(uint8_t) // no `;`, it's not needed and generates a -Wpedantic warning + CODA_OSS_define_swapBytes_specialization_(uint16_t) + CODA_OSS_define_swapBytes_specialization_(uint32_t) + CODA_OSS_define_swapBytes_specialization_(uint64_t) + #undef CODA_OSS_define_swapBytes_specialization_ + + template + inline constexpr bool is_byte_swappable() noexcept + { + // Trying to byte-swap anything other than integers is likely to cause + // problems (or at least confusion): + // * `struct`s have padding that should be ignored. + // * each individual member of a `struct` should be byte-swaped + // * byte-swaped `float` or `double` bits are nonsense + return (std::is_integral::value || std::is_enum::value) || !std::is_compound::value; + } + } + + /*! + * Function to swap one element irrespective of size. + * Returns the raw byte-swapped bytes for easy serialization. + */ + template + inline auto swapBytes(coda_oss::span inBytes, coda_oss::span outBytes) + { + static_assert(details::is_byte_swappable(), "T should not be a 'struct'"); + return details::swapBytes(inBytes, outBytes); + } + template + inline auto swapBytes(T in, coda_oss::span outBytes) + { + return swapBytes(as_bytes(in), outBytes); + } + template + inline auto swapBytes(T in) + { + std::vector retval; + retval.resize(sizeof(T)); + std::ignore = swapBytes(in, make_span(retval)); + return retval; + } + + // Reverse the above: turn `span` back to T after byte-swapping + template + inline auto swapBytes(coda_oss::span in) + { + // Don't want to cast the swapped bytes in `in` to T* as they might not be valid; + // e.g., a byte-swapped `float` could be garbage. + T retval; + swapBytes(in, as_writable_bytes(retval)); + return retval; + } + + /*! + * Function to swap one element irrespective of size. The inplace + * buffer function should be preferred. + * + * To specialize complex float, first include the complex library + * \code + #include + * \endcode + * + * Then put an overload in as specified below: + * \code + template std::complex byteSwap(std::complex val) + { + std::complex out(byteSwap(val.real()), + byteSwap(val.imag())); + return out; + } + * \endcode + * + */ + template inline T byteSwap(T val) + { + T out; + std::ignore = swapBytes(val, as_writable_bytes(out)); + return out; + } +} +#endif // CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/sys/include/sys/Conf.h b/externals/coda-oss/modules/c++/sys/include/sys/Conf.h index 28d396c5c..df36708bb 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/Conf.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/Conf.h @@ -66,23 +66,16 @@ #include #include #include -#include -#ifdef __GNUC__ -#include // "These functions are GNU extensions." -#endif #include #include #include #include #include -#include -#include -#include "coda_oss/span.h" -#include #include "str/Format.h" #include "sys/TimeStamp.h" +#include "sys/ByteSwap.h" /* Dance around the compiler to figure out */ @@ -205,205 +198,9 @@ namespace sys * RISC architectures we are big-endian. */ bool CODA_OSS_API isBigEndianSystem(); + bool CODA_OSS_API isLittleEndianSystem(); - /*! - * Swap bytes in-place. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param [inout] buffer to transform - * \param elemSize - * \param numElems - */ - void CODA_OSS_API byteSwap_(void* buffer, size_t elemSize, size_t numElems); - template - inline void byteSwap(T* buffer, size_t elemSize, size_t numElems) - { - // Trying to byte-swap structs can result in garbage because of padding. - static_assert(std::is_arithmetic::value || std::is_enum::value, "can only byte-swap numbers."); - if (elemSize != sizeof(T)) - { - throw std::invalid_argument("sizeof(T) != elemSize"); - } - byteSwap_(buffer, elemSize, numElems); - } - template - inline void byteSwap(coda_oss::span buffer) - { - constexpr auto elemSize = sizeof(T); - const auto numElems = buffer.size(); - byteSwap(buffer.data(), elemSize, numElems); - } - template - inline void byteSwap(coda_oss::span> buffer) - { - void* pBuffer = buffer.data(); - const coda_oss::span buffer_(static_cast(pBuffer), buffer.size() * 2); // real and imag - byteSwap(buffer_); - } - - inline void byteSwapV(void* buffer, unsigned short elemSize, size_t numElems) // existing API - { - byteSwap_(buffer, elemSize, numElems); - } - - /*! - * Swap bytes into output buffer. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param buffer to transform - * \param elemSize - * \param numElems - * \param[out] outputBuffer buffer to write swapped elements to - */ - void CODA_OSS_API byteSwap_(const void* buffer, size_t elemSize, size_t numElems, void* outputBuffer); - template - inline void byteSwap(const T* buffer, size_t elemSize, size_t numElems, - U* outputBuffer) // e.g., "unsigned int" && "int" - { - // Trying to byte-swap structs can result in garbage because of padding. - static_assert(std::is_arithmetic::value || std::is_enum::value, "can only byte-swap numbers."); - static_assert(std::is_arithmetic::value || std::is_enum::value, "can only byte-swap numbers."); - static_assert(sizeof(T) > 1, "byte-swapping a single-byte value makes no sense."); - //static_assert(sizeof(T) == sizeof(U), "sizeof(T) != sizeof(U)."); // outputBuffer could be std::byte - if (elemSize != sizeof(T)) - { - throw std::invalid_argument("sizeof(T) != elemSize"); - } - byteSwap_(buffer, elemSize, numElems, outputBuffer); - } - template - inline void byteSwap(coda_oss::span buffer, coda_oss::span outputBuffer) // e.g., "unsigned int" && "int" - { - const auto numElems = buffer.size(); - if (numElems != outputBuffer.size()) - { - throw std::invalid_argument("buffer.size() != outputBuffer.size()"); - } - constexpr auto elemSize = sizeof(T); - byteSwap(buffer.data(), elemSize, numElems, outputBuffer.data()); - } - template - inline void byteSwap(coda_oss::span> buffer, coda_oss::span> outputBuffer) - { - const void* pBuffer = buffer.data(); - const coda_oss::span buffer_(static_cast(pBuffer), buffer.size() * 2); // real and imag - void* pOutputBuffer = outputBuffer.data(); - const coda_oss::span outputBuffer_(static_cast(pOutputBuffer), outputBuffer.size() * 2); // real and imag - - byteSwap(buffer_, outputBuffer_); - } - - inline void byteSwapV(const void* buffer, unsigned short elemSize, size_t numElems, void* outputBuffer) // existing API - { - byteSwap_(buffer, elemSize, numElems, outputBuffer); - } - - /*! - * Function to swap one element irrespective of size. The inplace - * buffer function should be preferred. - * - * To specialize complex float, first include the complex library - * \code - #include - * \endcode - * - * Then put an overload in as specified below: - * \code - template std::complex byteSwap(std::complex val) - { - std::complex out(byteSwap(val.real()), - byteSwap(val.imag())); - return out; - } - * \endcode - * - */ - template inline T byteSwap_(T val) - { - // Trying to byte-swap structs can result in garbage because of padding. - static_assert(std::is_arithmetic::value || std::is_enum::value, "can only byte-swap numbers"); - - constexpr auto size = sizeof(T); - T out; - - unsigned char* cOut = reinterpret_cast(&out); - unsigned char* cIn = reinterpret_cast(&val); - for (size_t i = 0, j = size - 1; i < j; ++i, --j) - { - cOut[i] = cIn[j]; - cOut[j] = cIn[i]; - } - return out; - } - template inline T byteSwap(T val) - { - return byteSwap_(val); - } - inline uint8_t byteSwap(uint8_t val) - { - return val; // no-op - } -#if defined(_MSC_VER) - // These routines should geneerate a single instruction; see https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/ - inline uint16_t byteSwap(uint16_t val) - { - return _byteswap_ushort(val); - } - inline uint32_t byteSwap(uint32_t val) - { - return _byteswap_ulong(val); - } - inline uint64_t byteSwap(uint64_t val) - { - return _byteswap_uint64(val); - } -#elif defined(__GNUC__) - inline uint16_t byteSwap(uint16_t val) - { - return bswap_16(val); - } - inline uint32_t byteSwap(uint32_t val) - { - return bswap_32(val); - } - inline uint64_t byteSwap(uint64_t val) - { - return bswap_64(val); - } -#endif - template - inline T byteSwapValue_(T val) - { - static_assert(sizeof(T) > 1, "byte-swapping a single-byte value makes no sense."); - static_assert(sizeof(T) == sizeof(TUInt), "sizeof(T) != sizeof()"); - static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); - - const void* pVal = &val; - const auto pUInt = static_cast(pVal); - const auto result = byteSwap(*pUInt); - - const void* pResult = &result; - const auto pRetval = static_cast(pResult); - return *pRetval; - } - inline float byteSwap(float val) - { - return byteSwapValue_(val); - } - inline double byteSwap(double val) - { - return byteSwapValue_(val); - } - template - inline std::complex byteSwap(std::complex v) - { - std::complex retval{byteSwap(v.real()), byteSwap(v.imag())}; - return retval; - } - /*! * Method to create a block of memory on an alignment * boundary specified by the user. @@ -459,7 +256,6 @@ namespace sys #endif } - } // https://en.wikipedia.org/wiki/Year_2038_problem diff --git a/externals/coda-oss/modules/c++/sys/include/sys/Span.h b/externals/coda-oss/modules/c++/sys/include/sys/Span.h new file mode 100644 index 000000000..23b72d02c --- /dev/null +++ b/externals/coda-oss/modules/c++/sys/include/sys/Span.h @@ -0,0 +1,188 @@ +/* ========================================================================= + * This file is part of sys-c++ + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * (C) Copyright 2023, Maxar Technologies, Inc. + * + * sys-c++ 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. + * + * This program 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 this program; If not, + * see . + * + */ + +#ifndef CODA_OSS_sys_Span_h_INCLUDED_ +#define CODA_OSS_sys_Span_h_INCLUDED_ +#pragma once + +#include +#include +#include +#include + +namespace sys // not "mem", it depends on sys. +{ + +// Creating a `span` is verbose w/o deduction guidelines in C++17. +// Some overloads to ease the pain. +template +inline coda_oss::span make_span(const T* ptr, size_t sz) noexcept +{ + return coda_oss::span(ptr, sz); +} +template +inline coda_oss::span make_const_span(T* ptr, size_t sz) noexcept +{ + return coda_oss::span(ptr, sz); +} +template +inline coda_oss::span make_writable_span(T* ptr, size_t sz) noexcept // c.f., as_writable_bytes() +{ + return coda_oss::span(ptr, sz); +} +template +inline coda_oss::span make_span(T* ptr, size_t sz) noexcept +{ + return make_writable_span(ptr, sz); +} + +template +inline auto make_span(const void* ptr, size_t sz) noexcept +{ + return make_span(static_cast(ptr), sz); +} +template +inline auto make_const_span(void* ptr, size_t sz) noexcept +{ + return make_const_span(static_cast(ptr), sz); +} +template +inline auto make_span(void* ptr, size_t sz) noexcept +{ + return make_writable_span(static_cast(ptr), sz); +} + +template +inline auto make_const_span(coda_oss::span v) noexcept // turn span into span +{ + return make_const_span(v.data(), v.size()); +} + +template +inline auto make_span(const std::vector& v) noexcept +{ + return make_span(v.data(), v.size()); +} +template +inline auto make_const_span(std::vector& v) noexcept +{ + return make_const_span(v.data(), v.size()); +} +template +inline auto make_span(std::vector& v) noexcept +{ + return make_writable_span(v.data(), v.size()); +} + +template +inline auto make_span(const std::array& v) noexcept +{ + return make_span(v.data(), v.size()); +} +template +inline auto make_const_span(std::array& v) noexcept +{ + return make_const_span(v.data(), v.size()); +} +template +inline auto make_span(std::array& v) noexcept +{ + return make_writable_span(v.data(), v.size()); +} + +template +inline auto make_span(const T (&a)[N]) noexcept +{ + return make_span(a, N); +} +template +inline auto make_const_span(T (&a)[N]) noexcept +{ + return make_const_span(a, N); +} +template +inline auto make_span(T (&a)[N]) noexcept +{ + return make_writable_span(a, N); +} + +// Calling as_bytes() or as_writable_bytes() requires a span, which as +// noted above is a nuisance to create w/o C++17 +template +inline auto as_bytes(const T* ptr, size_t sz) noexcept +{ + return coda_oss::as_bytes(make_span(ptr, sz)); +} +template +inline auto as_writable_bytes(T* ptr, size_t sz) noexcept +{ + return coda_oss::as_writable_bytes(make_writable_span(ptr, sz)); +} + +template +inline auto as_bytes(const std::vector& v) noexcept +{ + return as_bytes(v.data(), v.size()); +} +template +inline auto as_writable_bytes(std::vector& v) noexcept +{ + return as_writable_bytes(v.data(), v.size()); +} + +template +inline auto as_bytes(const std::array& v) noexcept +{ + return as_bytes(v.data(), v.size()); +} +template +inline auto as_writable_bytes(std::array& v) noexcept +{ + return as_writable_bytes(v.data(), v.size()); +} + +template +inline auto as_bytes(const T (&a)[N]) noexcept +{ + return as_bytes(a, N); +} +template +inline auto as_writable_bytes(T (&a)[N]) noexcept +{ + return as_writable_bytes(a, N); +} + +// "cast" a single value to bytes +template +inline auto as_bytes(const T& v) noexcept +{ + return as_bytes(&v, 1); +} +template +inline auto as_writable_bytes(T& v) noexcept +{ + return as_writable_bytes(&v, 1); +} + +} +#endif // CODA_OSS_sys_Span_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/sys/source/Conf.cpp b/externals/coda-oss/modules/c++/sys/source/Conf.cpp index 414374d5a..bf29dd69b 100644 --- a/externals/coda-oss/modules/c++/sys/source/Conf.cpp +++ b/externals/coda-oss/modules/c++/sys/source/Conf.cpp @@ -19,6 +19,7 @@ * see . * */ +#include "sys/Conf.h" #include @@ -26,49 +27,100 @@ #include #include #include - -#include "sys/Conf.h" #include "coda_oss/bit.h" +#include "coda_oss/cstddef.h" +#include "coda_oss/span.h" -using endian = coda_oss::endian; +#include "sys/Span.h" // https://en.cppreference.com/w/cpp/types/endian -inline bool is_big_endian() +using endian = coda_oss::endian; +template +inline bool is_big_endian_() +{ + throw std::logic_error("Mixed-endian not supported."); +} +template<> +inline constexpr bool is_big_endian_() +{ + return true; +} +template <> +inline constexpr bool is_big_endian_() +{ + return false; +} +constexpr inline bool is_big_endian() +{ + return is_big_endian_(); +} + +// Want to explicitly test against both endian::bit and endian::little; i.e., +// because of "mixed" endianness, little may not the same as !big +template +inline bool is_little_endian_() { - auto endianness = endian::native; // "conditional expression is constant" - if (endianness == endian::big) - { - return true; - } - if (endianness == endian::little) - { - return false; - } throw std::logic_error("Mixed-endian not supported."); } +template <> +inline constexpr bool is_little_endian_() +{ + return false; +} +template <> +inline constexpr bool is_little_endian_() +{ + return true; +} +constexpr inline bool is_little_endian() +{ + return is_little_endian_(); +} + constexpr inline bool is_big_or_little_endian() { - return (endian::native == endian::big) || (endian::native == endian::little) ? true : false; + return is_big_endian() || is_little_endian(); } -inline bool isBigEndianSystem() +inline bool testIsBigEndianSystem() { // This is an endian test int intVal = 1; unsigned char* endianTest = (unsigned char*)&intVal; return endianTest[0] != 1; } -bool sys::isBigEndianSystem() +inline auto isBigEndianSystem_() { static_assert(is_big_or_little_endian(), "Mixed-endian not supported."); - const auto retval = ::isBigEndianSystem(); + const auto retval = testIsBigEndianSystem(); if (retval != is_big_endian()) { throw std::logic_error("endian values don't agree!"); } return retval; } - +inline auto isLittleEndianSystem_() +{ + static_assert(is_big_or_little_endian(), "Mixed-endian not supported."); + const auto retval = !testIsBigEndianSystem(); + if (retval != is_little_endian()) + { + throw std::logic_error("endian values don't agree!"); + } + return retval; +} +bool sys::isBigEndianSystem() +{ + auto const retval = isBigEndianSystem_(); + assert(!retval == isLittleEndianSystem_()); + return retval; +} +bool sys::isLittleEndianSystem() +{ + auto const retval = isLittleEndianSystem_(); + assert(!retval == isBigEndianSystem_()); + return retval; +} /*! * Swap bytes in-place. Note that a complex pixel @@ -79,9 +131,67 @@ bool sys::isBigEndianSystem() * \param elemSize * \param numElems */ -void sys::byteSwap_(void* buffer, size_t elemSize, size_t numElems) +template +inline void byteSwap_n_(void *buffer_, size_t numElems) { - byteSwap_(buffer, elemSize, numElems, buffer); + static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); + const auto buffer = sys::make_span(buffer_, numElems); + assert(buffer.size_bytes() == sizeof(TUInt) * numElems); + + for (auto& v : buffer) + { + v = sys::byteSwap(v); + } +} +template +inline void byteSwap_n(void *buffer, size_t elemSize, size_t numElems) +{ + if (sizeof(TUInt) != elemSize) + { + throw std::invalid_argument("'elemSize' != sizeof(TUInt)"); + } + byteSwap_n_(buffer, numElems); +} +void sys::byteSwap(void* buffer, size_t elemSize, size_t numElems) +{ + if ((buffer == nullptr) || (elemSize < 2) || (numElems == 0)) + return; + + switch (elemSize) + { + case sizeof(uint16_t): return byteSwap_n(buffer, elemSize, numElems); + case sizeof(uint32_t): return byteSwap_n(buffer, elemSize, numElems); + case sizeof(uint64_t): return byteSwap_n(buffer, elemSize, numElems); + default: break; + } + + auto const bufferPtr = static_cast(buffer); + const auto half = elemSize >> 1; + size_t offset = 0, innerOff = 0, innerSwap = 0; + for (size_t i = 0; i < numElems; ++i, offset += elemSize) + { + for (size_t j = 0; j < half; ++j) + { + innerOff = offset + j; + innerSwap = offset + elemSize - 1 - j; + + std::swap(bufferPtr[innerOff], bufferPtr[innerSwap]); + } + } +} +coda_oss::span sys::byteSwap(coda_oss::span buffer, size_t elemSize) +{ + if ((buffer.size() == 0) || (elemSize < 2)) + return sys::make_const_span(buffer); + + size_t const numElems = buffer.size() / elemSize; + if ((numElems * elemSize) != buffer.size()) + { + throw std::invalid_argument("'buffer' is not a multiple of 'elemSize'"); + } + + byteSwap(buffer.data(), elemSize, numElems); + return sys::make_const_span(buffer); } /*! @@ -95,61 +205,106 @@ void sys::byteSwap_(void* buffer, size_t elemSize, size_t numElems) * \param[out] outputBuffer buffer to write swapped elements to */ template -inline void byteSwap_n(const void *buffer_, size_t elemSize, size_t numElems, void *outputBuffer_) +inline void byteSwap_n_(const void *buffer_, size_t numElems, void *outputBuffer_) { static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); - using value_type = TUInt; - assert(sizeof(value_type) == elemSize); - std::ignore = elemSize; - const coda_oss::span buffer(static_cast(buffer_), numElems); - assert(buffer.size_bytes() == elemSize * numElems); - const coda_oss::span outputBuffer(static_cast(outputBuffer_), numElems); + const auto buffer = sys::make_span(buffer_, numElems); + assert(buffer.size_bytes() == sizeof(TUInt) * numElems); + const auto outputBuffer = sys::make_span(outputBuffer_, numElems); - std::transform(buffer.begin(), buffer.end(), outputBuffer.begin(), [](const auto& v) { return sys::byteSwap(v); }); + const auto byteSwap = [](const auto& v) { return sys::byteSwap(v); }; + std::transform(buffer.begin(), buffer.end(), outputBuffer.begin(), byteSwap); } - -void sys::byteSwap_(const void* buffer, - size_t elemSize, - size_t numElems, - void* outputBuffer) +template +inline void byteSwap_n(const void *buffer, size_t elemSize, size_t numElems, void *outputBuffer) { - if (!numElems || !buffer || !outputBuffer) - { - return; - } - - if (elemSize == 2) + if (sizeof(TUInt) != elemSize) { - return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + throw std::invalid_argument("'elemSize' != sizeof(TUInt)"); } - if (elemSize == 4) + byteSwap_n_(buffer, numElems, outputBuffer); +} +void sys::byteSwap(const void* buffer, size_t elemSize, size_t numElems, void* outputBuffer) +{ + if ((numElems == 0) || (buffer == nullptr) || (outputBuffer == nullptr)) { - return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + return; } - if (elemSize == 8) + + switch (elemSize) { - return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + case 1: std::ignore = memcpy(outputBuffer, buffer, elemSize * numElems); return; + case 2: return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + case 4: return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + case 8: return byteSwap_n(buffer, elemSize, numElems, outputBuffer); + default: break; } - const sys::byte* bufferPtr = static_cast(buffer); - sys::byte* outputBufferPtr = static_cast(outputBuffer); + auto const bufferPtr = static_cast(buffer); + auto const outputBufferPtr = static_cast(outputBuffer); const auto half = elemSize >> 1; size_t offset = 0; - for (size_t ii = 0; ii < numElems; ++ii, offset += elemSize) { - for (unsigned short jj = 0; jj < half; ++jj) + for (size_t jj = 0; jj < half; ++jj) { const size_t innerOff = offset + jj; const size_t innerSwap = offset + elemSize - 1 - jj; - // could be the same buffer, see overload above - const auto bufferInner = bufferPtr[innerSwap]; - const auto bufferOff = bufferPtr[innerOff]; - outputBufferPtr[innerOff] = bufferInner; - outputBufferPtr[innerSwap] = bufferOff; + outputBufferPtr[innerOff] = bufferPtr[innerSwap]; + outputBufferPtr[innerSwap] = bufferPtr[innerOff]; } } } +coda_oss::span sys::byteSwap(coda_oss::span buffer, + size_t elemSize, coda_oss::span outputBuffer) +{ + if ((buffer.size() == 0) || (outputBuffer.size() == 0)) + { + return sys::make_const_span(outputBuffer); + } + + size_t const numElems = buffer.size() / elemSize; + if ((numElems * elemSize) != buffer.size()) + { + throw std::invalid_argument("'buffer' is not a multiple of 'elemSize'"); + } + if (buffer.size() != outputBuffer.size()) + { + throw std::invalid_argument("'buffer' and 'outputBuffer' are different sizes'"); + } + + byteSwap(buffer.data(), elemSize, numElems, outputBuffer.data()); + return sys::make_const_span(outputBuffer); +} + + coda_oss::span sys::byteSwap( + coda_oss::span inPtr, + coda_oss::span outPtr) +{ + if (inPtr.size() != outPtr.size()) + { + throw std::invalid_argument("'size of byte buffers must match"); + } + + const auto elemSize = inPtr.size(); + switch (elemSize) + { + case sizeof(uint8_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); + case sizeof(uint16_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); + case sizeof(uint32_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); + case sizeof(uint64_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); + default: break; + } + + for (size_t ii = 0, jj = elemSize - 1; ii < jj; ++ii, --jj) + { + outPtr[ii] = inPtr[jj]; + outPtr[jj] = inPtr[ii]; + } + + // Give the raw byte-swapped bytes back to the caller for easy serialization + return make_const_span(outPtr); +} diff --git a/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp b/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp index 6ef347cb3..954872bb0 100644 --- a/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp +++ b/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp @@ -22,14 +22,14 @@ #include "TestCase.h" -#include - #include +#include #include // std::endian -#include // std::byte +#include #include #include +#include TEST_CASE(testEndianness) { @@ -72,29 +72,32 @@ TEST_CASE(testEndianness) } } -TEST_CASE(testByteSwap) +static std::vector make_origValues(size_t NUM_PIXELS) { ::srand(334); - static const size_t NUM_PIXELS = 10000; - std::vector origValues(NUM_PIXELS); + std::vector retval(NUM_PIXELS); for (size_t ii = 0; ii < NUM_PIXELS; ++ii) { const auto value = static_cast(::rand()) / RAND_MAX * - std::numeric_limits::max(); - origValues[ii] = static_cast(value); + std::numeric_limits::max(); + retval[ii] = static_cast(value); } + return retval; +} - // Byte swap the old-fashioned way - std::vector values1(origValues); - sys::byteSwap(&values1[0], sizeof(sys::Uint64_T), NUM_PIXELS); +TEST_CASE(testByteSwap) +{ + constexpr size_t NUM_PIXELS = 10000; + const auto origValues = make_origValues(NUM_PIXELS); + // Byte swap the old-fashioned way + auto values1(origValues); + sys::byteSwap(values1.data(), sizeof(uint64_t), NUM_PIXELS); // Byte swap into output buffer - const std::vector values2(origValues); - std::vector swappedValues2(values2.size()); - sys::byteSwap(&values2[0], sizeof(sys::Uint64_T), NUM_PIXELS, - &swappedValues2[0]); + std::vector swappedValues2(origValues.size()); + sys::byteSwap(origValues.data(), sizeof(uint64_t), NUM_PIXELS, swappedValues2.data()); // Everything should match for (size_t ii = 0; ii < NUM_PIXELS; ++ii) @@ -103,6 +106,7 @@ TEST_CASE(testByteSwap) } } +// 0xnn is an `int` which can't be used to initialize std::byte w/o a cast #define CODA_OSS_define_byte(v) constexpr static std::byte v = static_cast(0 ## v) CODA_OSS_define_byte(x00); CODA_OSS_define_byte(x11); @@ -127,263 +131,133 @@ static constexpr std::byte four_bytes[]{x00, x11, xEE, xFF}; static constexpr std::byte eight_bytes[]{x00, x11, x22, x33, xCC, xDD, xEE, xFF}; static constexpr std::byte sixteen_bytes[]{x00, x11, x22, x33, x44, x55, x66, x77, x88, x99, xAA, xBB, xCC, xDD, xEE, xFF}; -TEST_CASE(testByteSwapUInt16) +template +static void testByteSwapValues_(const std::string& testName, const void* pBytes) { - const void* pBytes = &(two_bytes[0]); - auto pUInt16 = static_cast(pBytes); - auto swap = sys::byteSwap(*pUInt16); - TEST_ASSERT_NOT_EQ(*pUInt16, swap); - const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - TEST_ASSERT(pResultBytes[0] == two_bytes[1]); - TEST_ASSERT(pResultBytes[1] == two_bytes[0]); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pUInt16, swap); - - // array swap from input to output - pBytes = &(sixteen_bytes[0]); - const auto buffer = static_cast(pBytes); - std::array outputBuffer; - sys::byteSwap(buffer, sizeof(uint16_t), outputBuffer.size(), outputBuffer.data()); - for (auto&& v : outputBuffer) - { - swap = sys::byteSwap(v); - TEST_ASSERT_NOT_EQ(v, swap); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(v, swap); - } + auto pUInt = static_cast(pBytes); + auto swap = sys::byteSwap(*pUInt); + TEST_ASSERT_NOT_EQ(*pUInt, swap); - // in-place swap - sys::byteSwap(outputBuffer.data(), sizeof(uint16_t), outputBuffer.size()); - pBytes = outputBuffer.data(); - pResultBytes = static_cast(pBytes); - for (size_t i=0; i<16; i++) - { - TEST_ASSERT(pResultBytes[i] == sixteen_bytes[i]); - } -} - -TEST_CASE(testByteSwapUInt32) -{ - const void* pBytes = &(four_bytes[0]); - auto pUInt32 = static_cast(pBytes); - auto swap = sys::byteSwap(*pUInt32); - TEST_ASSERT_NOT_EQ(*pUInt32, swap); const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - TEST_ASSERT(pResultBytes[0] == four_bytes[3]); - TEST_ASSERT(pResultBytes[1] == four_bytes[2]); - TEST_ASSERT(pResultBytes[2] == four_bytes[1]); - TEST_ASSERT(pResultBytes[3] == four_bytes[0]); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pUInt32, swap); - - // array swap from input to output - pBytes = &(sixteen_bytes[0]); - const auto buffer = static_cast(pBytes); - std::array outputBuffer; - sys::byteSwap(buffer, sizeof(uint32_t), outputBuffer.size(), outputBuffer.data()); - for (auto&& v : outputBuffer) - { - swap = sys::byteSwap(v); - TEST_ASSERT_NOT_EQ(v, swap); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(v, swap); - } - - // in-place swap - sys::byteSwap(outputBuffer.data(), sizeof(uint32_t), outputBuffer.size()); - pBytes = outputBuffer.data(); - pResultBytes = static_cast(pBytes); - for (size_t i=0; i<16; i++) + auto const pResultBytes = static_cast(pResult_); + auto const pValueBytes = static_cast(pBytes); + for (size_t i = 0, j = sizeof(TUInt); i < sizeof(TUInt) && j > 0; i++, j--) { - TEST_ASSERT(pResultBytes[i] == sixteen_bytes[i]); + TEST_ASSERT(pResultBytes[i] == pValueBytes[j-1]); } -} -TEST_CASE(testByteSwapUInt64) -{ - const void* pBytes = &(eight_bytes[0]); - auto pUInt64 = static_cast(pBytes); - auto swap = sys::byteSwap(*pUInt64); - TEST_ASSERT_NOT_EQ(*pUInt64, swap); - const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - TEST_ASSERT(pResultBytes[0] == eight_bytes[7]); - TEST_ASSERT(pResultBytes[1] == eight_bytes[6]); - TEST_ASSERT(pResultBytes[2] == eight_bytes[5]); - TEST_ASSERT(pResultBytes[3] == eight_bytes[4]); - TEST_ASSERT(pResultBytes[4] == eight_bytes[3]); - TEST_ASSERT(pResultBytes[5] == eight_bytes[2]); - TEST_ASSERT(pResultBytes[6] == eight_bytes[1]); - TEST_ASSERT(pResultBytes[7] == eight_bytes[0]); swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pUInt64, swap); - - // array swap from input to output - pBytes = &(sixteen_bytes[0]); - const auto buffer = static_cast(pBytes); - std::array outputBuffer; - sys::byteSwap(buffer, sizeof(uint64_t), outputBuffer.size(), outputBuffer.data()); - for (auto&& v : outputBuffer) - { - swap = sys::byteSwap(v); - TEST_ASSERT_NOT_EQ(v, swap); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(v, swap); - } + TEST_ASSERT_EQ(*pUInt, swap); - // in-place swap - sys::byteSwap(outputBuffer.data(), sizeof(uint64_t), outputBuffer.size()); - pBytes = outputBuffer.data(); - pResultBytes = static_cast(pBytes); - for (size_t i=0; i<16; i++) - { - TEST_ASSERT(pResultBytes[i] == sixteen_bytes[i]); - } -} + // swap as an "array" of one value + sys::byteSwap(pUInt, sizeof(TUInt), 1, &swap); + TEST_ASSERT_NOT_EQ(*pUInt, swap); + sys::byteSwap(&swap, sizeof(TUInt), 1); // swap back + TEST_ASSERT_EQ(*pUInt, swap); -TEST_CASE(testByteSwapFloat) -{ - static_assert(sizeof(float) == sizeof(uint32_t), "sizeof(float) != sizeof(uint32_t)"); - - const float v = 3.141592654f; - const void* pVoid = &v; - auto pFloat = static_cast(pVoid); - auto swap = sys::byteSwap(*pFloat); - // The swapped bits could be nonsense as a `float`, so comparing might not work - //TEST_ASSERT_NOT_EQ(*pFloat, swap); - const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - auto pValueBytes = static_cast(pVoid); - TEST_ASSERT(pResultBytes[0] == pValueBytes[3]); - TEST_ASSERT(pResultBytes[1] == pValueBytes[2]); - TEST_ASSERT(pResultBytes[2] == pValueBytes[1]); - TEST_ASSERT(pResultBytes[3] == pValueBytes[0]); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pFloat, swap); - - // array swap from input to output - const float values[] = {1.0f, 2.0f, 3.0f, 4.0f}; - pVoid = &(values[0]); - const auto buffer = static_cast(pVoid); - std::array outputBuffer; - sys::byteSwap(buffer, sizeof(float), outputBuffer.size(), outputBuffer.data()); - for (size_t i = 0; i 0; i++, j--) { - // can't test swapped bytes against anything; might not be a valid `float` - swap = sys::byteSwap(outputBuffer[i]); - TEST_ASSERT_EQ(values[i], swap); - } - - // in-place swap - sys::byteSwap(outputBuffer.data(), sizeof(float), outputBuffer.size()); - for (size_t i = 0; i < outputBuffer.size(); i++) - { - TEST_ASSERT_EQ(values[i], outputBuffer[i]); + TEST_ASSERT(resultBytes[i] == pValueBytes[j - 1]); } } - -TEST_CASE(testByteSwapDouble) +TEST_CASE(testByteSwapValues) { - using value_type = double; - static_assert(sizeof(value_type) == sizeof(uint64_t), "sizeof(value_type) != sizeof(uint64_t)"); - - const value_type v = 3.141592654; - const void* pVoid = &v; - auto pDouble = static_cast(pVoid); - auto swap = sys::byteSwap(*pDouble); - // The swapped bits could be nonsense as a `double`, so comparing might not work - //TEST_ASSERT_NOT_EQ(*pDouble, swap); - const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - auto pValueBytes = static_cast(pVoid); - TEST_ASSERT(pResultBytes[0] == pValueBytes[7]); - TEST_ASSERT(pResultBytes[1] == pValueBytes[6]); - TEST_ASSERT(pResultBytes[2] == pValueBytes[5]); - TEST_ASSERT(pResultBytes[3] == pValueBytes[4]); - TEST_ASSERT(pResultBytes[4] == pValueBytes[3]); - TEST_ASSERT(pResultBytes[5] == pValueBytes[2]); - TEST_ASSERT(pResultBytes[6] == pValueBytes[1]); - TEST_ASSERT(pResultBytes[7] == pValueBytes[0]); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pDouble, swap); - - // array swap from input to output - const std::vector values = {1.0, 2.0}; - const std::span buffer(values.data(), values.size()); - std::array outputBuffer; - const std::span outputBuffer_(outputBuffer.data(), outputBuffer.size()); - sys::byteSwap(buffer, outputBuffer_); - for (size_t i = 0; i < outputBuffer_.size(); i++) - { - // can't test swapped bytes against anything; might not be a valid `double` - swap = sys::byteSwap(outputBuffer_[i]); - TEST_ASSERT_EQ(values[i], swap); - } - - // in-place swap - sys::byteSwap(outputBuffer_); - for (size_t i = 0; i < outputBuffer_.size(); i++) - { - TEST_ASSERT_EQ(values[i], outputBuffer_[i]); - } + testByteSwapValues_(testName, two_bytes); + testByteSwapValues_(testName, four_bytes); + testByteSwapValues_(testName, eight_bytes); } -TEST_CASE(testByteSwapCxFloat) +TEST_CASE(testByteSwap12) { - using value_type = std::complex; - static_assert(sizeof(value_type) == sizeof(uint64_t), "sizeof(value_type) != sizeof(uint64_t)"); - - const value_type v = {1.1f, -9.9f}; - const void* pVoid = &v; - auto pCxFloat = static_cast(pVoid); - auto swap = sys::byteSwap(*pCxFloat); - // The swapped bits could be nonsense as a `double`, so comparing might not work - //TEST_ASSERT_NOT_EQ(*pDouble, swap); - const void* pResult_ = &swap; - auto pResultBytes = static_cast(pResult_); - auto pValueBytes = static_cast(pVoid); - TEST_ASSERT(pResultBytes[0] == pValueBytes[3]); - TEST_ASSERT(pResultBytes[1] == pValueBytes[2]); - TEST_ASSERT(pResultBytes[2] == pValueBytes[1]); - TEST_ASSERT(pResultBytes[3] == pValueBytes[0]); + // test a goofy element size + static constexpr std::byte twelve_bytes[]{ + x00, x11, x22, x33, x44, x55, + x99, xAA, xBB, xDD, xEE, xFF}; + const auto pValueBytes = sys::as_bytes(twelve_bytes); + + std::vector swappedValues(12); + auto pResultBytes = sys::make_span(swappedValues); + + auto elemSize = 12; + auto numElements = swappedValues.size() / elemSize; + sys::byteSwap(twelve_bytes, elemSize, numElements, pResultBytes.data()); + TEST_ASSERT(pResultBytes[0] == pValueBytes[11]); + TEST_ASSERT(pResultBytes[1] == pValueBytes[10]); + TEST_ASSERT(pResultBytes[2] == pValueBytes[9]); + TEST_ASSERT(pResultBytes[3] == pValueBytes[8]); TEST_ASSERT(pResultBytes[4] == pValueBytes[7]); TEST_ASSERT(pResultBytes[5] == pValueBytes[6]); TEST_ASSERT(pResultBytes[6] == pValueBytes[5]); TEST_ASSERT(pResultBytes[7] == pValueBytes[4]); - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pCxFloat, swap); - - // array swap from input to output - const std::vector values = {{1.1f, -9.9f}, {-22.22f, 88.88f}}; - const std::span buffer(values.data(), values.size()); - std::array outputBuffer; - const std::span outputBuffer_(outputBuffer.data(), outputBuffer.size()); - sys::byteSwap(buffer, outputBuffer_); - for (size_t i = 0; i(pValueBytes, pResultBytes); + TEST_ASSERT(result[0] == pValueBytes[11]); + TEST_ASSERT(result[1] == pValueBytes[10]); + TEST_ASSERT(result[2] == pValueBytes[9]); + TEST_ASSERT(result[3] == pValueBytes[8]); + TEST_ASSERT(result[4] == pValueBytes[7]); + TEST_ASSERT(result[5] == pValueBytes[6]); + TEST_ASSERT(result[6] == pValueBytes[5]); + TEST_ASSERT(result[7] == pValueBytes[4]); + TEST_ASSERT(result[8] == pValueBytes[3]); + TEST_ASSERT(result[9] == pValueBytes[2]); + TEST_ASSERT(result[10] == pValueBytes[1]); + TEST_ASSERT(result[11] == pValueBytes[0]); + + + elemSize = 6; // note that an ODD size doesn't work correctly + numElements = swappedValues.size() / elemSize; + sys::byteSwap(twelve_bytes, elemSize, numElements, swappedValues.data()); + TEST_ASSERT(pResultBytes[0] == pValueBytes[5]); + TEST_ASSERT(pResultBytes[1] == pValueBytes[4]); + TEST_ASSERT(pResultBytes[2] == pValueBytes[3]); + TEST_ASSERT(pResultBytes[3] == pValueBytes[2]); + TEST_ASSERT(pResultBytes[4] == pValueBytes[1]); + TEST_ASSERT(pResultBytes[5] == pValueBytes[0]); + + TEST_ASSERT(pResultBytes[6] == pValueBytes[11]); + TEST_ASSERT(pResultBytes[7] == pValueBytes[10]); + TEST_ASSERT(pResultBytes[8] == pValueBytes[9]); + TEST_ASSERT(pResultBytes[9] == pValueBytes[8]); + TEST_ASSERT(pResultBytes[10] == pValueBytes[7]); + TEST_ASSERT(pResultBytes[11] == pValueBytes[6]); + + sys::byteSwap(swappedValues.data(), elemSize, numElements); // swap back + for (size_t i = 0; i < swappedValues.size(); i++) { - // can't test swapped bytes against anything; might not be a valid `double` - swap = sys::byteSwap(outputBuffer_[i]); - TEST_ASSERT_EQ(values[i], swap); + TEST_ASSERT(pResultBytes[i] == pValueBytes[i]); } +} - // in-place swap - sys::byteSwap(outputBuffer_); - for (size_t i = 0; i < outputBuffer_.size(); i++) - { - TEST_ASSERT_EQ(values[i], outputBuffer_[i]); - } +template +static inline void six_byteSwap(const void* in, T& out) +{ + auto const inBytes = sys::make_span(in, sizeof(T)); + out = sys::swapBytes(inBytes); +} +TEST_CASE(testSixByteSwap) +{ + const int i = 123; + int i_swapped; + six_byteSwap(&i, i_swapped); + TEST_ASSERT_NOT_EQ(i, i_swapped); + + int result; + six_byteSwap(&i_swapped, result); + TEST_ASSERT_EQ(i, result); } TEST_MAIN( TEST_CHECK(testEndianness); TEST_CHECK(testByteSwap); - TEST_CHECK(testByteSwapUInt16); - TEST_CHECK(testByteSwapUInt32); - TEST_CHECK(testByteSwapUInt64); - TEST_CHECK(testByteSwapFloat); - TEST_CHECK(testByteSwapDouble); - TEST_CHECK(testByteSwapCxFloat); + TEST_CHECK(testByteSwapValues); + TEST_CHECK(testByteSwap12); + TEST_CHECK(testSixByteSwap); ) - \ No newline at end of file diff --git a/modules/c++/nitf/source/DecompressionInterface.cpp b/modules/c++/nitf/source/DecompressionInterface.cpp index 06328eef4..6815e5440 100644 --- a/modules/c++/nitf/source/DecompressionInterface.cpp +++ b/modules/c++/nitf/source/DecompressionInterface.cpp @@ -105,6 +105,36 @@ NITF_BOOL DecompressionInterface::adapterFreeBlock( }); } +NITF_BOOL DecompressionInterface::adapterFreeBlock( + nitf_DecompressionControl* object, + uint8_t* block, + nitf_Error* error) +{ + try + { + static_cast(object)->freeBlock(block); + return NRT_SUCCESS; + } + catch (const except::Exception& ex) + { + Utils::error_init(error, ex.getMessage(), NRT_CTXT, + NRT_ERR_DECOMPRESSION); + return NRT_FAILURE; + } + catch (const std::exception& ex) + { + Utils::error_init(error, ex, NRT_CTXT, + NRT_ERR_DECOMPRESSION); + return NRT_FAILURE; + } + catch (...) + { + nrt_Error_init(error, "Unknown error", NRT_CTXT, + NRT_ERR_DECOMPRESSION); + return NRT_FAILURE; + } +} + NITF_BOOL DecompressionInterface::adapterFreeBlock( nitf_DecompressionControl* object, std::byte* block,