From: Ken Brown <kbrown@cornell.edu>
To: cygwin-patches <cygwin-patches@cygwin.com>
Subject: [PATCH 6/7] Cygwin: remove 32-bit only clipboard code
Date: Thu, 26 May 2022 15:17:33 -0400 [thread overview]
Message-ID: <fffabfbd-d305-4958-9c1e-f3b00b9097ec@cornell.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 15 bytes --]
Patch attached.
[-- Attachment #2: 0006-Cygwin-remove-32-bit-only-clipboard-code.patch --]
[-- Type: text/plain, Size: 3415 bytes --]
From cfa148370cb51c6874d51ee97f79d04f6e547ca9 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 24 May 2022 10:25:06 -0400
Subject: [PATCH 6/7] Cygwin: remove 32-bit only clipboard code
---
winsup/cygwin/fhandler_clipboard.cc | 16 ----------------
winsup/cygwin/include/sys/clipboard.h | 23 ++++-------------------
2 files changed, 4 insertions(+), 35 deletions(-)
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index 9515795e4..ae6de4551 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -68,14 +68,6 @@ fhandler_dev_clipboard::set_clipboard (const void *buf, size_t len)
clipbuf = (cygcb_t *) GlobalLock (hmem);
clock_gettime (CLOCK_REALTIME, &clipbuf->ts);
-#ifdef __x86_64__
- /* ts overlays cb_sec and cb_nsec such that no conversion is needed */
-#elif __i386__
- /* Expand 32-bit timespec layout to 64-bit layout.
- NOTE: Steps must be done in this order to avoid data loss. */
- clipbuf->cb_nsec = clipbuf->ts.tv_nsec;
- clipbuf->cb_sec = clipbuf->ts.tv_sec;
-#endif
clipbuf->cb_size = len;
memcpy (clipbuf->cb_data, buf, len); // append user-supplied data
@@ -180,14 +172,6 @@ fhandler_dev_clipboard::fstat (struct stat *buf)
&& (hglb = GetClipboardData (format))
&& (clipbuf = (cygcb_t *) GlobalLock (hglb)))
{
-#ifdef __x86_64__
- /* ts overlays cb_sec and cb_nsec such that no conversion is needed */
-#elif __i386__
- /* Compress 64-bit timespec layout to 32-bit layout.
- NOTE: Steps must be done in this order to avoid data loss. */
- clipbuf->ts.tv_sec = clipbuf->cb_sec;
- clipbuf->ts.tv_nsec = clipbuf->cb_nsec;
-#endif
buf->st_atim = buf->st_mtim = clipbuf->ts;
buf->st_size = clipbuf->cb_size;
GlobalUnlock (hglb);
diff --git a/winsup/cygwin/include/sys/clipboard.h b/winsup/cygwin/include/sys/clipboard.h
index 932fe98d9..e3901d0c8 100644
--- a/winsup/cygwin/include/sys/clipboard.h
+++ b/winsup/cygwin/include/sys/clipboard.h
@@ -17,33 +17,18 @@ details. */
static const WCHAR *CYGWIN_NATIVE = L"CYGWIN_NATIVE_CLIPBOARD";
-/*
- * The following layout of cygcb_t is new with Cygwin 3.3.0. It aids in the
- * transfer of clipboard contents between 32- and 64-bit Cygwin environments.
- */
typedef struct
{
union
{
- /*
- * Note that ts below overlays the struct following it. On 32-bit Cygwin
- * timespec values have to be converted to|from cygcb_t layout. On 64-bit
- * Cygwin timespec values perfectly conform to the struct following, so
- * no conversion is needed.
- *
- * We avoid directly using 'struct timespec' or 'size_t' here because they
- * are different sizes on different architectures. When copy/pasting
- * between 32- and 64-bit Cygwin, the pasted data could appear corrupted,
- * or partially interpreted as a size which can cause an access violation.
- */
- struct timespec ts; // 8 bytes on 32-bit Cygwin, 16 bytes on 64-bit Cygwin
+ struct timespec ts;
struct
{
- uint64_t cb_sec; // 8 bytes everywhere
- uint64_t cb_nsec; // 8 bytes everywhere
+ uint64_t cb_sec; // == ts.tv_sec
+ uint64_t cb_nsec; // == ts.tv_nsec
};
};
- uint64_t cb_size; // 8 bytes everywhere
+ uint64_t cb_size;
char cb_data[];
} cygcb_t;
--
2.36.1
reply other threads:[~2022-05-26 19:17 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=fffabfbd-d305-4958-9c1e-f3b00b9097ec@cornell.edu \
--to=kbrown@cornell.edu \
--cc=cygwin-patches@cygwin.com \
/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).