From: Gisle Vanem <gisle.vanem@gmail.com>
To: bug-gnulib@gnu.org
Subject: Re: immutable: Implement on native Windows
Date: Mon, 18 Jan 2021 17:52:00 +0100 [thread overview]
Message-ID: <82737e62-8c8b-b9cd-1e61-e56ec627c820@gmail.com> (raw)
In-Reply-To: <2508354.J8lELeYisT@omega>
Bruno Haible wrote:
> The 'immutable' module, so far, worked only on platforms with mmap() and
> mprotect(). With this patch, it also works on native Windows.
...
> + if (!CloseHandle (h))
> + {
> + UnmapViewOfFile (mem_w);
> + UnmapViewOfFile (mem_r);
> + CloseHandle (h);
> + return 0;
> + }
> +# else
> /* Extend the file by size/pagesize pages. */
> long new_file_length = file_length + size;
> if (ftruncate (file_fd, new_file_length) < 0)
These functions look really nice. I've yet to try them.
I noted FileZilla have similar code in 'aio.cpp', but with
handling of a macOS bug if that is something Gnulib should
handle too:
#if FZ_MAC
// There's a bug on macOS: ftruncate can only be called _once_ on a shared memory object.
// The manpages do not cover this bug, only XNU's bsd/kern/posix_shm.c mentions it.
struct stat s;
if (fstat(shm, &s) != 0) {
int err = errno;
engine_.GetLogger().log(logmsg::debug_warning, "fstat failed with error %d", err);
return false;
}
if (s.st_size < 0 || static_cast<size_t>(s.st_size) < memory_size_)
#endif
// .. then the rest is similar to yours.
Not sure if the "bug" is still there, but the
is code at:
https://svn.filezilla-project.org/filezilla/FileZilla3/trunk/src/engine/aio.cpp?view=markup#l84
--
--gv
prev parent reply other threads:[~2021-01-18 17:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-10 0:23 new module 'immutable' Bruno Haible
2021-01-18 4:09 ` immutable: Implement on native Windows Bruno Haible
2021-01-18 16:52 ` Gisle Vanem [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=82737e62-8c8b-b9cd-1e61-e56ec627c820@gmail.com \
--to=gisle.vanem@gmail.com \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).