-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workaround for std::tmpfile() returning nullptr o Windows #45
base: main
Are you sure you want to change the base?
Conversation
(long long changed in C++20?)
as Windows seems to differ from Linux in C++20 in the interpretation
Also, find_if() seems to be C++-20, not 17, so I changed the version in CMake. |
Notice: // In windows
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef unsigned int size_t;
#endif
// In linux
#define __SIZE_TYPE__ long unsigned int
typedef __SIZE_TYPE__ size_t; I recommand to use a fix length integer like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hint: There is a .clang_format file (Google formatting) in the root of the repository. You can set up your editor to use that file if it exist or to use google formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is OK. Maybe better to wrap the code and move it to platform.h/cpp.
This solution with temp files usage should be redone but it is little bit tricky when the DT block is split into several DT/DZ blocks. If the standard said that the splits must contain the whole record, then it should be OK but currently many files have splits randomly. The function is possibly to change without temp files. Anyone like for loops ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed from C++ 20 to C++ 17 by request of Murmele. There is a lot of chnged files due to that.
I will add a lot of changes when the bus logging writing is ready, I have the C# interface left. I anyone can figure out why I as a repository owner, cannot create a fork/branch in GitHub! Going back to C++ 20 is a problem for Murmele. Maybe it's OK for the time being and take the problem when Murmele actually use it. Note that this implementation of MDF reading uses a lot of primary memory. The previous version of this library was designed for 32-bit Windows which have a limit of 2G of primary memory. Sure enough someone wanted to read in a >4G file. The solution was to cache the observers data buffers into files. This was truly a real mess. Just curious about the WebAssembly support. Is it possible to read a file from a WebAssembly? |
I am facing same trouble of null pointer with mingw / cygwin. I have modified the code to create a string variable "data_file_name" storing a file name in the current directory with the std::tmpnam() function, excluding root character '/' or '' as first character. Here is the modified function: void Dg4Block::ReadData(std::FILE* file) const { // First scan through all CN blocks and read in any SD VLSD data related data for (const auto& cg : cg_list_) {
} // Convert everything to a samples in a file single DT block can be read bool close_data_file = false;
} auto pos = GetFilePosition(data_file); for (const auto& cg : cg_list_) { |
Maybe it is better for everyone, that the code was rewritten so it can read the file without opening a temporary file. Faster but little bit spagetti code, well maybe not so little. |
I have made version 2.1 of the MDF library. It includes the Channel Array (CA) support as well as fix for the nonaligned numbers as 6-bit signed numbers. These changes affects the iChannel/Cn4Block files why a merge to the fork is difficult to perform. The temp file function returning null, has never occurred in Windows 11 64-bit and in Ubuntu 64-bit. I have added so the unit test are run in Windows 11 and in Ubuntu in GitHub action. I also have the possibility to test on MacOS but there are some issue with the XCode compiler. MacOS/CMake using an old Clang compiler just before C++20 which cause problem for all my libraries. It's a problem to test all OS and compiler combinations with the GitHub actions due to the fact that it stops at first error, so it takes a long time to find all errors. Most compiler errors are easy to fix typical Clang/Gnu/VC compiler issues. If anyone have a compiler/OS combination that is possible to test the library + tools before check-in to the GitHub (action) and do a build YML file (see existing yml file). I recommend that avoid the matrix parallel build as it seems to cancel each other if something fails. For the tmpfile problem, I suggest to move the code snippets to the MdfHelper or Platform class and add have all #ifdef there. |
This pull request needs to be synchronized with main branch but this will be tricky as there is overlapping fixes. I do have a proposal to somewhat solve the tmpfile problem. The extra file is needed to solve the problem when the "DT" block is split or compressed.
Maybe step 1 can be skipped. This will speed up the reading somewhat. Any ides ? |
FYI |
I have checked in the Read Cache functionality for MDF 4 files. It solves the tmpfile() problem as well as improving the read speed, quite a lot actually. Most of the above changes are obsolete. I don't if a merge is possible/needed at this time. Please let me know if you need my help with the merge. |
Plus "0ULL" changed to static_cast, as C++20 interpretations differbetween Windows and Linux
PS Please excuse the line formatting, I applied clang-tidy on some files.