From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1237 invoked by alias); 5 Feb 2011 20:38:41 -0000 Received: (qmail 1228 invoked by uid 22791); 5 Feb 2011 20:38:40 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,TW_SF X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Feb 2011 20:38:35 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p15KcWMi096090 for ; Sat, 5 Feb 2011 21:38:32 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms7.u-strasbg.fr [130.79.204.16]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p15KcVvm093071 for ; Sat, 5 Feb 2011 21:38:31 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p15KcTbN058714 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Sat, 5 Feb 2011 21:38:31 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: References: <001201cbc46c$5b95b100$12c11300$@muller@ics-cnrs.unistra.fr> <000001cbc473$6ef9d120$4ced7360$@muller@ics-cnrs.unistra.fr> In-Reply-To: <000001cbc473$6ef9d120$4ced7360$@muller@ics-cnrs.unistra.fr> Subject: [RFA] mingw port: Allow use of cvs GDB on Windows 95 Date: Sat, 05 Feb 2011 20:38:00 -0000 Message-ID: <002401cbc574$a8d990e0$fa8cb2a0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00107.txt.bz2 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 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";