-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Add header with low level I/O helpers. #2341
Conversation
Thanks for taking care of this! I'm not particularly fond calling this file "helpers", sounds too generic. What we have inside are OS abstraction functions, so perhaps a name along the lines of "os_abstraction" or "system_abstraction" would be descriptive and to the point. Other ideas are welcome though. @SergioRAgostinho Another thing is, every file in PCL is copyrighted by OpenPerception. Generally, we allow other companies to be listed in the copyright (e.g. here), but that makes sense when a major contributing (i.e. a new algorithm implementation) was made by their employee. In the case of this PR it's mostly about moving the code around, so I don't think it's fair to extend the copyright.
I'd leave the file in the IO for now. We may examine those other classes at some later point and consider if they actually need the macros at all or whether they can be made dependent on the IO module. |
Well, they only abstract low level I/O functions.
I agree that this is a pretty minor change, but it's also not simply moving around code. The originals were macros, these are inlinable functions. The copyright notice in source code is mainly an informational statement, not a legal implication. Copyright can not be transferred without signing a legal document in most countries, and I'm not authorized to sign over copyright for my employer. I'm fine with adding more copyright statements. Especially the
The only other place where Maybe it could simply be switched to using the standard |
There is a problem with namespacing, see Travis log. I think we should either strip the |
Yeah, I saw. Probably fixed now. I'm not so sure about removing the Of course you can still explicitly call the original functions with for Putting things in the global namespace also isn't very nice though. How about renaming to |
Generally, I like
So I'd probably stick with
If you could list OpenPerception first and then your employer, like we have elsewhere in the library, would it be okay?
I agree, looks like a good candidate to being changed to ifstream functions. One problem though is that the class does not seem to have any unit tests, so we need to be absolutely sure we don't break I/O in some subtle way.
OK, I see your point. Let's do that. ( |
Alrighty, will do.
Yeah, no problem.
Right, there is a bit of seeking going on, but it should be easy to do the equivalent with
True, lets see how it looks though :) Also need to fix more build failures by the looks of it. |
713198b
to
6cd704b
Compare
Implemented most of the changes I wasn't sure on the year number to use for the Open Perception copyright statement, so I just went for Still want to switch |
There are some compilation issues in Linemod, are you still working on this? Otherwise I'd propose to leave it out and merge the PR (to unbreak PCL for MacOS users). |
Good point, I removed the linemod commit. Considering that there are no unit tests, maybe I'll just leave it alone entirely. |
434e74c
to
d474ee1
Compare
PCL_ERROR ("[pcl::PCDReader::read] lseek errno: %d strerror: %s\n", errno, strerror (errno)); | ||
PCL_ERROR ("[pcl::PCDReader::read] Error during lseek ()!\n"); | ||
return (-1); | ||
} | ||
|
||
// Read compressed size to compute how much must be mapped | ||
unsigned int compressed_size = 0; | ||
ssize_t num_read = pcl_read (fd, &compressed_size, 4); | ||
ssize_t num_read = io::raw_read (fd, &compressed_size, 4); |
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.
On Windows ssize_t
is a typedef. Now that you moved it to the pcl::io
namespace, it needs to be qualified. (See AppVeyor log for compilation errors.)
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 moved the typedef to the global namespace. Should be fixed now.
io/include/pcl/io/low_level_io.h
Outdated
return ::_write(fd, buffer, count); | ||
} | ||
|
||
inline int raw_fallocate(int fd, off_t len) |
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.
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 changed it to a long
argument now. I actually also didn't use ssize_t
in the windows wrappers, but other code is using it in some places.
I figured that the compiler can give better diagnostics when the wrapper functions have the exact same argument/returns types as the underlying function. Otherwise, a known-at-compile-time overflow in a conversion might be hidden by the implicit conversion inside the wrapper functions.
That does mean the signatures aren't identical across windows/unix, but I couldn't think of a reason why that would be a problem.
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 did change to ::_chsize
)
Hmm, the failed test loads a PCD file, so the failure could be relevant. Is there any way to get more details from the exception? I don't have a Windows machine myself, so I can't replicate the failure locally. |
This test started to fail after #2247, so nothing to do with your changes. @matt-deboer this PR addresses the issue you reported two weeks ago. Could you give it a try? |
Superseded by #2354. |
Righty. Thanks for the detailed feedback along the way :) |
This PR adds a header with some low level I/O wrappers for Windows, Unix and OSX compatibility, as discussed in #2325.
Most importantly, it should fix the use of
::posix_fallocate
for OSX.I didn't compile yet, as compiling PCL takes quite some time. But feedback is already welcome.
Note that there are a few more modules that have some
#define pcl_open ...
and similar, but right now I added the header to the IO module. Maybe the header should move to the core module so all modules can use it?