diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2021-04-30 18:15:20 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2021-04-30 20:32:52 +0200 |
commit | 715c4208e47395bbe021c67f5bf86d08cb802905 (patch) | |
tree | 4334f108cb754e0340817637ea90468fa9682a93 | |
parent | 2d3416440213e1208ed665558e5eda765cb5f061 (diff) | |
download | newlib-715c4208e47395bbe021c67f5bf86d08cb802905.zip newlib-715c4208e47395bbe021c67f5bf86d08cb802905.tar.gz newlib-715c4208e47395bbe021c67f5bf86d08cb802905.tar.bz2 |
Cygwin: mq_open: set filesize using ftruncate
ftruncate is leaner than lseek/write.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/posix_ipc.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc index 89ec7db..fdecbca 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 */ |