From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20307 invoked by alias); 21 Feb 2011 11:50:54 -0000 Received: (qmail 20299 invoked by uid 22791); 21 Feb 2011 11:50:53 -0000 X-SWARE-Spam-Status: No, hits=0.3 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,RISK_FREE,TW_SF X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Feb 2011 11:50:48 +0000 Received: from md1.u-strasbg.fr (md1.u-strasbg.fr [IPv6:2001:660:2402::186]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p1LBoTak008335 ; Mon, 21 Feb 2011 12:50:29 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms5.u-strasbg.fr [130.79.204.14]) by md1.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p1LBoTo7008819 ; Mon, 21 Feb 2011 12:50:29 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p1LBoSFO004453 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Mon, 21 Feb 2011 12:50:29 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Joel Brobecker'" Cc: References: <001201cbc46c$5b95b100$12c11300$@muller@ics-cnrs.unistra.fr> <000001cbc473$6ef9d120$4ced7360$@muller@ics-cnrs.unistra.fr> <002401cbc574$a8d990e0$fa8cb2a0$@muller@ics-cnrs.unistra.fr> <20110221102151.GG2600@adacore.com> In-Reply-To: <20110221102151.GG2600@adacore.com> Subject: RE: [RFA] mingw port: Allow use of cvs GDB on Windows 95 Date: Mon, 21 Feb 2011 11:58:00 -0000 Message-ID: <009301cbd1bd$88ed0550$9ac70ff0$@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/msg00539.txt.bz2 > > 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. > > I was hoping that someone with more Windows knowledge would be able > to review this patch, but oh well... Thanks for doing this! > This patch looks OK to me (ie, no risk that I can see for the other > platforms). Just a couple of remarks: > > > +/* CancelIo is not available for Windows 95 OS, > > + so we need to use LoadLibrary/GetProcAddress to avoid > > + a startup failure. */ > > I find that the length of your lines are consistently really short > and inconsistent. I think it makes it harder to read. The above > can be reformatted to: > > /* CancelIo is not available for Windows 95 OS, so we need to use > LoadLibrary/GetProcAddress to avoid a startup failure. */ > > (but I think you could also look at your editor to see if there is > anything that's contributing to this, especially the inconsistency > - are you using fixed fonts?) No, it's just that I do like to have sentences in their own lines... I should try to adhere closer to GNU standards... > > +#define CancelIo dyn_CancelIo > > + > > +static BOOL WINAPI (*CancelIo) (HANDLE); > > I would *personally* keep these two together, to make it clearer > that the comment above applies to both. Just a thought, so don't > feel obligated to follow the suggestion if you don't agree. I removed the empty line in between. > > /* Stop any pending selects. */ > > - CancelIo ((HANDLE) _get_osfhandle (scb->fd)); > > + if (CancelIo) > > + CancelIo ((HANDLE) _get_osfhandle (scb->fd)); > > Can you add a comment explaining why it's OK to not call CancelIo > if it is not defined? I think you were trying to get more info > about this on this list - whatever information that you might have > gleaned... I added some explanation, see below. > The patch is pre-approved once the comments are addressed. Thanks for the approval, for the record, here is what I just committed. Pierre Muller GDB pascal language maintainer Index: ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.12615 diff -u -p -r1.12615 ChangeLog --- ChangeLog 21 Feb 2011 08:38:10 -0000 1.12615 +++ ChangeLog 21 Feb 2011 11:46:15 -0000 @@ -1,3 +1,12 @@ +2011-02-21 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. + 2011-02-21 Hui Zhu * Makefile.in (HFILES_NO_SRCDIR): Add printcmd.h. Index: 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 --- ser-mingw.c 11 Jan 2011 21:53:23 -0000 1.26 +++ ser-mingw.c 21 Feb 2011 11:46:15 -0000 @@ -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";