diff options
author | Pierre Muller <muller@sourceware.org> | 2011-02-21 11:47:12 +0000 |
---|---|---|
committer | Pierre Muller <muller@sourceware.org> | 2011-02-21 11:47:12 +0000 |
commit | 4af53f973a65f675b7b084b174e9cdfa1c5265e1 (patch) | |
tree | 5baffb9345806db2fba45e7acb06799d1d72d1e6 /gdb | |
parent | 91033e3716b2eccc227992cde676198949941edf (diff) | |
download | gdb-4af53f973a65f675b7b084b174e9cdfa1c5265e1.zip gdb-4af53f973a65f675b7b084b174e9cdfa1c5265e1.tar.gz gdb-4af53f973a65f675b7b084b174e9cdfa1c5265e1.tar.bz2 |
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/ser-mingw.c | 26 |
2 files changed, 32 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 84256b9..6ccae2a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2011-02-21 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. + 2011-02-21 Hui Zhu <teawater@gmail.com> * Makefile.in (HFILES_NO_SRCDIR): Add printcmd.h. diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c index 6d8edcc..2c1f0ca 100644 --- a/gdb/ser-mingw.c +++ b/gdb/ser-mingw.c @@ -45,6 +45,11 @@ 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 @@ -216,8 +221,12 @@ ser_windows_close (struct serial *scb) { struct ser_windows_state *state; - /* Stop any pending selects. */ - CancelIo ((HANDLE) _get_osfhandle (scb->fd)); + /* Stop any pending selects. On Windows 95 OS, CancelIo function does not + exist. In that case, it can be replaced by a call to CloseHandle, but + this is not necessary here as we do close the Windows handle by calling + close (scb->fd) below. */ + if (CancelIo) + CancelIo ((HANDLE) _get_osfhandle (scb->fd)); state = scb->state; CloseHandle (state->ov.hEvent); CloseHandle (state->except_event); @@ -1208,8 +1217,19 @@ _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. */ + 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"; |