public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: mq_open: set filesize using ftruncate Date: Fri, 30 Apr 2021 18:32:59 +0000 (GMT) [thread overview] Message-ID: <20210430183259.CC0623857C40@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=715c4208e47395bbe021c67f5bf86d08cb802905 commit 715c4208e47395bbe021c67f5bf86d08cb802905 Author: Corinna Vinschen <corinna@vinschen.de> Date: Fri Apr 30 18:15:20 2021 +0200 Cygwin: mq_open: set filesize using ftruncate ftruncate is leaner than lseek/write. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/posix_ipc.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc index 89ec7dbef..fdecbca75 100644 --- a/winsup/cygwin/posix_ipc.cc +++ b/winsup/cygwin/posix_ipc.cc @@ -23,6 +23,8 @@ details. */ #include <mqueue.h> #include <semaphore.h> +extern "C" int ftruncate64 (int fd, off_t length); + /* The prefix_len is the length of the path prefix ncluding trailing "/" (or "/sem." for semaphores) as well as the trailing NUL. */ static struct @@ -471,9 +473,7 @@ mq_open (const char *name, int oflag, ...) msgsize = MSGSIZE (attr->mq_msgsize); filesize = sizeof (struct mq_hdr) + (attr->mq_maxmsg * (sizeof (struct msg_hdr) + msgsize)); - if (lseek64 (fd, filesize - 1, SEEK_SET) == -1) - __leave; - if (write (fd, "", 1) == -1) + if (ftruncate64 (fd, filesize) == -1) __leave; /* Memory map the file */
reply other threads:[~2021-04-30 18:32 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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 * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210430183259.CC0623857C40@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.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: linkBe 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).