Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Compte ICS" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFC] mingw port: Allow use of cvs GDB on Windows 95
Date: Fri, 04 Feb 2011 13:06:00 -0000	[thread overview]
Message-ID: <001201cbc46c$5b95b100$12c11300$@muller@ics-cnrs.unistra.fr> (raw)

  I wanted to test current GDB on windows 95
systems, but CancelIo function is not present in Windows 95
kernel32 DLL which leads to a failure at startup of GDB.

  According to
http://www.codeguru.com/forum/showthread.php?t=80410

CancelIo calls can be emulated on windows 95.
My patch simply installs a substitute that
calls CloseHandle instead.

  I don't really care for remote serial connections 
on windows 95 machines, but the currently
compiled GDB cannot be loaded on a windows 95 machine
because CancelIo is assumed to be present.

  I tried to check the existing code
to see if I should reopen the handle, but to me it
rather seems that a call to CloseHandle is missing
for the normal case... Indeed, CancelIo
is called from ser_windows_close, and it seems
that the handle cannot be used anymore.
  Does anyone use this serial connection?
Is this handle still valid afterwards? Or should it be 
close inside ser_windows_close in all cases?

  In any case, the code should function unchanged for all
systems that have CancelIo, and allows
to use GDB on windows 95 again (even if I am not sure
that serial communication will work...).

  Comments welcome,

Pierre Muller


2011-02-04  Pierre Muller  <muller@ics.u-strasbg.fr>

	* src/gdb/ser-mingw.c (CancelIo): New macro for dynamically loaded
	DLL entry.
	(win95_cancelio): New function.
	(_initialize_ser_windows): Use LoadLirary/GetProcAddress
	to check for existence of CancelIo function in kernel32
	and substitute with win95_cancelio if not found.

Index: src/gdb/ser-mingw.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-mingw.c,v
retrieving revision 1.26
diff -u -p -r1.26 ser-mingw.c
--- src/gdb/ser-mingw.c	11 Jan 2011 21:53:23 -0000	1.26
+++ src/gdb/ser-mingw.c	3 Feb 2011 10:28:53 -0000
@@ -45,6 +45,21 @@ struct ser_windows_state
   HANDLE except_event;
 };
 
+/* CancelIo is not available for Windows 95 OS,
+   so we need to use LoadLibrary/GetProcAddress to avoid
+   a startup failure.  */
+#define CancelIo dyn_CancelIo
+
+static BOOL WINAPI (*CancelIo) (HANDLE);
+
+/* Create a subtitute function for Windows 95, that 
+   simply closes the handle.  */
+static BOOL WINAPI
+win95_cancelio (HANDLE h)
+{
+  return CloseHandle (h);
+}
+
 /* Open up a real live device for serial I/O.  */
 
 static int
@@ -1208,8 +1223,21 @@ _initialize_ser_windows (void)
   WSADATA wsa_data;
   struct serial_ops *ops;
 
-  /* First register the serial port driver.  */
+  HMODULE hm = NULL;
+
+  /* First find out if kernel32 exports CancelIo function.
+     If it doesn't use win95_cancelio substitute.  */
+  hm = LoadLibrary ("kernel32.dll");
+  if (hm)
+    {
+      CancelIo = (void *) GetProcAddress (hm, "CancelIo");
+      FreeLibrary (hm);
+    }
+
+  if (!CancelIo)
+    CancelIo = (void *) win95_cancelio;
 
+  /* Now register the serial port driver.  */
   ops = XMALLOC (struct serial_ops);
   memset (ops, 0, sizeof (struct serial_ops));
   ops->name = "hardwire";




             reply	other threads:[~2011-02-04 13:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-04 13:06 Compte ICS [this message]
2011-02-04 13:57 ` Pierre Muller
2011-02-05 20:38   ` [RFA] " Pierre Muller
2011-02-21 11:06     ` Joel Brobecker
2011-02-21 11:58       ` Pierre Muller
2011-02-21 12:52         ` Joel Brobecker
2011-02-21 13:35           ` Pierre Muller
2011-02-21 14:59             ` Joel Brobecker

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='001201cbc46c$5b95b100$12c11300$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@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: 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