LADSoft / OrangeC

OrangeC Compiler And Tool Chain
http://ladsoft.tripod.com/orange_c_compiler.html
Other
291 stars 39 forks source link

posix compat: add support for fdatasync #637

Open GitMensch opened 3 years ago

GitMensch commented 3 years ago

Mainly wondering: Would it be reasonable to add fdatasync or would it be better to only support fsync, as it is now?

LADSoft commented 3 years ago

given the way fsync is written , I imagine this would just be a wrapper for fsync. would that be useful?

GitMensch commented 3 years ago

I haven't checked the fsync implementation. The documented difference between those are:

The current implementation definitely does not include anything about _POSIX_SYNCHRONIZED_IO, so I don't know if it is the third option or second or first. I think a wrapper is only reasonable if there are differences or if the current implementation is actually identical to the defined fdatasync behavior.

LADSoft commented 3 years ago

i don't think i wrote the fsync, but all it does is duplicate the handle then close the duplicated handle. I don't even know if that is correct, e.g. should it do a __flush() first.... I can't see fdatasync doing more than that because there really isn't anything more you can do...

GitMensch commented 3 years ago

Not sure, commonly fflush will ensure everything from the user-buffers used for write is at least in the filesystem cache, while fsync will wait tell the OS to place it to the disk and waits until this is done.

What part of this is done by the current implementation of fsync?

LADSoft commented 3 years ago

the current version of fsync just dups the handle and closes the dup, which I assume writes the file system buffers to disk. That says nothing about what is stored locally in the program's buffers though...