* [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft
@ 2022-06-02 14:12 Jon Turney
2022-06-02 14:12 ` [PATCH 1/2] Simplify cygwin_buf_t Jon Turney
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jon Turney @ 2022-06-02 14:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Jon Turney
This cleans up some cruft from Cygwin 1.5 !__USEWIDE support I noticed when
looking at the history of __USEWIDE.
Jon Turney (2):
Simplify cygwin_buf_t
Simplify __USEWIDE
gdb/nat/windows-nat.c | 3 +--
gdb/windows-nat.c | 45 +++++++++----------------------------------
2 files changed, 10 insertions(+), 38 deletions(-)
--
2.36.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] Simplify cygwin_buf_t
2022-06-02 14:12 [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Jon Turney
@ 2022-06-02 14:12 ` Jon Turney
2022-06-02 14:12 ` [PATCH 2/2] Simplify __USEWIDE Jon Turney
2022-06-02 14:43 ` [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2022-06-02 14:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Jon Turney
Prior to c6ca3dab dropping support for Cygwin 1.5, cygwin_buf_t was
defined as char_t for Cygwin 1.5. After that, it's always wchar_t, so
just use that.
---
gdb/nat/windows-nat.c | 3 +--
gdb/windows-nat.c | 21 ++++++++++-----------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index ca6a529601e..20a2902b109 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -28,7 +28,6 @@
#else
#include <sys/cygwin.h>
#define __USEWIDE
-typedef wchar_t cygwin_buf_t;
#define GetModuleFileNameEx GetModuleFileNameExW
#endif
@@ -196,7 +195,7 @@ windows_process_info::get_exec_module_filename (char *exe_name_ret,
/* Cygwin prefers that the path be in /x/y/z format, so extract
the filename into a temporary buffer first, and then convert it
to POSIX format into the destination buffer. */
- cygwin_buf_t *pathbuf = (cygwin_buf_t *) alloca (exe_name_max_len * sizeof (cygwin_buf_t));
+ wchar_t *pathbuf = (wchar_t *) alloca (exe_name_max_len * sizeof (wchar_t));
len = GetModuleFileNameEx (handle,
dh_buf, pathbuf, exe_name_max_len);
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 8631a1b4569..ab438750186 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -90,7 +90,6 @@ static windows_process_info windows_process;
static CORE_ADDR cygwin_load_start;
static CORE_ADDR cygwin_load_end;
# define __USEWIDE
- typedef wchar_t cygwin_buf_t;
# define STARTUPINFO STARTUPINFOW
# define CreateProcess CreateProcessW
#endif
@@ -683,7 +682,7 @@ windows_make_so (const char *name, LPVOID load_addr)
strcat (buf, "\\ntdll.dll");
}
#else
- cygwin_buf_t buf[__PMAX];
+ wchar_t buf[__PMAX];
buf[0] = 0;
if (access (name, F_OK) != 0)
@@ -2340,13 +2339,13 @@ windows_nat_target::create_inferior (const char *exec_file,
{
STARTUPINFO si;
#ifdef __CYGWIN__
- cygwin_buf_t real_path[__PMAX];
- cygwin_buf_t shell[__PMAX]; /* Path to shell */
- cygwin_buf_t infcwd[__PMAX];
+ wchar_t real_path[__PMAX];
+ wchar_t shell[__PMAX]; /* Path to shell */
+ wchar_t infcwd[__PMAX];
const char *sh;
- cygwin_buf_t *toexec;
- cygwin_buf_t *cygallargs;
- cygwin_buf_t *args;
+ wchar_t *toexec;
+ wchar_t *cygallargs;
+ wchar_t *args;
char **old_env = NULL;
PWCHAR w32_env;
size_t len;
@@ -2403,7 +2402,7 @@ windows_nat_target::create_inferior (const char *exec_file,
{
flags |= DEBUG_ONLY_THIS_PROCESS;
if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, exec_file, real_path,
- __PMAX * sizeof (cygwin_buf_t)) < 0)
+ __PMAX * sizeof (wchar_t)) < 0)
error (_("Error starting executable: %d"), errno);
toexec = real_path;
#ifdef __USEWIDE
@@ -2442,13 +2441,13 @@ windows_nat_target::create_inferior (const char *exec_file,
error (_("Error converting inferior cwd: %d"), errno);
#ifdef __USEWIDE
- args = (cygwin_buf_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
+ args = (wchar_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
* sizeof (wchar_t));
wcscpy (args, toexec);
wcscat (args, L" ");
wcscat (args, cygallargs);
#else /* !__USEWIDE */
- args = (cygwin_buf_t *) alloca (strlen (toexec) + strlen (cygallargs) + 2);
+ args = (char *) alloca (strlen (toexec) + strlen (cygallargs) + 2);
strcpy (args, toexec);
strcat (args, " ");
strcat (args, cygallargs);
--
2.36.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] Simplify __USEWIDE
2022-06-02 14:12 [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Jon Turney
2022-06-02 14:12 ` [PATCH 1/2] Simplify cygwin_buf_t Jon Turney
@ 2022-06-02 14:12 ` Jon Turney
2022-06-02 14:43 ` [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2022-06-02 14:12 UTC (permalink / raw)
To: gdb-patches; +Cc: Jon Turney
Prior to c6ca3dab dropping support for Cygwin 1.5, __USEWIDE not defined
for Cygwin 1.5. After that, it's always defined if __CYGWIN__ is, so
remove __USEWIDE conditionals inside __CYGWIN__ conditionals.
---
gdb/windows-nat.c | 26 --------------------------
1 file changed, 26 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ab438750186..78db4e99d40 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -89,7 +89,6 @@ static windows_process_info windows_process;
/* The starting and ending address of the cygwin1.dll text segment. */
static CORE_ADDR cygwin_load_start;
static CORE_ADDR cygwin_load_end;
-# define __USEWIDE
# define STARTUPINFO STARTUPINFOW
# define CreateProcess CreateProcessW
#endif
@@ -688,17 +687,10 @@ windows_make_so (const char *name, LPVOID load_addr)
if (access (name, F_OK) != 0)
{
if (strcasecmp (name, "ntdll.dll") == 0)
-#ifdef __USEWIDE
{
GetSystemDirectoryW (buf, sizeof (buf) / sizeof (wchar_t));
wcscat (buf, L"\\ntdll.dll");
}
-#else
- {
- GetSystemDirectoryA (buf, sizeof (buf) / sizeof (wchar_t));
- strcat (buf, "\\ntdll.dll");
- }
-#endif
}
#endif
solibs.emplace_back ();
@@ -2405,32 +2397,21 @@ windows_nat_target::create_inferior (const char *exec_file,
__PMAX * sizeof (wchar_t)) < 0)
error (_("Error starting executable: %d"), errno);
toexec = real_path;
-#ifdef __USEWIDE
len = mbstowcs (NULL, allargs, 0) + 1;
if (len == (size_t) -1)
error (_("Error starting executable: %d"), errno);
cygallargs = (wchar_t *) alloca (len * sizeof (wchar_t));
mbstowcs (cygallargs, allargs, len);
-#else /* !__USEWIDE */
- cygallargs = allargs;
-#endif
}
else
{
sh = get_shell ();
if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, sh, shell, __PMAX) < 0)
error (_("Error starting executable via shell: %d"), errno);
-#ifdef __USEWIDE
len = sizeof (L" -c 'exec '") + mbstowcs (NULL, exec_file, 0)
+ mbstowcs (NULL, allargs, 0) + 2;
cygallargs = (wchar_t *) alloca (len * sizeof (wchar_t));
swprintf (cygallargs, len, L" -c 'exec %s %s'", exec_file, allargs);
-#else /* !__USEWIDE */
- len = (sizeof (" -c 'exec '") + strlen (exec_file)
- + strlen (allargs) + 2);
- cygallargs = (char *) alloca (len);
- xsnprintf (cygallargs, len, " -c 'exec %s %s'", exec_file, allargs);
-#endif /* __USEWIDE */
toexec = shell;
flags |= DEBUG_PROCESS;
}
@@ -2440,18 +2421,11 @@ windows_nat_target::create_inferior (const char *exec_file,
infcwd, strlen (inferior_cwd)) < 0)
error (_("Error converting inferior cwd: %d"), errno);
-#ifdef __USEWIDE
args = (wchar_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
* sizeof (wchar_t));
wcscpy (args, toexec);
wcscat (args, L" ");
wcscat (args, cygallargs);
-#else /* !__USEWIDE */
- args = (char *) alloca (strlen (toexec) + strlen (cygallargs) + 2);
- strcpy (args, toexec);
- strcat (args, " ");
- strcat (args, cygallargs);
-#endif /* !__USEWIDE */
#ifdef CW_CVT_ENV_TO_WINENV
/* First try to create a direct Win32 copy of the POSIX environment. */
--
2.36.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft
2022-06-02 14:12 [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Jon Turney
2022-06-02 14:12 ` [PATCH 1/2] Simplify cygwin_buf_t Jon Turney
2022-06-02 14:12 ` [PATCH 2/2] Simplify __USEWIDE Jon Turney
@ 2022-06-02 14:43 ` Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2022-06-02 14:43 UTC (permalink / raw)
To: Jon Turney; +Cc: gdb-patches
>>>>> "Jon" == Jon Turney <jon.turney@dronecode.org.uk> writes:
Jon> This cleans up some cruft from Cygwin 1.5 !__USEWIDE support I noticed when
Jon> looking at the history of __USEWIDE.
These look good to me. Thank you for doing this.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-02 14:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 14:12 [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Jon Turney
2022-06-02 14:12 ` [PATCH 1/2] Simplify cygwin_buf_t Jon Turney
2022-06-02 14:12 ` [PATCH 2/2] Simplify __USEWIDE Jon Turney
2022-06-02 14:43 ` [PATCH 0/2] Clean up some Cygwin 1.5 !__USEWIDE cruft Tom Tromey
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).