This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] mingw port: Allow use of cvs GDB on Windows 95


  After these checks, I submit now a simpler patch:
if CancelIo is not exported in kernel32, simply don't 
do anything instead.

  This allows use of current CVS GDB on windows 95 OS.

  Is this patch OK?

Pierre Muller


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

	Allow use of mingw native on Windows 95 OS.
	* src/gdb/ser-mingw.c (CancelIo): New macro for dynamically loaded
	DLL entry.
	(ser_windows_close): Only call CancelIo if function exists.
	(_initialize_ser_windows): Use LoadLirary/GetProcAddress
	to check for existence of CancelIo function in kernel32 DLL.

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	5 Feb 2011 17:28:07 -0000
@@ -45,6 +45,13 @@ 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);
+
 /* Open up a real live device for serial I/O.  */
 
 static int
@@ -217,7 +224,8 @@ ser_windows_close (struct serial *scb)
   struct ser_windows_state *state;
 
   /* Stop any pending selects.  */
-  CancelIo ((HANDLE) _get_osfhandle (scb->fd));
+  if (CancelIo)
+    CancelIo ((HANDLE) _get_osfhandle (scb->fd));
   state = scb->state;
   CloseHandle (state->ov.hEvent);
   CloseHandle (state->except_event);
@@ -1207,9 +1215,19 @@ _initialize_ser_windows (void)
 {
   WSADATA wsa_data;
   struct serial_ops *ops;
+  HMODULE hm = NULL;
 
-  /* First register the serial port driver.  */
+  /* First find out if kernel32 exports CancelIo function.  */
+  hm = LoadLibrary ("kernel32.dll");
+  if (hm)
+    {
+      CancelIo = (void *) GetProcAddress (hm, "CancelIo");
+      FreeLibrary (hm);
+    }
+  else
+    CancelIo = NULL;
 
+  /* Now register the serial port driver.  */
   ops = XMALLOC (struct serial_ops);
   memset (ops, 0, sizeof (struct serial_ops));
   ops->name = "hardwire";


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]